Skip to content

Commit

Permalink
more cases
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Sep 12, 2023
1 parent f4fbd18 commit 87bced3
Showing 1 changed file with 33 additions and 8 deletions.
41 changes: 33 additions & 8 deletions spec/01-unit/08-router_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4860,7 +4860,7 @@ end
do
local flavor = "expressions"

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

local use_case, router
Expand Down Expand Up @@ -4964,21 +4964,31 @@ do

end)

describe("Router (flavor = " .. flavor .. ") [stream] ", function()
describe("#only Router (flavor = " .. flavor .. ") [stream]", function()
reload_router(flavor, "stream")

local use_case, router

local service = {
name = "service-invalid",
protocol = "tcp",
}

lazy_setup(function()
use_case = {
-- query has one value
{
service = {
name = "service-tls-passthough-invalid",
protocol = "tcp",
},
service = service,
route = {
id = "e8fb37f1-102d-461e-9c51-6608a6bb8101",
protocols = { "tls" },
expression = [[tls.sni == "www.example.com"]],
priority = 100,
},
},
{
service = service,
route = {
id = "e8fb37f1-102d-461e-9c51-6608a6bb8102",
protocols = { "tls_passthough" },
expression = [[tls.sni == "www.example.org"]],
priority = 100,
Expand All @@ -4989,6 +4999,21 @@ do
router = assert(new_router(use_case))
end)

it("exec() should match tls with tls.sni", function()
local _ngx = {
var = {
remote_port = 1000,
server_port = 1000,
ssl_preread_server_name = "www.example.com",
},
}
router._set_ngx(_ngx)
local match_t = router:exec()
assert.truthy(match_t)

assert.same(use_case[1].route, match_t.route)
end)

it("exec() should match tls_passthough with tls.sni", function()
local _ngx = {
var = {
Expand All @@ -5001,7 +5026,7 @@ do
local match_t = router:exec()
assert.truthy(match_t)

assert.same(use_case[1].route, match_t.route)
assert.same(use_case[2].route, match_t.route)
end)

end)
Expand Down

0 comments on commit 87bced3

Please sign in to comment.