@@ -25,8 +25,20 @@ describe('determineAllowCrossAccountAssetPublishing', () => {
25
25
} ) ;
26
26
} ) ;
27
27
28
- AWSMock . mock ( 'CloudFormation' , 'describeStackResources' , ( _params : any , callback : Function ) => {
29
- callback ( null , { StackResources : [ ] } ) ;
28
+ const result = await determineAllowCrossAccountAssetPublishing ( mockSDK ) ;
29
+ expect ( result ) . toBe ( true ) ;
30
+ } ) ;
31
+
32
+ it . each ( [ '' , '-' , '*' , '---' ] ) ( 'should return true when the bucket output does not look like a real bucket' , async ( notABucketName ) => {
33
+ AWSMock . mock ( 'CloudFormation' , 'describeStacks' , ( _params : any , callback : Function ) => {
34
+ callback ( null , {
35
+ Stacks : [ {
36
+ Outputs : [
37
+ { OutputKey : 'BootstrapVersion' , OutputValue : '1' } ,
38
+ { OutputKey : 'BucketName' , OutputValue : notABucketName } ,
39
+ ] ,
40
+ } ] ,
41
+ } ) ;
30
42
} ) ;
31
43
32
44
const result = await determineAllowCrossAccountAssetPublishing ( mockSDK ) ;
@@ -37,13 +49,21 @@ describe('determineAllowCrossAccountAssetPublishing', () => {
37
49
AWSMock . mock ( 'CloudFormation' , 'describeStacks' , ( _params : any , callback : Function ) => {
38
50
callback ( null , {
39
51
Stacks : [ {
40
- Outputs : [ { OutputKey : 'BootstrapVersion' , OutputValue : '21' } ] ,
52
+ Outputs : [
53
+ { OutputKey : 'BootstrapVersion' , OutputValue : '21' } ,
54
+ { OutputKey : 'BucketName' , OutputValue : 'some-bucket' } ,
55
+ ] ,
41
56
} ] ,
42
57
} ) ;
43
58
} ) ;
44
59
45
- AWSMock . mock ( 'CloudFormation' , 'describeStackResources' , ( _params : any , callback : Function ) => {
46
- callback ( null , { StackResources : [ { ResourceType : 'AWS::S3::Bucket' , PhysicalResourceId : 'some-bucket' } ] } ) ;
60
+ const result = await determineAllowCrossAccountAssetPublishing ( mockSDK ) ;
61
+ expect ( result ) . toBe ( true ) ;
62
+ } ) ;
63
+
64
+ it ( 'should return true if looking up the bootstrap stack fails' , async ( ) => {
65
+ AWSMock . mock ( 'CloudFormation' , 'describeStacks' , ( _params : any , callback : Function ) => {
66
+ callback ( new Error ( 'Could not read bootstrap stack' ) ) ;
47
67
} ) ;
48
68
49
69
const result = await determineAllowCrossAccountAssetPublishing ( mockSDK ) ;
@@ -63,15 +83,14 @@ describe('determineAllowCrossAccountAssetPublishing', () => {
63
83
AWSMock . mock ( 'CloudFormation' , 'describeStacks' , ( _params : any , callback : Function ) => {
64
84
callback ( null , {
65
85
Stacks : [ {
66
- Outputs : [ { OutputKey : 'BootstrapVersion' , OutputValue : '20' } ] ,
86
+ Outputs : [
87
+ { OutputKey : 'BootstrapVersion' , OutputValue : '20' } ,
88
+ { OutputKey : 'BucketName' , OutputValue : 'some-bucket' } ,
89
+ ] ,
67
90
} ] ,
68
91
} ) ;
69
92
} ) ;
70
93
71
- AWSMock . mock ( 'CloudFormation' , 'describeStackResources' , ( _params : any , callback : Function ) => {
72
- callback ( null , { StackResources : [ { ResourceType : 'AWS::S3::Bucket' , PhysicalResourceId : 'some-bucket' } ] } ) ;
73
- } ) ;
74
-
75
94
const result = await determineAllowCrossAccountAssetPublishing ( mockSDK ) ;
76
95
expect ( result ) . toBe ( false ) ;
77
96
} ) ;
@@ -94,15 +113,14 @@ describe('getBootstrapStackInfo', () => {
94
113
AWSMock . mock ( 'CloudFormation' , 'describeStacks' , ( _params : any , callback : Function ) => {
95
114
callback ( null , {
96
115
Stacks : [ {
97
- Outputs : [ { OutputKey : 'BootstrapVersion' , OutputValue : '21' } ] ,
116
+ Outputs : [
117
+ { OutputKey : 'BootstrapVersion' , OutputValue : '21' } ,
118
+ { OutputKey : 'BucketName' , OutputValue : 'some-bucket' } ,
119
+ ] ,
98
120
} ] ,
99
121
} ) ;
100
122
} ) ;
101
123
102
- AWSMock . mock ( 'CloudFormation' , 'describeStackResources' , ( _params : any , callback : Function ) => {
103
- callback ( null , { StackResources : [ { ResourceType : 'AWS::S3::Bucket' , PhysicalResourceId : 'some-bucket' } ] } ) ;
104
- } ) ;
105
-
106
124
const result = await getBootstrapStackInfo ( mockSDK , 'CDKToolkit' ) ;
107
125
expect ( result ) . toEqual ( {
108
126
hasStagingBucket : true ,
0 commit comments