Skip to content

Commit

Permalink
move stream test in front of http test
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Sep 13, 2023
1 parent 9d93c1f commit 8a4aa00
Showing 1 changed file with 67 additions and 69 deletions.
136 changes: 67 additions & 69 deletions spec/01-unit/08-router_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4860,6 +4860,73 @@ end
do
local flavor = "expressions"

describe("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 = {
{
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_passthrough" },
expression = [[tls.sni == "www.example.org"]],
priority = 100,
},
},
}

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_passthrough with tls.sni", function()
local _ngx = {
var = {
remote_port = 1000,
server_port = 1000,
ssl_preread_server_name = "www.example.org",
},
}
router._set_ngx(_ngx)
local match_t = router:exec()
assert.truthy(match_t)

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

end)

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

Expand Down Expand Up @@ -4963,74 +5030,5 @@ do
end)

end)

--[==[
describe("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 = {
{
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_passthrough" },
expression = [[tls.sni == "www.example.org"]],
priority = 100,
},
},
}
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_passthrough with tls.sni", function()
local _ngx = {
var = {
remote_port = 1000,
server_port = 1000,
ssl_preread_server_name = "www.example.org",
},
}
router._set_ngx(_ngx)
local match_t = router:exec()
assert.truthy(match_t)
assert.same(use_case[2].route, match_t.route)
end)
end)
--]==]
end

0 comments on commit 8a4aa00

Please sign in to comment.