From f9761c3437530dfaa2812ab6f1ec030e17f5c5dc Mon Sep 17 00:00:00 2001 From: Trong Huu Nguyen Date: Tue, 2 Jul 2024 21:54:18 +0200 Subject: [PATCH] test(config): add some more cases, remove unneeded parameter --- pkg/config/config_test.go | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 0f83d71..724caf3 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -23,7 +23,7 @@ func TestConfig_Validate(t *testing.T) { mutate func(cfg *config.Config) } - run := func(t *testing.T, name string, base *config.Config, tests []test) { + run := func(name string, base *config.Config, tests []test) { t.Run(name, func(t *testing.T) { t.Run("happy path", func(t *testing.T) { err = base.Validate() @@ -42,7 +42,7 @@ func TestConfig_Validate(t *testing.T) { }) } - run(t, "default", fixture, []test{ + run("default", fixture, []test{ { "invalid value for cookie-same-site", func(cfg *config.Config) { @@ -109,13 +109,19 @@ func TestConfig_Validate(t *testing.T) { server.Session.RefreshAuto = false server.Redis.Address = "localhost:6379" - run(t, "sso server", server, []test{ + run("sso server", server, []test{ { "missing redis", func(cfg *config.Config) { cfg.Redis = config.Redis{} }, }, + { + "missing cookie name", + func(cfg *config.Config) { + cfg.SSO.SessionCookieName = "" + }, + }, { "with session auto refresh", func(cfg *config.Config) { @@ -135,7 +141,7 @@ func TestConfig_Validate(t *testing.T) { }, }, { - "invalid server default redirect url", + "invalid default redirect url", func(cfg *config.Config) { cfg.SSO.ServerDefaultRedirectURL = "invalid" }, @@ -156,13 +162,19 @@ func TestConfig_Validate(t *testing.T) { proxy.Session.RefreshAuto = false proxy.Redis.Address = "localhost:6379" - run(t, "sso proxy", proxy, []test{ + run("sso proxy", proxy, []test{ { "missing redis", func(cfg *config.Config) { cfg.Redis = config.Redis{} }, }, + { + "missing cookie name", + func(cfg *config.Config) { + cfg.SSO.SessionCookieName = "" + }, + }, { "with session auto refresh", func(cfg *config.Config) {