From 6cbc7d94ef42f829a036ddf8254fe8b8534b4eba Mon Sep 17 00:00:00 2001 From: Kong Deployment Bot Date: Thu, 23 Feb 2023 09:47:56 -0500 Subject: [PATCH] fix(clustering): session renamed fields (#10354) Co-authored-by: Samuele Illuminati --- CHANGELOG.md | 2 ++ kong/clustering/compat/init.lua | 1 + spec/01-unit/19-hybrid/03-compat_spec.lua | 34 +++++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c153b5a89a92..c1ad0d075e5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,6 +80,8 @@ - Fix an issue where control plane does not downgrade config for `aws_lambda` and `zipkin` for older version of data planes. [#10346](https://github.com/Kong/kong/pull/10346) +- Fix an issue where control plane does not rename fields correctly for `session` for older version of data planes. + [#10352](https://github.com/Kong/kong/pull/10352) ## 3.2.0 diff --git a/kong/clustering/compat/init.lua b/kong/clustering/compat/init.lua index 69c0df6bafb5..dbb2a16c6bc4 100644 --- a/kong/clustering/compat/init.lua +++ b/kong/clustering/compat/init.lua @@ -238,6 +238,7 @@ end local function rename_field(config, name_from, name_to, has_update) if config[name_from] ~= nil then config[name_to] = config[name_from] + config[name_from] = nil return true end return has_update diff --git a/spec/01-unit/19-hybrid/03-compat_spec.lua b/spec/01-unit/19-hybrid/03-compat_spec.lua index 5d75537e4a75..a0d98882631f 100644 --- a/spec/01-unit/19-hybrid/03-compat_spec.lua +++ b/spec/01-unit/19-hybrid/03-compat_spec.lua @@ -157,6 +157,9 @@ describe("kong.clustering.compat", function() "goodbye", "my.nested.field", }, + session = { + "anything", + }, }, }) end) @@ -275,6 +278,37 @@ describe("kong.clustering.compat", function() }, }, }, + + { + name = "renamed fields", + version = "1.0.0", + plugins = { + { + name = "session", + config = { + idling_timeout = 60, + rolling_timeout = 60, + stale_ttl = 60, + cookie_same_site = "Default", + cookie_http_only = false, + remember = true, + }, + }, + }, + expect = { + { + name = "session", + config = { + cookie_idletime = 60, + cookie_lifetime = 60, + cookie_discard = 60, + cookie_samesite = "Lax", + cookie_httponly = false, + cookie_persistent = true, + }, + }, + }, + }, } for _, case in ipairs(cases) do