@@ -48,7 +48,7 @@ describe("containers registries configure", () => {
4848 const domain = "123456789012.dkr.ecr.us-west-2.amazonaws.com" ;
4949 await expect (
5050 runWrangler (
51- `containers registries configure ${ domain } --public-credential=test-id --disableSecretsStore `
51+ `containers registries configure ${ domain } --public-credential=test-id --disable-secrets-store `
5252 )
5353 ) . rejects . toThrowErrorMatchingInlineSnapshot (
5454 `[Error: Secrets Store can only be disabled in FedRAMP compliance regions.]`
@@ -61,23 +61,23 @@ describe("containers registries configure", () => {
6161 `containers registries configure ${ domain } --aws-access-key-id=test-access-key-id --secret-store-id=storeid`
6262 )
6363 ) . rejects . toThrowErrorMatchingInlineSnapshot (
64- `[Error: Secrets Store is not supported in FedRAMP compliance regions. You must set --disableSecretsStore .]`
64+ `[Error: Secrets Store is not supported in FedRAMP compliance regions. You must set --disable-secrets-store .]`
6565 ) ;
6666
6767 await expect (
6868 runWrangler (
69- `containers registries configure ${ domain } --aws-access-key-id=test-access-key-id --secret-store-id=storeid --disableSecretsStore `
69+ `containers registries configure ${ domain } --aws-access-key-id=test-access-key-id --secret-store-id=storeid --disable-secrets-store `
7070 )
7171 ) . rejects . toThrowErrorMatchingInlineSnapshot (
72- `[Error: Arguments secret-store-id and disableSecretsStore are mutually exclusive]`
72+ `[Error: Arguments secret-store-id and disable-secrets-store are mutually exclusive]`
7373 ) ;
7474
7575 await expect (
7676 runWrangler (
77- `containers registries configure ${ domain } --aws-access-key-id=test-access-key-id --secret-name=secret-name --disableSecretsStore `
77+ `containers registries configure ${ domain } --aws-access-key-id=test-access-key-id --secret-name=secret-name --disable-secrets-store `
7878 )
7979 ) . rejects . toThrowErrorMatchingInlineSnapshot (
80- `[Error: Arguments secret-name and disableSecretsStore are mutually exclusive]`
80+ `[Error: Arguments secret-name and disable-secrets-store are mutually exclusive]`
8181 ) ;
8282 } ) ;
8383
@@ -123,7 +123,7 @@ describe("containers registries configure", () => {
123123 } ) ;
124124
125125 await runWrangler (
126- `containers registries configure ${ awsEcrDomain } --aws-access-key-id=test-access-key-id --disableSecretsStore `
126+ `containers registries configure ${ awsEcrDomain } --aws-access-key-id=test-access-key-id --disable-secrets-store `
127127 ) ;
128128
129129 expect ( cliStd . stdout ) . toMatchInlineSnapshot ( `
@@ -161,7 +161,7 @@ describe("containers registries configure", () => {
161161 } ) ;
162162
163163 await runWrangler (
164- `containers registries configure ${ awsEcrDomain } --public-credential=test-access-key-id --disableSecretsStore `
164+ `containers registries configure ${ awsEcrDomain } --public-credential=test-access-key-id --disable-secrets-store `
165165 ) ;
166166 } ) ;
167167 } ) ;
@@ -192,6 +192,7 @@ describe("containers registries configure", () => {
192192 modified : "2024-01-01T00:00:00Z" ,
193193 } ,
194194 ] ) ;
195+ mockListSecrets ( storeId , [ ] ) ;
195196 mockCreateSecret ( storeId ) ;
196197 mockPutRegistry ( {
197198 domain : "123456789012.dkr.ecr.us-west-2.amazonaws.com" ,
@@ -235,6 +236,7 @@ describe("containers registries configure", () => {
235236
236237 mockListSecretStores ( [ ] ) ;
237238 mockCreateSecretStore ( newStoreId ) ;
239+ mockListSecrets ( newStoreId , [ ] ) ;
238240 mockCreateSecret ( newStoreId ) ;
239241 mockPutRegistry ( {
240242 domain : awsEcrDomain ,
@@ -275,6 +277,7 @@ describe("containers registries configure", () => {
275277 result : "AWS_Secret_Access_Key" ,
276278 } ) ;
277279
280+ mockListSecrets ( providedStoreId , [ ] ) ;
278281 mockCreateSecret ( providedStoreId ) ;
279282 mockPutRegistry ( {
280283 domain : awsEcrDomain ,
@@ -307,7 +310,7 @@ describe("containers registries configure", () => {
307310 │
308311 │
309312 │
310- │ Container-scoped secret AWS_Secret_Access_Key created in Secrets Store.
313+ │ Container-scoped secret " AWS_Secret_Access_Key" created in Secrets Store.
311314 │
312315 ╰ Registry configuration completed
313316
@@ -336,6 +339,7 @@ describe("containers registries configure", () => {
336339 modified : "2024-01-01T00:00:00Z" ,
337340 } ,
338341 ] ) ;
342+ mockListSecrets ( storeId , [ ] ) ;
339343 mockCreateSecret ( storeId ) ;
340344 mockPutRegistry ( {
341345 domain : awsEcrDomain ,
@@ -353,6 +357,53 @@ describe("containers registries configure", () => {
353357 `containers registries configure ${ awsEcrDomain } --public-credential=test-access-key-id --secret-name=AWS_Secret_Access_Key`
354358 ) ;
355359 } ) ;
360+
361+ it ( "should reuse existing secret with --skip-confirmation" , async ( ) => {
362+ const storeId = "test-store-id-reuse" ;
363+ const secretName = "existing_secret" ;
364+
365+ mockStdIn . send ( "test-secret-value" ) ;
366+ mockListSecretStores ( [
367+ {
368+ id : storeId ,
369+ account_id : "some-account-id" ,
370+ name : "Default" ,
371+ created : "2024-01-01T00:00:00Z" ,
372+ modified : "2024-01-01T00:00:00Z" ,
373+ } ,
374+ ] ) ;
375+ mockListSecrets ( storeId , [
376+ {
377+ id : "existing-secret-id" ,
378+ store_id : storeId ,
379+ name : secretName ,
380+ comment : "" ,
381+ scopes : [ "containers" ] ,
382+ created : "2024-01-01T00:00:00Z" ,
383+ modified : "2024-01-01T00:00:00Z" ,
384+ status : "active" ,
385+ } ,
386+ ] ) ;
387+ mockPutRegistry ( {
388+ domain : awsEcrDomain ,
389+ is_public : false ,
390+ auth : {
391+ public_credential : "test-access-key-id" ,
392+ private_credential : {
393+ store_id : storeId ,
394+ secret_name : secretName ,
395+ } ,
396+ } ,
397+ kind : "ECR" ,
398+ } ) ;
399+
400+ await runWrangler (
401+ `containers registries configure ${ awsEcrDomain } --public-credential=test-access-key-id --secret-name=${ secretName } --skip-confirmation`
402+ ) ;
403+
404+ // Should not contain "created" message since we reused existing secret
405+ expect ( cliStd . stdout ) . not . toContain ( "created in Secrets Store" ) ;
406+ } ) ;
356407 } ) ;
357408 } ) ;
358409} ) ;
0 commit comments