From 82d5da209e34cce9e247d8c972f29a48eb135e5a Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Tue, 10 Dec 2024 18:08:25 +0800 Subject: [PATCH] chore: update unit tests --- pkg/config/auth_test.go | 17 +++++------------ .../local_enabled_and_disabled.diff | 2 +- .../local_disabled_remote_enabled.diff | 2 +- .../local_enabled_remote_disabled.diff | 2 +- .../local_enabled_and_disabled.diff | 6 +++--- .../local_disabled_remote_enabled.diff | 7 +------ .../local_enabled_remote_disabled.diff | 8 +------- .../TestMfaDiff/local_enabled_and_disabled.diff | 4 ++-- .../enable_sign_up_without_provider.diff | 2 +- .../local_disabled_remote_enabled.diff | 4 ++-- .../local_enabled_remote_disabled.diff | 6 +++--- 11 files changed, 21 insertions(+), 39 deletions(-) diff --git a/pkg/config/auth_test.go b/pkg/config/auth_test.go index f85b87730..e8e9c6811 100644 --- a/pkg/config/auth_test.go +++ b/pkg/config/auth_test.go @@ -186,11 +186,7 @@ func TestHookDiff(t *testing.T) { Enabled: false, URI: "pg-functions://postgres/public/verifyMFA", }, - PasswordVerificationAttempt: &hookConfig{ - Enabled: false, - URI: "http://example.com", - Secrets: "test-secret", - }, + PasswordVerificationAttempt: nil, } // Run test diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ @@ -198,12 +194,12 @@ func TestHookDiff(t *testing.T) { HookCustomAccessTokenUri: cast.Ptr("http://example.com"), HookCustomAccessTokenSecrets: cast.Ptr("ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252"), HookSendSmsEnabled: cast.Ptr(true), - HookSendSmsUri: cast.Ptr(""), - HookSendSmsSecrets: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + HookSendSmsUri: cast.Ptr("https://example.com"), + HookSendSmsSecrets: cast.Ptr("ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252"), HookSendEmailEnabled: cast.Ptr(true), HookSendEmailUri: cast.Ptr("pg-functions://postgres/public/sendEmail"), HookMfaVerificationAttemptEnabled: cast.Ptr(true), - HookMfaVerificationAttemptUri: cast.Ptr(""), + HookMfaVerificationAttemptUri: cast.Ptr("pg-functions://postgres/public/verifyMFA"), HookPasswordVerificationAttemptEnabled: cast.Ptr(true), HookPasswordVerificationAttemptUri: cast.Ptr("https://example.com"), HookPasswordVerificationAttemptSecrets: cast.Ptr("ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252"), @@ -234,10 +230,7 @@ func TestHookDiff(t *testing.T) { Enabled: true, URI: "pg-functions://postgres/public/verifyMFA", }, - PasswordVerificationAttempt: &hookConfig{ - Enabled: true, - URI: "pg-functions://postgres/public/verifyPassword", - }, + PasswordVerificationAttempt: nil, } // Run test diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ diff --git a/pkg/config/testdata/TestAuthDiff/local_enabled_and_disabled.diff b/pkg/config/testdata/TestAuthDiff/local_enabled_and_disabled.diff index 3db4d5462..b4022569c 100644 --- a/pkg/config/testdata/TestAuthDiff/local_enabled_and_disabled.diff +++ b/pkg/config/testdata/TestAuthDiff/local_enabled_and_disabled.diff @@ -25,4 +25,4 @@ diff remote[auth] local[auth] +password_requirements = "lower_upper_letters_digits_symbols" [hook] - [hook.mfa_verification_attempt] + diff --git a/pkg/config/testdata/TestEmailDiff/local_disabled_remote_enabled.diff b/pkg/config/testdata/TestEmailDiff/local_disabled_remote_enabled.diff index 3308fd0a4..99a50071f 100644 --- a/pkg/config/testdata/TestEmailDiff/local_disabled_remote_enabled.diff +++ b/pkg/config/testdata/TestEmailDiff/local_disabled_remote_enabled.diff @@ -1,7 +1,7 @@ diff remote[auth] local[auth] --- remote[auth] +++ local[auth] -@@ -51,13 +51,13 @@ +@@ -31,13 +31,13 @@ inactivity_timeout = "0s" [email] diff --git a/pkg/config/testdata/TestEmailDiff/local_enabled_remote_disabled.diff b/pkg/config/testdata/TestEmailDiff/local_enabled_remote_disabled.diff index d42967e05..85d30362a 100644 --- a/pkg/config/testdata/TestEmailDiff/local_enabled_remote_disabled.diff +++ b/pkg/config/testdata/TestEmailDiff/local_enabled_remote_disabled.diff @@ -1,7 +1,7 @@ diff remote[auth] local[auth] --- remote[auth] +++ local[auth] -@@ -51,35 +51,43 @@ +@@ -31,35 +31,43 @@ inactivity_timeout = "0s" [email] diff --git a/pkg/config/testdata/TestExternalDiff/local_enabled_and_disabled.diff b/pkg/config/testdata/TestExternalDiff/local_enabled_and_disabled.diff index 37ab653dd..089d74eee 100644 --- a/pkg/config/testdata/TestExternalDiff/local_enabled_and_disabled.diff +++ b/pkg/config/testdata/TestExternalDiff/local_enabled_and_disabled.diff @@ -1,7 +1,7 @@ diff remote[auth] local[auth] --- remote[auth] +++ local[auth] -@@ -91,7 +91,7 @@ +@@ -71,7 +71,7 @@ [external] [external.apple] @@ -10,7 +10,7 @@ diff remote[auth] local[auth] client_id = "test-client-1,test-client-2" secret = "hash:ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252" url = "" -@@ -98,9 +98,9 @@ +@@ -78,9 +78,9 @@ redirect_uri = "" skip_nonce_check = false [external.azure] @@ -23,7 +23,7 @@ diff remote[auth] local[auth] url = "" redirect_uri = "" skip_nonce_check = false -@@ -147,7 +147,7 @@ +@@ -127,7 +127,7 @@ redirect_uri = "" skip_nonce_check = false [external.google] diff --git a/pkg/config/testdata/TestHookDiff/local_disabled_remote_enabled.diff b/pkg/config/testdata/TestHookDiff/local_disabled_remote_enabled.diff index 69f0f7901..c8cf4c5f0 100644 --- a/pkg/config/testdata/TestHookDiff/local_disabled_remote_enabled.diff +++ b/pkg/config/testdata/TestHookDiff/local_disabled_remote_enabled.diff @@ -1,7 +1,7 @@ diff remote[auth] local[auth] --- remote[auth] +++ local[auth] -@@ -11,23 +11,23 @@ +@@ -11,19 +11,19 @@ [hook] [hook.mfa_verification_attempt] @@ -9,11 +9,6 @@ diff remote[auth] local[auth] +enabled = false uri = "pg-functions://postgres/public/verifyMFA" secrets = "" - [hook.password_verification_attempt] --enabled = true -+enabled = false - uri = "http://example.com" - secrets = "test-secret" [hook.custom_access_token] -enabled = true +enabled = false diff --git a/pkg/config/testdata/TestHookDiff/local_enabled_remote_disabled.diff b/pkg/config/testdata/TestHookDiff/local_enabled_remote_disabled.diff index c5b8878d9..e5f26740e 100644 --- a/pkg/config/testdata/TestHookDiff/local_enabled_remote_disabled.diff +++ b/pkg/config/testdata/TestHookDiff/local_enabled_remote_disabled.diff @@ -1,19 +1,13 @@ diff remote[auth] local[auth] --- remote[auth] +++ local[auth] -@@ -11,25 +11,25 @@ +@@ -11,21 +11,21 @@ [hook] [hook.mfa_verification_attempt] -enabled = false +enabled = true uri = "pg-functions://postgres/public/verifyMFA" - secrets = "hash:" - [hook.password_verification_attempt] --enabled = false --uri = "" -+enabled = true -+uri = "pg-functions://postgres/public/verifyPassword" secrets = "hash:" [hook.custom_access_token] -enabled = false diff --git a/pkg/config/testdata/TestMfaDiff/local_enabled_and_disabled.diff b/pkg/config/testdata/TestMfaDiff/local_enabled_and_disabled.diff index 866ce8fae..e5fa7c476 100644 --- a/pkg/config/testdata/TestMfaDiff/local_enabled_and_disabled.diff +++ b/pkg/config/testdata/TestMfaDiff/local_enabled_and_disabled.diff @@ -1,8 +1,8 @@ diff remote[auth] local[auth] --- remote[auth] +++ local[auth] -@@ -32,16 +32,16 @@ - secrets = "" +@@ -12,16 +12,16 @@ + [hook] [mfa] -max_enrolled_factors = 10 diff --git a/pkg/config/testdata/TestSmsDiff/enable_sign_up_without_provider.diff b/pkg/config/testdata/TestSmsDiff/enable_sign_up_without_provider.diff index 637a0206e..a7c312c91 100644 --- a/pkg/config/testdata/TestSmsDiff/enable_sign_up_without_provider.diff +++ b/pkg/config/testdata/TestSmsDiff/enable_sign_up_without_provider.diff @@ -1,7 +1,7 @@ diff remote[auth] local[auth] --- remote[auth] +++ local[auth] -@@ -60,7 +60,7 @@ +@@ -40,7 +40,7 @@ otp_expiry = 0 [sms] diff --git a/pkg/config/testdata/TestSmsDiff/local_disabled_remote_enabled.diff b/pkg/config/testdata/TestSmsDiff/local_disabled_remote_enabled.diff index 4348c80ba..1dd938cd7 100644 --- a/pkg/config/testdata/TestSmsDiff/local_disabled_remote_enabled.diff +++ b/pkg/config/testdata/TestSmsDiff/local_disabled_remote_enabled.diff @@ -1,7 +1,7 @@ diff remote[auth] local[auth] --- remote[auth] +++ local[auth] -@@ -60,12 +60,12 @@ +@@ -40,12 +40,12 @@ otp_expiry = 0 [sms] @@ -19,7 +19,7 @@ diff remote[auth] local[auth] account_sid = "" message_service_sid = "" auth_token = "" -@@ -88,8 +88,6 @@ +@@ -68,8 +68,6 @@ api_key = "" api_secret = "" [sms.test_otp] diff --git a/pkg/config/testdata/TestSmsDiff/local_enabled_remote_disabled.diff b/pkg/config/testdata/TestSmsDiff/local_enabled_remote_disabled.diff index e29c287ed..4418013bf 100644 --- a/pkg/config/testdata/TestSmsDiff/local_enabled_remote_disabled.diff +++ b/pkg/config/testdata/TestSmsDiff/local_enabled_remote_disabled.diff @@ -1,7 +1,7 @@ diff remote[auth] local[auth] --- remote[auth] +++ local[auth] -@@ -60,12 +60,12 @@ +@@ -40,12 +40,12 @@ otp_expiry = 0 [sms] @@ -19,7 +19,7 @@ diff remote[auth] local[auth] account_sid = "" message_service_sid = "" auth_token = "" -@@ -75,9 +75,9 @@ +@@ -55,9 +55,9 @@ message_service_sid = "" auth_token = "" [sms.messagebird] @@ -32,7 +32,7 @@ diff remote[auth] local[auth] [sms.textlocal] enabled = false sender = "" -@@ -88,6 +88,7 @@ +@@ -68,6 +68,7 @@ api_key = "" api_secret = "" [sms.test_otp]