ac-awssecrets 2.5.7 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/test/config.js CHANGED
@@ -1,192 +1,96 @@
1
+ // Test fixture data - only used in tests, never imported by production code
2
+
1
3
  const config = {
2
- configVar1: {
3
- c1: false
4
- },
4
+ environment: 'test',
5
+ configVar1: { c1: true },
5
6
  configVar2: {
6
- servers: [
7
- { server: 'cacheRead', host: 'localhost', port: 6379 },
8
- ]
9
- },
10
- configVar4: {
11
- api: {
12
- port: 90
13
- }
14
- },
15
- configVar5: {
16
- path: {
17
- cookie: false
18
- }
7
+ servers: [{ server: 'main', port: 3000 }]
19
8
  },
9
+ configVar5: { path: {} },
10
+ configVar7: { level: 'info' },
20
11
  aws: {
21
12
  account: '123',
22
13
  accessKeys: []
23
- },
24
- configVar7: {
25
- level: 'info'
26
- },
27
- db: []
14
+ }
28
15
  }
29
16
 
17
+ // Simulates SSM Parameter Store entries
18
+ const parameterStore = [
19
+ { name: '/test/configVar1', value: JSON.stringify({ c1: true, c2: 'value2', c3: 42 }) },
20
+ { name: '/test/configVar2', value: JSON.stringify({ port: 5432 }) },
21
+ { name: '/test/configVar4/api/url', value: 'https://api.admiralcloud.com' },
22
+ { name: '/test/configVar5/path/cookie', value: 'true' },
23
+ { name: '/test/configVar6/prop1', value: '123' },
24
+ { name: '/test/configVar6/prop2', value: 'abc' },
25
+ { name: '/test/db/1', value: JSON.stringify({ url: 'https://db1.admiralcloud.com' }) },
26
+ { name: '/test/db/2', value: JSON.stringify({ url: 'https://db2.admiralcloud.com' }) },
27
+ // Merged aws config
28
+ { name: '/test/aws', value: JSON.stringify({ account: '456', accessKeys: [] }) },
29
+ ]
30
30
 
31
- // AWS PARAMETER STORE
31
+ // Parameters to load via SSM
32
32
  const secretParameters = [
33
33
  { name: 'configVar1', json: true },
34
- { name: 'configVar2', json: true, array: true, path: 'configVar2.servers', property: { server: 'cacheRead' } },
35
- { name: 'configVar4/api', json: true },
36
- { name: 'configVar5.path', json: true },
37
- { name: 'configVar6', json: true },
34
+ { name: 'configVar2', json: true, path: 'configVar2.servers.0', merge: true },
35
+ { name: 'configVar4/api/url', path: 'configVar4.api.url' },
36
+ { name: 'configVar5/path/cookie', path: 'configVar5.path.cookie' },
37
+ { name: 'configVar6/prop1', path: 'configVar6.prop1' },
38
+ { name: 'configVar6/prop2', path: 'configVar6.prop2' },
39
+ { name: 'configVar7/nonExisting', path: 'configVar7.level' },
38
40
  { name: 'aws', json: true, merge: true },
39
- { name: 'db/*', json: true, merge: true, path: 'db', array: true }
41
+ { name: 'db/*', path: 'db', array: true, json: true },
40
42
  ]
41
43
 
