Skip to content

Commit 5300eb6

Browse files
committed
Test fixes
1 parent 2eda01c commit 5300eb6

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

packages/cdkConstructs/src/constructs/RestApiGateway.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export interface RestApiGatewayProps {
4141
/** Stack name, used as prefix for resource naming and DNS records. */
4242
readonly stackName: string
4343
/** Stack UUID, used as a unique identifier for the stack. Optional */
44-
readonly stackUUID?: string
44+
readonly stackUuid?: string
4545
/** Shared retention period for API and deployment-related log groups. */
4646
readonly logRetentionInDays: number
4747
/** Truststore object key to enable mTLS; leave undefined to disable mTLS or when enableServiceDomain is false. */
@@ -58,9 +58,9 @@ export interface RestApiGatewayProps {
5858
readonly enableServiceDomain?: boolean
5959
}
6060

61-
const getTrustStoreKeyPrefix = (stackName: string, stackUUID?: string) => {
62-
if (stackUUID) {
63-
return `cpt-api/${stackName}-${stackUUID}-truststore`
61+
const getTrustStoreKeyPrefix = (stackName: string, stackUuid?: string) => {
62+
if (stackUuid) {
63+
return `cpt-api/${stackName}-${stackUuid}-truststore`
6464
} else {
6565
return `cpt-api/${stackName}-truststore`
6666
}

packages/cdkConstructs/tests/constructs/RestApiGateway.test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ describe("RestApiGateway with mTLS and stackUUID", () => {
351351
PolicyDocument?: {
352352
Statement?: Array<{
353353
Action?: Array<string>
354-
Resource?: string | Array<string>
354+
Resource?: unknown | Array<unknown>
355355
}>
356356
}
357357
}
@@ -372,7 +372,7 @@ describe("RestApiGateway with mTLS and stackUUID", () => {
372372

373373
const apiGateway = new RestApiGateway(stack, "TestApiGateway", {
374374
stackName: "test-stack",
375-
stackUUID: "f47ac10b",
375+
stackUUID: "f47ac10b-58cc-4372-a567-0e02b2c3d479",
376376
logRetentionInDays: 30,
377377
mutualTlsTrustStoreKey: "truststore.pem",
378378
forwardCsocLogs: false,
@@ -385,7 +385,7 @@ describe("RestApiGateway with mTLS and stackUUID", () => {
385385

386386
const template = Template.fromStack(stack)
387387
template.hasResourceProperties("Custom::CDKBucketDeployment", {
388-
DestinationKeyPrefix: "cpt-api/test-stack-f47ac10b-truststore"
388+
DestinationBucketKeyPrefix: "cpt-api/test-stack-f47ac10b-58cc-4372-a567-0e02b2c3d479-truststore"
389389
})
390390

391391
const policies = template.findResources("AWS::IAM::ManagedPolicy")
@@ -403,7 +403,13 @@ describe("RestApiGateway with mTLS and stackUUID", () => {
403403
? statement.Resource
404404
: (statement.Resource ? [statement.Resource] : [])
405405

406-
return resources.some((resource) => resource.includes(expectedTrustStoreObjectPath))
406+
return resources.some((resource) => {
407+
if (typeof resource === "string") {
408+
return resource.includes(expectedTrustStoreObjectPath)
409+
}
410+
411+
return JSON.stringify(resource).includes(expectedTrustStoreObjectPath)
412+
})
407413
})
408414
})
409415

0 commit comments

Comments
 (0)