summaryrefslogtreecommitdiff
path: root/internal/configuration/helpers_test.go
diff options
context:
space:
mode:
authorJames Elliott <james-d-elliott@users.noreply.github.com>2023-10-18 05:39:11 +1100
committerGitHub <noreply@github.com>2023-10-18 04:39:11 +1000
commit5446efb48a6e031080dbd22b418f023aa8efd6e5 (patch)
tree900afb1b2856ef14c87d088fe33d8a1a8b35f56b /internal/configuration/helpers_test.go
parent8ab5126818ac6b71c900516bf86c5655ea690cd8 (diff)
fix(configuration): deprecated secrets not mapped (#6150)
This fixes an issue where a deprecated configuration options when used as a secret are not mapped like the other configuration sources are. It should be noted no previous secret key has been deprecated so this fixes an issue that had no practical replication, however it fixes a future issue preemptively. Signed-off-by: James Elliott <james-d-elliott@users.noreply.github.com>
Diffstat (limited to 'internal/configuration/helpers_test.go')
-rw-r--r--internal/configuration/helpers_test.go28
1 files changed, 22 insertions, 6 deletions
diff --git a/internal/configuration/helpers_test.go b/internal/configuration/helpers_test.go
index cc8cd1180..081d2b3c0 100644
--- a/internal/configuration/helpers_test.go
+++ b/internal/configuration/helpers_test.go
@@ -4,6 +4,8 @@ import (
"testing"
"github.com/stretchr/testify/assert"
+
+ "github.com/authelia/authelia/v4/internal/configuration/schema"
)
func TestIsSecretKey(t *testing.T) {
@@ -28,7 +30,7 @@ func TestGetEnvConfigMaps(t *testing.T) {
"mysecret.user_password",
}
- keys, ignoredKeys := getEnvConfigMap(input, DefaultEnvPrefix, DefaultEnvDelimiter)
+ keys, ignoredKeys := getEnvConfigMap(input, DefaultEnvPrefix, DefaultEnvDelimiter, deprecations)
key, ok = keys[DefaultEnvPrefix+"MY_NON_SECRET_CONFIG_ITEM"]
assert.True(t, ok)
@@ -52,7 +54,7 @@ func TestGetEnvConfigMaps(t *testing.T) {
assert.Contains(t, ignoredKeys, DefaultEnvPrefix+"MYSECRET_USER_PASSWORD_FILE")
}
-func TestGetSecretConfigMap(t *testing.T) {
+func TestGetSecretConfigMapMockInput(t *testing.T) {
var (
key string
ok bool
@@ -65,7 +67,7 @@ func TestGetSecretConfigMap(t *testing.T) {
"mysecret.user_password",
}
- keys := getSecretConfigMap(input, DefaultEnvPrefix, DefaultEnvDelimiter)
+ keys := getSecretConfigMap(input, DefaultEnvPrefix, DefaultEnvDelimiter, deprecations)
key, ok = keys[DefaultEnvPrefix+"MY_NON_SECRET_CONFIG_ITEM_FILE"]
assert.False(t, ok)
@@ -73,13 +75,27 @@ func TestGetSecretConfigMap(t *testing.T) {
key, ok = keys[DefaultEnvPrefix+"MYOTHER_CONFIGKEY_FILE"]
assert.True(t, ok)
- assert.Equal(t, key, "myother.configkey")
+ assert.Equal(t, "myother.configkey", key)
key, ok = keys[DefaultEnvPrefix+"MYSECRET_PASSWORD_FILE"]
assert.True(t, ok)
- assert.Equal(t, key, "mysecret.password")
+ assert.Equal(t, "mysecret.password", key)
key, ok = keys[DefaultEnvPrefix+"MYSECRET_USER_PASSWORD_FILE"]
assert.True(t, ok)
- assert.Equal(t, key, "mysecret.user_password")
+ assert.Equal(t, "mysecret.user_password", key)
+}
+
+func TestGetSecretConfigMap(t *testing.T) {
+ keys := getSecretConfigMap(schema.Keys, DefaultEnvPrefix, DefaultEnvDelimiter, deprecations)
+
+ var (
+ key string
+ ok bool
+ )
+
+ key, ok = keys[DefaultEnvPrefix+"JWT_SECRET_FILE"]
+
+ assert.True(t, ok)
+ assert.Equal(t, "jwt_secret", key)
}