@@ -22,25 +22,25 @@ func (m *mockMultiKeyProvider) ReadSecret(_ context.Context, path string) (map[s
2222func TestCollectMappedSecrets (t * testing.T ) {
2323 mock := & mockMultiKeyProvider {
2424 secrets : map [string ]map [string ]string {
25- "shared/pgsql " : {
26- "PRIMARY_MEDIA_PGSQL_USER " : "dbuser" ,
27- "PRIMARY_MEDIA_PGSQL_PASSWORD " : "dbpass" ,
25+ "shared/database " : {
26+ "DB_USER " : "dbuser" ,
27+ "DB_PASSWORD " : "dbpass" ,
2828 },
29- "shared/akamai " : {
30- "AKAMAI_TOKEN " : "tok123" ,
31- "AKAMAI_HEADER " : "hdr456" ,
29+ "shared/cdn " : {
30+ "CDN_TOKEN " : "tok123" ,
31+ "CDN_HEADER " : "hdr456" ,
3232 },
33- "ccmcms " : {
34- "OPENAI_API_KEY " : "sk-abc" ,
33+ "myapp " : {
34+ "API_SECRET_KEY " : "sk-abc" ,
3535 },
3636 },
3737 }
3838
3939 mapping := map [string ]SecretMapping {
40- "PRIMARY_MEDIA_PGSQL_USER " : {Path : "shared/pgsql " , Key : "PRIMARY_MEDIA_PGSQL_USER " },
41- "PRIMARY_MEDIA_PGSQL_PASSWORD " : {Path : "shared/pgsql " , Key : "PRIMARY_MEDIA_PGSQL_PASSWORD " },
42- "AKAMAI_TOKEN " : {Path : "shared/akamai " , Key : "AKAMAI_TOKEN " },
43- "OPENAI_APIKEY " : {Path : "ccmcms " , Key : "OPENAI_API_KEY " }, // env var differs from vault key
40+ "DB_USER " : {Path : "shared/database " , Key : "DB_USER " },
41+ "DB_PASSWORD " : {Path : "shared/database " , Key : "DB_PASSWORD " },
42+ "CDN_TOKEN " : {Path : "shared/cdn " , Key : "CDN_TOKEN " },
43+ "API_KEY " : {Path : "myapp " , Key : "API_SECRET_KEY " }, // env var differs from vault key
4444 }
4545
4646 records , err := CollectMappedSecrets (context .Background (), mock , mapping )
@@ -49,10 +49,10 @@ func TestCollectMappedSecrets(t *testing.T) {
4949 }
5050
5151 expected := map [string ]string {
52- "PRIMARY_MEDIA_PGSQL_USER " : "dbuser" ,
53- "PRIMARY_MEDIA_PGSQL_PASSWORD " : "dbpass" ,
54- "AKAMAI_TOKEN" : "tok123" ,
55- "OPENAI_APIKEY" : "sk-abc" ,
52+ "DB_USER " : "dbuser" ,
53+ "DB_PASSWORD " : "dbpass" ,
54+ "CDN_TOKEN" : "tok123" ,
55+ "API_KEY" : "sk-abc" ,
5656 }
5757
5858 if len (records ) != len (expected ) {
@@ -74,14 +74,14 @@ func TestCollectMappedSecrets(t *testing.T) {
7474func TestCollectMappedSecrets_MissingKey (t * testing.T ) {
7575 mock := & mockMultiKeyProvider {
7676 secrets : map [string ]map [string ]string {
77- "shared/akamai " : {
78- "AKAMAI_TOKEN " : "tok123" ,
77+ "shared/cdn " : {
78+ "CDN_TOKEN " : "tok123" ,
7979 },
8080 },
8181 }
8282
8383 mapping := map [string ]SecretMapping {
84- "MISSING_VAR" : {Path : "shared/akamai " , Key : "NONEXISTENT_KEY" },
84+ "MISSING_VAR" : {Path : "shared/cdn " , Key : "NONEXISTENT_KEY" },
8585 }
8686
8787 _ , err := CollectMappedSecrets (context .Background (), mock , mapping )
@@ -123,7 +123,7 @@ func TestCollectMappedSecrets_DeduplicatesPaths(t *testing.T) {
123123 callCount := 0
124124 mock := & countingMultiKeyProvider {
125125 secrets : map [string ]map [string ]string {
126- "shared/pgsql " : {
126+ "shared/database " : {
127127 "USER" : "u" ,
128128 "PASS" : "p" ,
129129 },
@@ -132,8 +132,8 @@ func TestCollectMappedSecrets_DeduplicatesPaths(t *testing.T) {
132132 }
133133
134134 mapping := map [string ]SecretMapping {
135- "DB_USER" : {Path : "shared/pgsql " , Key : "USER" },
136- "DB_PASS" : {Path : "shared/pgsql " , Key : "PASS" },
135+ "DB_USER" : {Path : "shared/database " , Key : "USER" },
136+ "DB_PASS" : {Path : "shared/database " , Key : "PASS" },
137137 }
138138
139139 _ , err := CollectMappedSecrets (context .Background (), mock , mapping )
0 commit comments