-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 469e7d8
Showing
16 changed files
with
685 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
return { | ||
default = { | ||
verbose = true, | ||
coverage = false, | ||
output = "gtest", | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
charset = utf-8 | ||
|
||
[*.lua] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[kong/templates/nginx*] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[*.template] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[Makefile] | ||
indent_style = tab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "monthly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: Lint | ||
concurrency: | ||
group: ${{ github.workflow }} ${{ github.ref }} | ||
cancel-in-progress: ${{ github.event_name == 'pull_request' }} | ||
on: | ||
pull_request: {} | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
luacheck: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: LuaCheck linter | ||
uses: lunarmodules/luacheck@master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: "Test" | ||
concurrency: | ||
group: ${{ github.workflow }} ${{ github.ref }} | ||
cancel-in-progress: ${{ github.event_name == 'pull_request' }} | ||
on: | ||
pull_request: {} | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
kongVersion: | ||
- "3.7.x" | ||
- "dev" | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Replace consumer key | ||
run: sed -i 's/consumer_key = "__CONSUMER_KEY__"/consumer_key = "${{ vars.CONSUMER_KEY }}"/g' spec/swift-auth/01-integration_spec.lua | ||
- name: Replace consumer secret | ||
run: sed -i 's/consumer_secret = "__CONSUMER_SECRET__"/consumer_secret = "${{ secrets.CONSUMER_SECRET }}"/g' spec/swift-auth/01-integration_spec.lua | ||
- name: Tests | ||
uses: Kong/kong-pongo-action@v1 | ||
with: | ||
pongo_version: master | ||
kong_version: ${{ matrix.kongVersion }} | ||
- run: pongo run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
**/.DS_Store | ||
|
||
# servroot is typically the nginx/Kong workingdirectory when testing | ||
servroot | ||
|
||
# packed distribution format for LuaRocks | ||
*.rock | ||
# exclude Pongo shell history | ||
.pongo/.ash_history | ||
.pongo/.bash_history | ||
# exclude LuaCov statistics file | ||
luacov.stats.out | ||
# exclude LuaCov report | ||
luacov.report.out | ||
# exclude Pongo containerid file | ||
.containerid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
-- Configuration file for LuaCheck | ||
-- see: https://luacheck.readthedocs.io/en/stable/ | ||
-- | ||
-- To run do: `luacheck .` from the repo | ||
|
||
std = "ngx_lua" | ||
unused_args = false | ||
redefined = false | ||
max_line_length = false | ||
|
||
|
||
globals = { | ||
"_KONG", | ||
"kong", | ||
"ngx.IS_CLI", | ||
} | ||
|
||
|
||
not_globals = { | ||
"string.len", | ||
"table.getn", | ||
} | ||
|
||
|
||
ignore = { | ||
"6.", -- ignore whitespace warnings | ||
} | ||
|
||
|
||
include_files = { | ||
"**/*.lua", | ||
"*.rockspec", | ||
".busted", | ||
".luacheckrc", | ||
} | ||
|
||
exclude_files = { | ||
--"spec/fixtures/invalid-module.lua", | ||
--"spec-old-api/fixtures/invalid-module.lua", | ||
} | ||
|
||
|
||
files["spec/**/*.lua"] = { | ||
std = "ngx_lua+busted", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
include = { | ||
"%/kong%-plugin%/kong%/.+$", | ||
} | ||
|
||
statsfile = "/kong-plugin/luacov.stats.out" | ||
reportfile = "/kong-plugin/luacov.report.out" | ||
runreport = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--postgres | ||
--no-cassandra |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Kong Swift OAuth plugin | ||
|
||
This plugin requests a Swift OAuth2 token and adds the retrieved OAuth access token into | ||
the HTTP Authorization header of proxied requests. | ||
|
||
## Table of contents | ||
- [Requirements](#requirements) | ||
- [Testing](#testing) | ||
|
||
## Requirements | ||
|
||
Pongo provides a simple way of testing Kong plugins. For a complete walkthrough [check this blogpost on the Kong website](https://konghq.com/blog/custom-lua-plugin-kong-gateway). | ||
|
||
Required tools: | ||
|
||
* `docker-compose` (and hence `docker`) | ||
* `curl` | ||
* `realpath`, for older MacOS versions you need the [`coreutils`](https://www.gnu.org/software/coreutils/coreutils.html) | ||
to be installed. This is easiest via the [Homebrew package manager](https://brew.sh/) by doing: | ||
``` | ||
brew install coreutils | ||
``` | ||
* Depending on your environment you should set some [environment variables](#configuration). | ||
|
||
## Testing | ||
|
||
### Create an app | ||
[Create an application](https://developer.swift.com/myapps) and select the API products you want to use. `Payment Pre-validation API` and `gpi API` API products have to be selected | ||
to run the integrations tests. | ||
|
||
### Do a test run | ||
|
||
Clone Pongo repository and install Pongo shell script: | ||
``` | ||
PATH=$PATH:~/.local/bin | ||
git clone https://github.com/Kong/kong-pongo.git | ||
mkdir -p ~/.local/bin | ||
ln -s $(realpath kong-pongo/pongo.sh) ~/.local/bin/pongo | ||
``` | ||
|
||
Clone the plugin repository: | ||
|
||
``` | ||
git clone https://github.com/swiftinc/kong-plugin-swift-auth.git | ||
cd kong-plugin-swift-auth | ||
``` | ||
|
||
Replace the `__CONSUMER_KEY__` and `__CONSUMER_SECRET__` placeholders from the `spec/swift-auth/01-integration_spec.lua` with the values from the application created in the developer portal: | ||
|
||
``` | ||
-- ############################################ | ||
-- REPLACE BEFORE LAUNCHING THE TESTS | ||
-- ############################################ | ||
local consumer_key = "__CONSUMER_KEY__" | ||
local consumer_secret = "__CONSUMER_SECRET__" | ||
-- ############################################ | ||
``` | ||
|
||
Auto pull and build the test images: | ||
|
||
``` | ||
pongo run | ||
``` | ||
|
||
To directly access Kong from the host, `--expose` argument can be used expose the internal ports to the host: | ||
|
||
``` | ||
pongo run --expose | ||
``` | ||
|
||
The above command will automatically build the test image and start the test environment. When done, the test environment can be torn down by: | ||
|
||
``` | ||
pongo down | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
local plugin_name = "swift-auth" | ||
local package_name = "kong-plugin-" .. plugin_name | ||
local package_version = "1.0.0" | ||
local rockspec_revision = "1" | ||
|
||
local github_account_name = "swiftinc" | ||
local github_repo_name = "kong-plugin-swift-auth" | ||
local git_checkout = package_version == "dev" and "master" or package_version | ||
|
||
package = package_name | ||
version = package_version .. "-" .. rockspec_revision | ||
supported_platforms = { "linux", "macosx" } | ||
source = { | ||
url = "git+https://github.com/"..github_account_name.."/"..github_repo_name..".git", | ||
branch = git_checkout, | ||
} | ||
|
||
description = { | ||
summary = "Kong is a scalable and customizable API Management Layer built on top of Nginx.", | ||
homepage = "https://"..github_account_name..".github.io/"..github_repo_name, | ||
license = "Swift API sample code", | ||
} | ||
|
||
dependencies = { | ||
} | ||
|
||
build = { | ||
type = "builtin", | ||
modules = { | ||
["kong.plugins."..plugin_name..".utils"] = "kong/plugins/"..plugin_name.."/utils.lua", | ||
["kong.plugins."..plugin_name..".handler"] = "kong/plugins/"..plugin_name.."/handler.lua", | ||
["kong.plugins."..plugin_name..".schema"] = "kong/plugins/"..plugin_name.."/schema.lua", | ||
["kong.plugins."..plugin_name..".access"] = "kong/plugins/"..plugin_name.."/access.lua", | ||
} | ||
} |
Oops, something went wrong.