42
- const parameterStore = [
43
- { name: '/test/configVar1', value: JSON.stringify({ c1: true, c2: 123, c3: 'abc' }) },
44
+ // Simulates Secrets Manager entries
45
+ const availableSecrets = [
44
46
  {
45
- name: '/test/configVar2',
46
- value: JSON.stringify({
47
- port: 6360,
48
- host: 'myRedisHost'
49
- })
47
+ name: 'configVar1',
48
+ value: { c2: 'secretValue2', c3: 99 }
50
49
  },
51
50
  {
52
- name: '/test/configVar3',
53
- },
54
- {
55
- name: '/test/configVar4/api',
56
- value: JSON.stringify({ "url":"https://api.admiralcloud.com" })
51
+ name: 'configVar2',
52
+ value: { port: 9999 }
57
53
  },
58
54
  {
59
- name: '/test/errorVar1',
60
- value: 'JSON:abc',
55
+ name: 'configVar4',
56
+ value: { api: 'JSON:{"url":"https://api.admiralcloud.com"}' }
61
57
  },
62
58
  {
63
- name: '/test/configVar5.path',
64
- value: JSON.stringify({ cookie: true })
59
+ name: 'configVar5',
60
+ value: { cookie: 'true' }
65
61
  },
66
62
  {
67
- name: '/test/configVar6',
68
- value: JSON.stringify({
69
- prop1: 123,
70
- prop2: 'abc'
71
- })
63
+ name: 'configVar6',
64
+ value: { prop1: 123, prop2: 'abc' }
72
65
  },
73
66
  {
74
- name: '/test/aws',
75
- value: JSON.stringify({
76
- account: '456'
77
- })
67
+ name: 'awsAccessKey1',
68
+ value: { accessKeyId: 'awsKey1', secretAccessKey: 'secret1' }
78
69
  },
79
70
  {
80
- name: '/test/db/1',
81
- value: JSON.stringify({ url: 'https://db1.admiralcloud.com' }),
71
+ name: 'awsAccessKey2',
72
+ value: { accessKeyId: 'awsKey2', secretAccessKey: 'secret2' }
82
73
  },
83
74
  {
84
- name: '/test/db/2',
85
- value: JSON.stringify({ url: 'https://db2.admiralcloud.com' }),
75
+ name: 'awsAccessKeys',
76
+ value: { values: JSON.stringify(['awsAccessKey1', 'awsAccessKey2']) }
86
77
  },
78
+ {
79
+ name: 'invalidJSON',
80
+ value: 'not-valid-json'
81
+ }
87
82
  ]
88
83
 
89
-
90
- // AWS SECRETS
91
84
  const secrets = [
92
- { key: 'configVar1', name: 'simple' },
93
- { key: 'configVar2', name: 'server', servers: true, serverName: 'cacheRead' },
94
- { key: 'configVar4', name: 'json' },
95
- { key: 'configVar5.path', name: 'path' },
96
- { key: 'configVar6', name: 'notExistingLocally' },
97
- { key: 'configVar7', name: 'notExistingKey' },
85
+ { name: 'configVar1', key: 'configVar1' },
86
+ { name: 'configVar2', key: 'configVar2', servers: true, serverName: 'main' },
87
+ { name: 'configVar4', key: 'configVar4' },
88
+ { name: 'configVar5', key: 'configVar5' },
89
+ { name: 'configVar6', key: 'configVar6' },
98
90
  ]
99
91
 
100
-
101
-
102
- const availableSecrets = [{
103
- key: 'configVar1',
104
- name: 'simple',
105
- value: {
106
- c1: 'true',
107
- c2: 123,
108
- c3: 'abc'
109
- },
110
- log: true
111
- }, {
112
- key: 'configVar2',
113
- name: 'server',
114
- value: {
115
- port: 6360,
116
- host: 'myRedisHost'
117
- }
118
- },
119
- {
120
- key: 'configVar3',
121
- name: 'noSecret'
122
- },
123
- {
124
- key: 'configVar4',
125
- name: 'json',
126
- value: {
127
- api: 'JSON:{"url":"https://api.admiralcloud.com"}',
128
- valueHasJSON: true
129
- }
130
- },
131
- {
132
- key: 'errorVar1',
133
- name: 'invalidJSON',
134
- value: {
135
- api: 'JSON:abc',
136
- valueHasJSON: true
137
- }
138
- },
139
- {
140
- key: 'configVar5.path',
141
- name: 'path',
142
- value: {
143
- cookie: true
144
- }
145
- },
146
- {
147
- key: 'configVar6',
148
- name: 'notExistingLocally',
149
- value: {
150
- prop1: 123,
151
- prop2: 'abc'
152
- }
153
- },
154
- {
155
- key: 'aws.accessKeys',
156
- name: 'aws.accessKeyConfigs',
157
- value: {
158
- values: '["aws.key1", "aws.key2"]'
159
- }
160
- },
161
- {
162
- key: 'aws.failedKeys',
163
- name: 'aws.failedKeysConfig',
164
- value: {
165
- values: 123
166
- }
167
- },
168
- {
169
- key: 'aws.key1',
170
- name: 'aws.key1',
171
- value: {
172
- accessKeyId: 'awsKey1',
173
- secretAccessKey: 'awsSecret1'
174
- }
175
- },{
176
- key: 'aws.key2',
177
- name: 'aws.key2',
178
- value: {
179
- accessKeyId: 'awsKey2',
180
- secretAccessKey: 'awsSecret2'
181
- }
182
- }]
183
-
184
92
  const multisecrets = [
185
- { key: 'aws.accessKeys', name: 'aws.accessKeyConfigs' }
186
- ]
187
-
188
- const multisecretsFail = [
189
- { key: 'aws.failedKeys', name: 'aws.failedKeysConfig' }
93
+ { name: 'awsAccessKeys', key: 'aws.accessKeys' }
190
94
  ]
191
95
 
192
96
  module.exports = {
@@ -194,8 +98,6 @@ module.exports = {
194
98
  parameterStore,
195
99
  secretParameters,
196
100
  availableSecrets,
197
- multisecretsFail,
198
101
  secrets,
199
102
  multisecrets
200
- }
201
-
103
+ }