@@ -24,30 +24,22 @@ describe("SsmParametersConstruct", () => {
2424 id : "MockParam1" ,
2525 nameSuffix : "MockParam1" ,
2626 description : "Description for mock parameter 1" ,
27- value : "mock-value-1" ,
28- outputExportSuffix : "MockParam1Parameter" ,
29- outputDescription : "Name of the SSM parameter holding MockParam1"
27+ value : "mock-value-1"
3028 } ,
3129 {
3230 id : "MockParam2" ,
3331 nameSuffix : "MockParam2" ,
3432 description : "Description for mock parameter 2" ,
35- value : "mock-value-2" ,
36- outputExportSuffix : "MockParam2Parameter" ,
37- outputDescription : "Name of the SSM parameter holding MockParam2"
33+ value : "mock-value-2"
3834 } ,
3935 {
4036 id : "MockParam3" ,
4137 nameSuffix : "MockParam3" ,
4238 description : "Description for mock parameter 3" ,
43- value : "mock-value-3" ,
44- outputExportSuffix : "MockParam3Parameter" ,
45- outputDescription : "Name of the SSM parameter holding MockParam3"
39+ value : "mock-value-3"
4640 }
4741 ] ,
48- readPolicyDescription : "Mock policy description" ,
49- readPolicyOutputDescription : "Mock read policy output description" ,
50- readPolicyExportSuffix : "MockGetParametersPolicy"
42+ readPolicyDescription : "Mock policy description"
5143 } )
5244 // Sonarcloud complains that the construct is not used, so we add an assertion to sidestep that.
5345 assert ( params , "SsmParametersConstruct should be created successfully" )
@@ -99,37 +91,10 @@ describe("SsmParametersConstruct", () => {
9991 expect ( statement . Action ) . toEqual ( [ "ssm:GetParameter" , "ssm:GetParameters" ] )
10092 expect ( statement . Resource ) . toHaveLength ( 3 )
10193 } )
102-
103- test ( "exports parameter names and policy ARN" , ( ) => {
104- const outputs = template . toJSON ( ) . Outputs as Record < string , {
105- Description ?: string
106- Export ?: {
107- Name ?: string
108- }
109- } >
110-
111- const exportedNames = Object . values ( outputs )
112- . map ( ( output ) => output . Export ?. Name )
113- . filter ( ( name ) : name is string => name !== undefined )
114-
115- const descriptions = Object . values ( outputs )
116- . map ( ( output ) => output . Description )
117- . filter ( ( description ) : description is string => description !== undefined )
118-
119- expect ( exportedNames ) . toContain ( "mock-stack-MockParam1Parameter" )
120- expect ( exportedNames ) . toContain ( "mock-stack-MockParam2Parameter" )
121- expect ( exportedNames ) . toContain ( "mock-stack-MockParam3Parameter" )
122- expect ( exportedNames ) . toContain ( "mock-stack-MockGetParametersPolicy" )
123-
124- expect ( descriptions ) . toContain ( "Name of the SSM parameter holding MockParam1" )
125- expect ( descriptions ) . toContain ( "Name of the SSM parameter holding MockParam2" )
126- expect ( descriptions ) . toContain ( "Name of the SSM parameter holding MockParam3" )
127- expect ( descriptions ) . toContain ( "Mock read policy output description" )
128- } )
12994} )
13095
13196describe ( "SsmParametersConstruct uses defaults when optional fields are omitted" , ( ) => {
132- test ( "outputDescription defaults to description and outputExportSuffix defaults to nameSuffix " , ( ) => {
97+ test ( "creates parameter and policy with default readPolicyDescription " , ( ) => {
13398 const app = new App ( )
13499 const stack = new Stack ( app , "defaultsStack" )
135100 const params = new SsmParametersConstruct ( stack , "DefaultsParameters" , {
@@ -140,22 +105,23 @@ describe("SsmParametersConstruct uses defaults when optional fields are omitted"
140105 nameSuffix : "MockParam1Suffix" ,
141106 description : "Mock SSM parameter description" ,
142107 value : "mock-value-1"
143- // outputDescription and outputExportSuffix intentionally omitted
144108 }
145109 ]
146110 } )
147111 // Get sonar to shup up about the construct not being used
148112 assert ( params , "SsmParametersConstruct should be created successfully" )
149113 const template = Template . fromStack ( stack )
150114
151- const outputs = template . toJSON ( ) . Outputs as Record < string , {
152- Description ?: string
153- Export ?: { Name ?: string }
154- } >
115+ template . hasResourceProperties ( "AWS::SSM::Parameter" , {
116+ Name : "mock-stack-MockParam1Suffix" ,
117+ Type : "String" ,
118+ Value : "mock-value-1" ,
119+ Description : "Mock SSM parameter description"
120+ } )
155121
156- const outputValues = Object . values ( outputs )
157- expect ( outputValues . some ( ( o ) => o . Description === "Mock SSM parameter description" ) ) . toBe ( true )
158- expect ( outputValues . some ( ( o ) => o . Export ?. Name === "mock-stack-MockParam1Suffix" ) ) . toBe ( true )
122+ template . hasResourceProperties ( "AWS::IAM::ManagedPolicy" , {
123+ Description : "Allows reading SSM parameters"
124+ } )
159125 } )
160126} )
161127
0 commit comments