add e2e test for cookie annotations
This commit is contained in:
parent
7de718f359
commit
38279366a5
3 changed files with 24 additions and 35 deletions
|
|
@ -74,7 +74,7 @@ local function set_cookie(self, value)
|
|||
}
|
||||
|
||||
local expires
|
||||
if self.cookie_expires then
|
||||
if self.cookie_expires and self.cookie_expires ~= "" then
|
||||
expires, err = parse_cookie_expires(self.cookie_expires)
|
||||
if err then
|
||||
ngx.log(ngx.WARN, string.format("error when parsing cookie expires: %s, ignoring it", tostring(err)))
|
||||
|
|
@ -83,7 +83,7 @@ local function set_cookie(self, value)
|
|||
end
|
||||
end
|
||||
|
||||
if self.cookie_max_age then
|
||||
if self.cookie_max_age and self.cookie_max_age ~= "" then
|
||||
cookie_data.max_age = tonumber(self.cookie_max_age)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -88,38 +88,6 @@ describe("Sticky", function()
|
|||
assert.equal(sticky_balancer_instance.digest_func, default_hash_implementation)
|
||||
end)
|
||||
end)
|
||||
|
||||
context("when backend specifies cookie expires", function()
|
||||
it("returns an instance containing the corresponding cookie expires", function()
|
||||
local temp_backend = util.deepcopy(test_backend)
|
||||
temp_backend.sessionAffinityConfig.cookieSessionAffinity.expires = "1y"
|
||||
local sticky_balancer_instance = sticky:new(temp_backend)
|
||||
assert.equal(sticky_balancer_instance.cookie_expires, "1y")
|
||||
end)
|
||||
end)
|
||||
|
||||
context("when backend does not specify cookie expires", function()
|
||||
it("returns an instance without cookie expires", function()
|
||||
local sticky_balancer_instance = sticky:new(test_backend)
|
||||
assert.equal(sticky_balancer_instance.cookie_expires, nil)
|
||||
end)
|
||||
end)
|
||||
|
||||
context("when backend specifies cookie max-age", function()
|
||||
it("returns an instance containing the corresponding cookie max-age", function()
|
||||
local temp_backend = util.deepcopy(test_backend)
|
||||
temp_backend.sessionAffinityConfig.cookieSessionAffinity.maxage = 1000
|
||||
local sticky_balancer_instance = sticky:new(temp_backend)
|
||||
assert.equal(sticky_balancer_instance.cookie_max_age, 1000)
|
||||
end)
|
||||
end)
|
||||
|
||||
context("when backend does not specify cookie max-age", function()
|
||||
it("returns an instance without cookie max-age", function()
|
||||
local sticky_balancer_instance = sticky:new(test_backend)
|
||||
assert.equal(sticky_balancer_instance.cookie_max_age, nil)
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("balance()", function()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue