@@ -258,18 +258,29 @@ describe("RestApiGateway with mTLS", () => {
258258 } )
259259
260260 test ( "creates trust store deployment policy with S3 permissions" , ( ) => {
261+ interface PolicyResource {
262+ Properties ?: {
263+ PolicyDocument ?: {
264+ Statement ?: Array < { Action ?: Array < string > } >
265+ }
266+ }
267+ }
268+ interface Statement {
269+ Action ?: Array < string >
270+ }
271+
261272 const policies = template . findResources ( "AWS::IAM::ManagedPolicy" )
262- const trustStorePolicy = Object . values ( policies ) . find ( ( p : any ) =>
263- p . Properties ?. PolicyDocument ?. Statement ?. some ( ( s : any ) =>
273+ const trustStorePolicy = Object . values ( policies ) . find ( ( p : PolicyResource ) =>
274+ p . Properties ?. PolicyDocument ?. Statement ?. some ( ( s : Statement ) =>
264275 s . Action ?. includes ( "s3:ListBucket" )
265276 )
266- )
277+ ) as PolicyResource
267278 expect ( trustStorePolicy ) . toBeDefined ( )
268- const statements = ( trustStorePolicy as any ) . Properties . PolicyDocument . Statement
269- expect ( statements . some ( ( s : any ) => s . Action ?. includes ( "s3:ListBucket" ) ) ) . toBe ( true )
270- expect ( statements . some ( ( s : any ) => s . Action ?. includes ( "s3:GetObject" ) ) ) . toBe ( true )
271- expect ( statements . some ( ( s : any ) => s . Action ?. includes ( "kms:Decrypt" ) ) ) . toBe ( true )
272- expect ( statements . some ( ( s : any ) => s . Action ?. includes ( "logs:CreateLogStream" ) ) ) . toBe ( true )
279+ const statements = trustStorePolicy . Properties ? .PolicyDocument ? .Statement ?? [ ]
280+ expect ( statements . some ( ( s : Statement ) => s . Action ?. includes ( "s3:ListBucket" ) ) ) . toBe ( true )
281+ expect ( statements . some ( ( s : Statement ) => s . Action ?. includes ( "s3:GetObject" ) ) ) . toBe ( true )
282+ expect ( statements . some ( ( s : Statement ) => s . Action ?. includes ( "kms:Decrypt" ) ) ) . toBe ( true )
283+ expect ( statements . some ( ( s : Statement ) => s . Action ?. includes ( "logs:CreateLogStream" ) ) ) . toBe ( true )
273284 } )
274285
275286 test ( "creates trust store deployment role" , ( ) => {
@@ -302,8 +313,16 @@ describe("RestApiGateway with mTLS", () => {
302313 } )
303314
304315 test ( "configures mTLS on domain name" , ( ) => {
316+ interface DomainNameResource {
317+ Properties : {
318+ MutualTlsAuthentication : {
319+ TruststoreUri : unknown
320+ }
321+ }
322+ }
323+
305324 const domainNames = template . findResources ( "AWS::ApiGateway::DomainName" )
306- const domainName = Object . values ( domainNames ) [ 0 ] as any
325+ const domainName = Object . values ( domainNames ) [ 0 ] as DomainNameResource
307326 expect ( domainName . Properties . MutualTlsAuthentication ) . toBeDefined ( )
308327 expect ( domainName . Properties . MutualTlsAuthentication . TruststoreUri ) . toBeDefined ( )
309328 } )
0 commit comments