From 7c7a1b9c8bda52065ef3bbf9840a48428a3be2b5 Mon Sep 17 00:00:00 2001 From: BrianKopp Date: Sat, 8 Feb 2020 12:58:52 -0700 Subject: [PATCH] Update samesite tests --- .../nginx/lua/test/balancer/sticky_test.lua | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/rootfs/etc/nginx/lua/test/balancer/sticky_test.lua b/rootfs/etc/nginx/lua/test/balancer/sticky_test.lua index d967769e1..c1bee4ac0 100644 --- a/rootfs/etc/nginx/lua/test/balancer/sticky_test.lua +++ b/rootfs/etc/nginx/lua/test/balancer/sticky_test.lua @@ -114,6 +114,7 @@ describe("Sticky", function() set = function(self, payload) assert.equal(payload.key, test_backend.sessionAffinityConfig.cookieSessionAffinity.name) assert.equal(payload.path, ngx.var.location_path) + assert.equal(payload.samesite, nil) assert.equal(payload.domain, nil) assert.equal(payload.httponly, true) assert.equal(payload.secure, false) @@ -143,6 +144,7 @@ describe("Sticky", function() set = function(self, payload) assert.equal(payload.key, test_backend.sessionAffinityConfig.cookieSessionAffinity.name) assert.equal(payload.path, ngx.var.location_path) + assert.equal(payload.samesite, nil) assert.equal(payload.domain, nil) assert.equal(payload.httponly, true) assert.equal(payload.secure, true) @@ -185,6 +187,7 @@ describe("Sticky", function() set = function(self, payload) assert.equal(payload.key, test_backend.sessionAffinityConfig.cookieSessionAffinity.name) assert.equal(payload.path, ngx.var.location_path) + assert.equal(payload.samesite, nil) assert.equal(payload.domain, nil) assert.equal(payload.httponly, true) assert.equal(payload.secure, false) @@ -228,6 +231,7 @@ describe("Sticky", function() assert.equal(payload.path, ngx.var.location_path) assert.equal(payload.domain, ngx.var.host) assert.equal(payload.httponly, true) + assert.equal(payload.samesite, nil) return true, nil end, get = function(k) return false end, @@ -368,6 +372,7 @@ describe("Sticky", function() set = function(self, payload) assert.equal(payload.key, test_backend.sessionAffinityConfig.cookieSessionAffinity.name) assert.equal(payload.path, ngx.var.location_path) + assert.equal(payload.samesite, nil) assert.equal(payload.domain, nil) assert.equal(payload.httponly, true) assert.equal(payload.secure, false) @@ -405,13 +410,14 @@ describe("Sticky", function() cookie.new = mocked_cookie_new end) - local function test_set_cookie(sticky, samesite, conditional_samesite_none, expected_path) + local function test_set_cookie(sticky, samesite, conditional_samesite_none, expected_path, expected_samesite) local s = {} cookie.new = function(self) local cookie_instance = { set = function(self, payload) assert.equal(payload.key, test_backend.sessionAffinityConfig.cookieSessionAffinity.name) assert.equal(payload.path, expected_path) + assert.equal(payload.samesite, expected_samesite) assert.equal(payload.domain, nil) assert.equal(payload.httponly, true) assert.equal(payload.secure, false) @@ -433,27 +439,27 @@ describe("Sticky", function() end it("returns a cookie with SameSite=Strict when user specifies samesite strict", function() - test_set_cookie(sticky_balanced, "Strict", false, "/; SameSite=Strict") + test_set_cookie(sticky_balanced, "Strict", false, "/", "Strict") end) it("returns a cookie with SameSite=Strict when user specifies samesite strict and conditional samesite none", function() - test_set_cookie(sticky_balanced, "Strict", true, "/; SameSite=Strict") + test_set_cookie(sticky_balanced, "Strict", true, "/", "Strict") end) it("returns a cookie with SameSite=Lax when user specifies samesite lax", function() - test_set_cookie(sticky_balanced, "Lax", false, "/; SameSite=Lax") + test_set_cookie(sticky_balanced, "Lax", false, "/", "Lax") end) it("returns a cookie with SameSite=Lax when user specifies samesite lax and conditional samesite none", function() - test_set_cookie(sticky_balanced, "Lax", true, "/; SameSite=Lax") + test_set_cookie(sticky_balanced, "Lax", true, "/", "Lax") end) it("returns a cookie with SameSite=None when user specifies samesite None", function() - test_set_cookie(sticky_balanced, "None", false, "/; SameSite=None") + test_set_cookie(sticky_balanced, "None", false, "/", "None") end) it("returns a cookie with SameSite=None when user specifies samesite None and conditional samesite none with supported user agent", function() mock_ngx({ var = { location_path = "/", host = "test.com" , http_user_agent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.2704.103 Safari/537.36"} }) - test_set_cookie(sticky_balanced, "None", true, "/; SameSite=None") + test_set_cookie(sticky_balanced, "None", true, "/", "None") end) it("returns a cookie without SameSite=None when user specifies samesite None and conditional samesite none with unsupported user agent", function() mock_ngx({ var = { location_path = "/", host = "test.com" , http_user_agent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36"} }) - test_set_cookie(sticky_balanced, "None", true, "/") + test_set_cookie(sticky_balanced, "None", true, "/", nil) end) end) end)