@@ -124,6 +124,70 @@ describe('secretsmanager', async () => {
124
124
expect ( secret . body . type ) . to . equal ( 'kubernetes.io/tls' )
125
125
} )
126
126
127
+ it ( 'should pull existing secret from secretsmanager in the correct region' , async ( ) => {
128
+ const smEU = awsConfig . secretsManagerFactory ( {
129
+ region : 'eu-west-1'
130
+ } )
131
+ const createSecret = util . promisify ( smEU . createSecret ) . bind ( smEU )
132
+ const putSecretValue = util . promisify ( smEU . putSecretValue ) . bind ( smEU )
133
+
134
+ let result = await createSecret ( {
135
+ Name : `e2e/${ uuid } /x-region-credentials` ,
136
+ SecretString : '{"username":"foo","password":"bar"}'
137
+ } ) . catch ( err => {
138
+ expect ( err ) . to . equal ( null )
139
+ } )
140
+
141
+ result = await kubeClient
142
+ . apis [ customResourceManifest . spec . group ]
143
+ . v1 . namespaces ( 'default' ) [ customResourceManifest . spec . names . plural ]
144
+ . post ( {
145
+ body : {
146
+ apiVersion : 'kubernetes-client.io/v1' ,
147
+ kind : 'ExternalSecret' ,
148
+ metadata : {
149
+ name : `e2e-secretmanager-x-region-${ uuid } `
150
+ } ,
151
+ spec : {
152
+ backendType : 'secretsManager' ,
153
+ region : 'eu-west-1' ,
154
+ data : [
155
+ {
156
+ key : `e2e/${ uuid } /x-region-credentials` ,
157
+ property : 'password' ,
158
+ name : 'password'
159
+ } ,
160
+ {
161
+ key : `e2e/${ uuid } /x-region-credentials` ,
162
+ property : 'username' ,
163
+ name : 'username'
164
+ }
165
+ ]
166
+ }
167
+ }
168
+ } )
169
+
170
+ expect ( result ) . to . not . equal ( undefined )
171
+ expect ( result . statusCode ) . to . equal ( 201 )
172
+
173
+ let secret = await waitForSecret ( 'default' , `e2e-secretmanager-x-region-${ uuid } ` )
174
+ expect ( secret ) . to . not . equal ( undefined )
175
+ expect ( secret . body . data . username ) . to . equal ( 'Zm9v' )
176
+ expect ( secret . body . data . password ) . to . equal ( 'YmFy' )
177
+
178
+ // update the secret value
179
+ result = await putSecretValue ( {
180
+ SecretId : `e2e/${ uuid } /x-region-credentials` ,
181
+ SecretString : '{"username":"your mom","password":"1234"}'
182
+ } ) . catch ( err => {
183
+ expect ( err ) . to . equal ( null )
184
+ } )
185
+ await delay ( 2000 )
186
+ secret = await waitForSecret ( 'default' , `e2e-secretmanager-x-region-${ uuid } ` )
187
+ expect ( secret . body . data . username ) . to . equal ( 'eW91ciBtb20=' )
188
+ expect ( secret . body . data . password ) . to . equal ( 'MTIzNA==' )
189
+ } )
190
+
127
191
describe ( 'permitted annotation' , async ( ) => {
128
192
beforeEach ( async ( ) => {
129
193
await kubeClient . api . v1 . namespaces ( 'default' ) . patch ( {
0 commit comments