@@ -34,12 +34,19 @@ describe('kv-backend', () => {
34
34
key : 'mocked-key' ,
35
35
name : 'mocked-name' ,
36
36
property : 'oops'
37
- } ]
37
+ } ] ,
38
+ specOptions : { }
38
39
} )
39
40
expect . fail ( 'Should not reach' )
40
41
} catch ( err ) {
41
42
expect ( err ) . to . be . an ( 'error' )
42
43
}
44
+ expect ( kvBackend . _get . calledOnce ) . to . equal ( true )
45
+ expect ( kvBackend . _get . getCall ( 0 ) . args [ 0 ] ) . to . deep . equal ( {
46
+ key : 'mocked-key' ,
47
+ keyOptions : { } ,
48
+ specOptions : { }
49
+ } )
43
50
} )
44
51
45
52
it ( 'handles secrets values that are objects' , async ( ) => {
@@ -77,19 +84,22 @@ describe('kv-backend', () => {
77
84
} , {
78
85
key : 'fakePropertyKey2' ,
79
86
name : 'fakePropertyName2'
80
- } ]
87
+ } ] ,
88
+ specOptions : {
89
+ passMeAlong : true
90
+ }
81
91
} )
82
92
83
- expect ( loggerMock . info . calledWith ( 'fetching secret property fakePropertyName1 with role: no role set' ) ) . to . equal ( true )
84
- expect ( loggerMock . info . calledWith ( 'fetching secret property fakePropertyName2 with role: no role set' ) ) . to . equal ( true )
85
- expect ( kvBackend . _get . calledWith ( {
86
- secretKey : 'fakePropertyKey1' ,
87
- roleArn : undefined
88
- } ) ) . to . equal ( true )
89
- expect ( kvBackend . _get . calledWith ( {
90
- secretKey : 'fakePropertyKey2' ,
91
- roleArn : undefined
92
- } ) ) . to . equal ( true )
93
+ expect ( kvBackend . _get . getCall ( 0 ) . args [ 0 ] ) . to . deep . equal ( {
94
+ key : 'fakePropertyKey1' ,
95
+ keyOptions : { } ,
96
+ specOptions : { passMeAlong : true }
97
+ } )
98
+ expect ( kvBackend . _get . getCall ( 1 ) . args [ 0 ] ) . to . deep . equal ( {
99
+ key : 'fakePropertyKey2' ,
100
+ keyOptions : { } ,
101
+ specOptions : { passMeAlong : true }
102
+ } )
93
103
expect ( secretPropertyValues ) . deep . equals ( [ { fakePropertyName1 : 'fakePropertyValue1' } , { fakePropertyName2 : 'fakePropertyValue2' } ] )
94
104
} )
95
105
@@ -105,19 +115,19 @@ describe('kv-backend', () => {
105
115
key : 'fakePropertyKey2' ,
106
116
name : 'fakePropertyName2'
107
117
} ] ,
108
- roleArn : 'secretDescriptiorRole'
118
+ specOptions : { roleArn : 'secretDescriptiorRole' }
109
119
} )
110
120
111
- expect ( loggerMock . info . calledWith ( 'fetching secret property fakePropertyName1 with role: secretDescriptiorRole' ) ) . to . equal ( true )
112
- expect ( loggerMock . info . calledWith ( 'fetching secret property fakePropertyName2 with role: secretDescriptiorRole' ) ) . to . equal ( true )
113
- expect ( kvBackend . _get . calledWith ( {
114
- secretKey : 'fakePropertyKey1' ,
115
- roleArn : 'secretDescriptiorRole'
116
- } ) ) . to . equal ( true )
117
- expect ( kvBackend . _get . calledWith ( {
118
- secretKey : 'fakePropertyKey2' ,
119
- roleArn : 'secretDescriptiorRole'
120
- } ) ) . to . equal ( true )
121
+ expect ( kvBackend . _get . getCall ( 0 ) . args [ 0 ] ) . to . deep . equal ( {
122
+ key : 'fakePropertyKey1' ,
123
+ keyOptions : { } ,
124
+ specOptions : { roleArn : 'secretDescriptiorRole' }
125
+ } )
126
+ expect ( kvBackend . _get . getCall ( 1 ) . args [ 0 ] ) . to . deep . equal ( {
127
+ key : 'fakePropertyKey2' ,
128
+ keyOptions : { } ,
129
+ specOptions : { roleArn : 'secretDescriptiorRole' }
130
+ } )
121
131
expect ( secretPropertyValues ) . deep . equals ( [ { fakePropertyName1 : 'fakePropertyValue1' } , { fakePropertyName2 : 'fakePropertyValue2' } ] )
122
132
} )
123
133
} )
@@ -147,33 +157,34 @@ describe('kv-backend', () => {
147
157
kvBackend . _get . onFirstCall ( ) . resolves ( 'fakePropertyValue1' )
148
158
149
159
const dataFromValues = await kvBackend . _fetchDataFromValues ( {
150
- dataFrom : [ 'fakePropertyKey1' ]
160
+ dataFrom : [ 'fakePropertyKey1' ] ,
161
+ specOptions : { passMeAlong : true }
151
162
} )
152
163
153
- expect ( kvBackend . _get . calledWith ( {
154
- secretKey : 'fakePropertyKey1' ,
155
- roleArn : undefined
156
- } ) ) . to . equal ( true )
164
+ expect ( kvBackend . _get . getCall ( 0 ) . args [ 0 ] ) . to . deep . equal ( {
165
+ key : 'fakePropertyKey1' ,
166
+ specOptions : { passMeAlong : true }
167
+ } )
157
168
expect ( dataFromValues ) . deep . equals ( [ undefined ] )
158
169
} )
159
170
160
- it ( 'fetches secret property values using the specified role ' , async ( ) => {
171
+ it ( 'fetches secret property values using the specified options ' , async ( ) => {
161
172
kvBackend . _get . onFirstCall ( ) . resolves ( '{"fakePropertyName1":"fakePropertyValue1"}' )
162
173
kvBackend . _get . onSecondCall ( ) . resolves ( '{"fakePropertyName2":"fakePropertyValue2"}' )
163
174
164
175
const dataFromValues = await kvBackend . _fetchDataFromValues ( {
165
176
dataFrom : [ 'fakePropertyKey1' , 'fakePropertyKey2' ] ,
166
- roleArn : 'secretDescriptiorRole'
177
+ specOptions : { roleArn : 'secretDescriptiorRole' }
167
178
} )
168
179
169
- expect ( kvBackend . _get . calledWith ( {
170
- secretKey : 'fakePropertyKey1' ,
171
- roleArn : 'secretDescriptiorRole'
172
- } ) ) . to . equal ( true )
173
- expect ( kvBackend . _get . calledWith ( {
174
- secretKey : 'fakePropertyKey2' ,
175
- roleArn : 'secretDescriptiorRole'
176
- } ) ) . to . equal ( true )
180
+ expect ( kvBackend . _get . getCall ( 0 ) . args [ 0 ] ) . to . deep . equal ( {
181
+ key : 'fakePropertyKey1' ,
182
+ specOptions : { roleArn : 'secretDescriptiorRole' }
183
+ } )
184
+ expect ( kvBackend . _get . getCall ( 1 ) . args [ 0 ] ) . to . deep . equal ( {
185
+ key : 'fakePropertyKey2' ,
186
+ specOptions : { roleArn : 'secretDescriptiorRole' }
187
+ } )
177
188
expect ( dataFromValues ) . deep . equals ( [ { fakePropertyName1 : 'fakePropertyValue1' } , { fakePropertyName2 : 'fakePropertyValue2' } ] )
178
189
} )
179
190
} )
@@ -183,7 +194,7 @@ describe('kv-backend', () => {
183
194
let error
184
195
185
196
try {
186
- kvBackend . _get ( )
197
+ kvBackend . _get ( { } )
187
198
} catch ( err ) {
188
199
error = err
189
200
}
@@ -267,12 +278,12 @@ describe('kv-backend', () => {
267
278
key : 'fakePropertyKey2' ,
268
279
name : 'fakePropertyName2'
269
280
} ] ,
270
- roleArn : 'my-role'
281
+ specOptions : { roleArn : 'my-role' }
271
282
} ) ) . to . equal ( true )
272
283
273
284
expect ( kvBackend . _fetchDataFromValues . calledWith ( {
274
285
dataFrom : [ ] ,
275
- roleArn : 'my-role'
286
+ specOptions : { roleArn : 'my-role' }
276
287
} ) ) . to . equal ( true )
277
288
} )
278
289
@@ -290,24 +301,32 @@ describe('kv-backend', () => {
290
301
] ,
291
302
dataFrom : [
292
303
'fakeDataFromKey1'
293
- ]
304
+ ] ,
305
+ roleArn : 'this-should-be-passed-along' ,
306
+ magicSetting : 'this as well'
294
307
}
295
308
} )
296
309
297
- expect ( kvBackend . _fetchDataValues . calledWith ( {
310
+ expect ( kvBackend . _fetchDataValues . getCall ( 0 ) . args [ 0 ] ) . to . deep . equal ( {
298
311
data : [ {
299
312
key : 'fakePropertyKey1' ,
300
313
name : 'fakePropertyName1'
301
314
} , {
302
315
key : 'fakePropertyKey2' ,
303
316
name : 'fakePropertyName2'
304
317
} ] ,
305
- roleArn : undefined
306
- } ) ) . to . equal ( true )
318
+ specOptions : {
319
+ roleArn : 'this-should-be-passed-along' ,
320
+ magicSetting : 'this as well'
321
+ }
322
+ } )
307
323
308
324
expect ( kvBackend . _fetchDataFromValues . calledWith ( {
309
325
dataFrom : [ 'fakeDataFromKey1' ] ,
310
- roleArn : undefined
326
+ specOptions : {
327
+ roleArn : 'this-should-be-passed-along' ,
328
+ magicSetting : 'this as well'
329
+ }
311
330
} ) ) . to . equal ( true )
312
331
} )
313
332
@@ -321,15 +340,15 @@ describe('kv-backend', () => {
321
340
}
322
341
} )
323
342
324
- expect ( kvBackend . _fetchDataValues . calledWith ( {
343
+ expect ( kvBackend . _fetchDataValues . getCall ( 0 ) . args [ 0 ] ) . to . deep . equal ( {
325
344
data : [ ] ,
326
- roleArn : undefined
327
- } ) ) . to . equal ( true )
345
+ specOptions : { }
346
+ } )
328
347
329
- expect ( kvBackend . _fetchDataFromValues . calledWith ( {
348
+ expect ( kvBackend . _fetchDataFromValues . getCall ( 0 ) . args [ 0 ] ) . to . deep . equal ( {
330
349
dataFrom : [ 'fakeDataFromKey1' , 'fakeDataFromKey2' ] ,
331
- roleArn : undefined
332
- } ) ) . to . equal ( true )
350
+ specOptions : { }
351
+ } )
333
352
} )
334
353
} )
335
354
} )
0 commit comments