@@ -99,37 +99,10 @@ describe("SsmParametersConstruct", () => {
9999 expect ( statement . Action ) . toEqual ( [ "ssm:GetParameter" , "ssm:GetParameters" ] )
100100 expect ( statement . Resource ) . toHaveLength ( 3 )
101101 } )
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- } )
129102} )
130103
131104describe ( "SsmParametersConstruct uses defaults when optional fields are omitted" , ( ) => {
132- test ( "outputDescription defaults to description and outputExportSuffix defaults to nameSuffix " , ( ) => {
105+ test ( "creates parameter and policy with default readPolicyDescription when optional fields are omitted " , ( ) => {
133106 const app = new App ( )
134107 const stack = new Stack ( app , "defaultsStack" )
135108 const params = new SsmParametersConstruct ( stack , "DefaultsParameters" , {
@@ -140,22 +113,24 @@ describe("SsmParametersConstruct uses defaults when optional fields are omitted"
140113 nameSuffix : "MockParam1Suffix" ,
141114 description : "Mock SSM parameter description" ,
142115 value : "mock-value-1"
143- // outputDescription and outputExportSuffix intentionally omitted
144116 }
145- ]
117+ ] ,
118+ readPolicyExportSuffix : "MockGetParametersPolicy"
146119 } )
147120 // Get sonar to shup up about the construct not being used
148121 assert ( params , "SsmParametersConstruct should be created successfully" )
149122 const template = Template . fromStack ( stack )
150123
151- const outputs = template . toJSON ( ) . Outputs as Record < string , {
152- Description ?: string
153- Export ?: { Name ?: string }
154- } >
124+ template . hasResourceProperties ( "AWS::SSM::Parameter" , {
125+ Name : "mock-stack-MockParam1Suffix" ,
126+ Type : "String" ,
127+ Value : "mock-value-1" ,
128+ Description : "Mock SSM parameter description"
129+ } )
155130
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 )
131+ template . hasResourceProperties ( "AWS::IAM::ManagedPolicy" , {
132+ Description : "Allows reading SSM parameters"
133+ } )
159134 } )
160135} )
161136
0 commit comments