Skip to content

Commit

Permalink
chore(deps): bump atc-router to v1.6.0 and add changelog entry for "n…
Browse files Browse the repository at this point in the history
…ot" operator support in ATC (#12405)

KAG-3605

---------

Co-authored-by: Datong Sun <[email protected]>
  • Loading branch information
2 people authored and locao committed Mar 5, 2024
1 parent f2093e1 commit 415d115
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .requirements
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ LUA_KONG_NGINX_MODULE=4fbc3ddc7dcbc706ed286b95344f3cb6da17e637 # 0.8.0
LUA_RESTY_LMDB=951926f20b674a0622236a0e331b359df1c02d9b # 1.3.0
LUA_RESTY_EVENTS=8448a92cec36ac04ea522e78f6496ba03c9b1fd8 # 0.2.0
LUA_RESTY_WEBSOCKET=60eafc3d7153bceb16e6327074e0afc3d94b1316 # 0.4.0
ATC_ROUTER=ee6bb38f9c71becb750041f605bfe0fffc2c70fe # 1.5.1
ATC_ROUTER=1abb9286947b70b4e302d8df953961c1280a0289 # 1.6.0

KONG_MANAGER=v3.5.0.0
NGX_WASM_MODULE=388d5720293f5091ccee1f859a42683fbfd14e7d # prerelease-0.2.0
Expand Down
3 changes: 3 additions & 0 deletions changelog/unreleased/expressions_not_operator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
message: The expressions route now supports the `!` (not) operator, which allows creating routes like `!(http.path =^)` and `!(http.path == "/a" || http.path == "/b")`
type: "feature"
scope: "Core"
2 changes: 1 addition & 1 deletion changelog/unreleased/kong/bump-atc-router.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
message: Bumped atc-router from 1.2.0 to 1.5.1
message: Bumped atc-router from 1.2.0 to 1.6.0
type: dependency
scope: Core
19 changes: 19 additions & 0 deletions spec/01-unit/01-db/01-schema/06-routes_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,25 @@ describe("routes schema (flavor = expressions)", function()
reload_flavor("expressions")
setup_global_env()

it("validates a 'not' expression", function()
local route = {
id = a_valid_uuid,
name = "my_route",
protocols = { "http" },
expression = [[!(http.method == "GET") && !(http.host == "example.com") && !(http.path ^= "/foo")]],
priority = 100,
strip_path = false,
preserve_host = true,
service = { id = another_uuid },
}
route = Routes:process_auto_fields(route, "insert")
assert.truthy(route.created_at)
assert.truthy(route.updated_at)
assert.same(route.created_at, route.updated_at)
assert.truthy(Routes:validate(route))
assert.falsy(route.strip_path)
end)

it("validates a valid http route", function()
local route = {
id = a_valid_uuid,
Expand Down
30 changes: 30 additions & 0 deletions spec/01-unit/08-router_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5631,5 +5631,35 @@ do
assert.same(ctx.route_match_cached, "pos")
end)
end)

describe("Router (flavor = " .. flavor .. ") [http]", function()
reload_router(flavor)

it("select() should match not expression", function()
local use_case = {
{
service = service,
route = {
id = "e8fb37f1-102d-461e-9c51-6608a6bb8101",
expression = [[!(http.path ^= r#"/foo"#)]],
priority = 100,
},
},
}

local router = assert(new_router(use_case))

local match_t = router:select("GET", "/123/foo/bar")
assert.truthy(match_t)
assert.same(use_case[1].route, match_t.route)

local match_t = router:select("GET", "/xyz/hello-world/bar")
assert.truthy(match_t)
assert.same(use_case[1].route, match_t.route)

local match_t = router:select("GET", "/foo/bar")
assert.falsy(match_t)
end)
end)
end -- local flavor = "expressions"

0 comments on commit 415d115

Please sign in to comment.