From c980185142c58821b7ae7ef0b88c6c98ca8f0246 Mon Sep 17 00:00:00 2001 From: kaizen3031593 <36202692+kaizen3031593@users.noreply.github.com> Date: Tue, 5 Oct 2021 14:07:08 -0400 Subject: [PATCH] chore(assertions): replace `absentProperty()` with `absent()` and support it as a `Matcher` type (#16653) Currently `Match.absentProperty()` is not of type `Matcher` and this introduces a few flaws. For example, `Matcher.isMatcher(Match.absentProperty())` is `false`. This PR fixes this issue by replacing `Match.absentProperty()` with `Match.absent()` that is of type `Matcher`. The decision to change the name is due to supporting this as a general matcher and not just for Properties. BREAKING CHANGE: `Match.absentProperty()` becomes `Match.absent()`, and its type changes from `string` to `Matcher`. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/assertions/README.md | 10 ++-- packages/@aws-cdk/assertions/lib/match.ts | 39 ++++++++------- .../@aws-cdk/assertions/test/match.test.ts | 31 ++++++++++-- .../@aws-cdk/assertions/test/template.test.ts | 47 +++++++++++++++-- .../test/http/lambda.test.ts | 2 +- .../aws-apigatewayv2/test/http/api.test.ts | 6 +-- .../aws-cloudwatch/test/alarm.test.ts | 6 +-- .../aws-cognito/test/user-pool-client.test.ts | 50 +++++++++---------- .../aws-cognito/test/user-pool.test.ts | 48 +++++++++--------- .../aws-efs/test/efs-file-system.test.ts | 2 +- packages/@aws-cdk/aws-ivs/test/ivs.test.ts | 2 +- .../test/s3-bucket.test.ts | 4 +- .../test/delivery-stream.test.ts | 12 ++--- .../@aws-cdk/aws-neptune/test/cluster.test.ts | 2 +- .../aws-redshift/test/cluster.test.ts | 4 +- .../aws-synthetics/test/canary.test.ts | 2 +- .../test/example-resource.test.ts | 2 +- 17 files changed, 167 insertions(+), 102 deletions(-) diff --git a/packages/@aws-cdk/assertions/README.md b/packages/@aws-cdk/assertions/README.md index ce480bc152dc4..cb081c32053a2 100644 --- a/packages/@aws-cdk/assertions/README.md +++ b/packages/@aws-cdk/assertions/README.md @@ -194,8 +194,8 @@ match. ### Presence and Absence -The `Match.absentProperty()` matcher can be used to specify that a specific -property should not exist on the target. This can be used within `Match.objectLike()` +The `Match.absent()` matcher can be used to specify that a specific +value should not exist on the target. This can be used within `Match.objectLike()` or outside of any matchers. ```ts @@ -216,15 +216,15 @@ or outside of any matchers. // The following will NOT throw an assertion error assert.hasResourceProperties('Foo::Bar', { Fred: Match.objectLike({ - Bob: Match.absentProperty(), + Bob: Match.absent(), }), }); // The following will throw an assertion error assert.hasResourceProperties('Foo::Bar', { Fred: Match.objectLike({ - Wobble: Match.absentProperty(), - }) + Wobble: Match.absent(), + }), }); ``` diff --git a/packages/@aws-cdk/assertions/lib/match.ts b/packages/@aws-cdk/assertions/lib/match.ts index 9b18400abcbf6..8e4d83a398347 100644 --- a/packages/@aws-cdk/assertions/lib/match.ts +++ b/packages/@aws-cdk/assertions/lib/match.ts @@ -1,8 +1,6 @@ import { Matcher, MatchResult } from './matcher'; import { getType } from './private/type'; -const ABSENT = '{{ABSENT}}'; - /** * Partial and special matching during template assertions. */ @@ -10,8 +8,8 @@ export abstract class Match { /** * Use this matcher in the place of a field's value, if the field must not be present. */ - public static absentProperty(): string { - return ABSENT; + public static absent(): Matcher { + return new AbsentMatch('absent'); } /** @@ -129,10 +127,6 @@ class LiteralMatch extends Matcher { return result; } - if (this.pattern === ABSENT) { - throw new Error('absentProperty() can only be used in an object matcher'); - } - if (actual !== this.pattern) { result.push(this, [], `Expected ${this.pattern} but received ${actual}`); } @@ -185,9 +179,10 @@ class ArrayMatch extends Matcher { const patternElement = this.pattern[patternIdx]; const matcher = Matcher.isMatcher(patternElement) ? patternElement : new LiteralMatch(this.name, patternElement); - if (this.subsequence && matcher instanceof AnyMatch) { - // array subsequence matcher is not compatible with anyValue() matcher. They don't make sense to be used together. - throw new Error('The Matcher anyValue() cannot be nested within arrayWith()'); + const matcherName = matcher.name; + if (this.subsequence && (matcherName == 'absent' || matcherName == 'anyValue')) { + // array subsequence matcher is not compatible with anyValue() or absent() matcher. They don't make sense to be used together. + throw new Error(`The Matcher ${matcherName}() cannot be nested within arrayWith()`); } const innerResult = matcher.test(actual[actualIdx]); @@ -253,13 +248,7 @@ class ObjectMatch extends Matcher { } for (const [patternKey, patternVal] of Object.entries(this.pattern)) { - if (patternVal === ABSENT) { - if (patternKey in actual) { - result.push(this, [`/${patternKey}`], 'Key should be absent'); - } - continue; - } - if (!(patternKey in actual)) { + if (!(patternKey in actual) && !(patternVal instanceof AbsentMatch)) { result.push(this, [`/${patternKey}`], 'Missing key'); continue; } @@ -339,4 +328,18 @@ class AnyMatch extends Matcher { } return result; } +} + +class AbsentMatch extends Matcher { + constructor(public readonly name: string) { + super(); + } + + public test(actual: any): MatchResult { + const result = new MatchResult(actual); + if (actual !== undefined) { + result.push(this, [], `Received ${actual}, but key should be absent`); + } + return result; + } } \ No newline at end of file diff --git a/packages/@aws-cdk/assertions/test/match.test.ts b/packages/@aws-cdk/assertions/test/match.test.ts index b0c92a2da2c8f..0b1ce784f9023 100644 --- a/packages/@aws-cdk/assertions/test/match.test.ts +++ b/packages/@aws-cdk/assertions/test/match.test.ts @@ -77,7 +77,7 @@ describe('Matchers', () => { }); test('absent', () => { - expect(() => Match.exact(Match.absentProperty()).test('foo')).toThrow(/absentProperty/); + expect(() => Match.exact(Match.absent())).toThrow(/cannot directly contain another matcher/); }); }); @@ -125,8 +125,9 @@ describe('Matchers', () => { expectFailure(matcher, [{ foo: 'baz', fred: 'waldo' }], [/Missing element at pattern index 0/]); }); - test('absent', () => { - expect(() => Match.arrayWith([Match.absentProperty()]).test(['foo'])).toThrow(/absentProperty/); + test('incompatible with absent', () => { + matcher = Match.arrayWith(['foo', Match.absent()]); + expect(() => matcher.test(['foo', 'bar'])).toThrow(/absent\(\) cannot be nested within arrayWith\(\)/); }); test('incompatible with anyValue', () => { @@ -184,9 +185,9 @@ describe('Matchers', () => { }); test('absent', () => { - matcher = Match.objectLike({ foo: Match.absentProperty() }); + matcher = Match.objectLike({ foo: Match.absent() }); expectPass(matcher, { bar: 'baz' }); - expectFailure(matcher, { foo: 'baz' }, [/Key should be absent at \/foo/]); + expectFailure(matcher, { foo: 'baz' }, [/key should be absent at \/foo/]); }); }); @@ -363,6 +364,26 @@ describe('Matchers', () => { expectFailure(matcher, '{ "Foo"', [/invalid JSON string/i]); }); }); + + describe('absent', () => { + let matcher: Matcher; + + test('simple', () => { + matcher = Match.absent(); + expectFailure(matcher, 'foo', ['Received foo, but key should be absent']); + expectPass(matcher, undefined); + }); + + test('nested in object', () => { + matcher = Match.objectLike({ foo: Match.absent() }); + expectFailure(matcher, { foo: 'bar' }, [/key should be absent at \/foo/]); + expectFailure(matcher, { foo: [1, 2] }, [/key should be absent at \/foo/]); + expectFailure(matcher, { foo: null }, [/key should be absent at \/foo/]); + + expectPass(matcher, { foo: undefined }); + expectPass(matcher, {}); + }); + }); }); function expectPass(matcher: Matcher, target: any): void { diff --git a/packages/@aws-cdk/assertions/test/template.test.ts b/packages/@aws-cdk/assertions/test/template.test.ts index 97e7e4ca241a6..92f169488fd69 100644 --- a/packages/@aws-cdk/assertions/test/template.test.ts +++ b/packages/@aws-cdk/assertions/test/template.test.ts @@ -248,11 +248,11 @@ describe('Template', () => { const inspect = Template.fromStack(stack); inspect.hasResource('Foo::Bar', { - Properties: Match.objectLike({ foo: Match.absentProperty() }), + Properties: Match.objectLike({ foo: Match.absent() }), }); expect(() => inspect.hasResource('Foo::Bar', { - Properties: Match.objectLike({ baz: Match.absentProperty() }), - })).toThrow(/Key should be absent at \/Properties\/baz/); + Properties: Match.objectLike({ baz: Match.absent() }), + })).toThrow(/key should be absent at \/Properties\/baz/); }); test('incorrect types', () => { @@ -269,6 +269,47 @@ describe('Template', () => { }); }); + describe('hasResourceProperties', () => { + test('absent', () => { + const stack = new Stack(); + new CfnResource(stack, 'Foo', { + type: 'Foo::Bar', + properties: { baz: 'qux' }, + }); + + const inspect = Template.fromStack(stack); + inspect.hasResourceProperties('Foo::Bar', { + bar: Match.absent(), + }); + expect(() => inspect.hasResourceProperties('Foo::Bar', { + baz: Match.absent(), + })).toThrow(/key should be absent at \/Properties\/baz/); + }); + + test('absent - no properties on template', () => { + const stack = new Stack(); + new CfnResource(stack, 'Foo', { + type: 'Foo::Bar', + }); + + const inspect = Template.fromStack(stack); + inspect.hasResourceProperties('Foo::Bar', Match.absent()); + }); + + test('not', () => { + const stack = new Stack(); + new CfnResource(stack, 'Foo', { + type: 'Foo::Bar', + properties: { baz: 'qux' }, + }); + + const inspect = Template.fromStack(stack); + inspect.hasResourceProperties('Foo::Bar', Match.not({ + baz: 'boo', + })); + }); + }); + describe('getResources', () => { test('matching resource type', () => { const stack = new Stack(); diff --git a/packages/@aws-cdk/aws-apigatewayv2-authorizers/test/http/lambda.test.ts b/packages/@aws-cdk/aws-apigatewayv2-authorizers/test/http/lambda.test.ts index 1f62ad76867b0..c9fdf62c17d57 100644 --- a/packages/@aws-cdk/aws-apigatewayv2-authorizers/test/http/lambda.test.ts +++ b/packages/@aws-cdk/aws-apigatewayv2-authorizers/test/http/lambda.test.ts @@ -103,7 +103,7 @@ describe('HttpLambdaAuthorizer', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::ApiGatewayV2::Authorizer', { AuthorizerPayloadFormatVersion: '1.0', - EnableSimpleResponses: Match.absentProperty(), + EnableSimpleResponses: Match.absent(), }); }); diff --git a/packages/@aws-cdk/aws-apigatewayv2/test/http/api.test.ts b/packages/@aws-cdk/aws-apigatewayv2/test/http/api.test.ts index dc096594d0ecd..5b7f1052bfe35 100644 --- a/packages/@aws-cdk/aws-apigatewayv2/test/http/api.test.ts +++ b/packages/@aws-cdk/aws-apigatewayv2/test/http/api.test.ts @@ -127,7 +127,7 @@ describe('HttpApi', () => { new HttpApi(stack, 'HttpApi'); Template.fromStack(stack).hasResourceProperties('AWS::ApiGatewayV2::Api', { - CorsConfiguration: Match.absentProperty(), + CorsConfiguration: Match.absent(), }); }); @@ -447,7 +447,7 @@ describe('HttpApi', () => { Template.fromStack(stack).hasResourceProperties('AWS::ApiGatewayV2::Route', { RouteKey: 'GET /chickens', AuthorizationType: 'NONE', - AuthorizerId: Match.absentProperty(), + AuthorizerId: Match.absent(), }); }); @@ -469,7 +469,7 @@ describe('HttpApi', () => { }); Template.fromStack(stack).hasResourceProperties('AWS::ApiGatewayV2::Route', { - AuthorizationScopes: Match.absentProperty(), + AuthorizationScopes: Match.absent(), }); }); diff --git a/packages/@aws-cdk/aws-cloudwatch/test/alarm.test.ts b/packages/@aws-cdk/aws-cloudwatch/test/alarm.test.ts index c2381d2891a86..afb2224eb2f50 100644 --- a/packages/@aws-cdk/aws-cloudwatch/test/alarm.test.ts +++ b/packages/@aws-cdk/aws-cloudwatch/test/alarm.test.ts @@ -126,7 +126,7 @@ describe('Alarm', () => { Namespace: 'CDK/Test', Period: 300, Statistic: 'Maximum', - ExtendedStatistic: Match.absentProperty(), + ExtendedStatistic: Match.absent(), Threshold: 1000, }); @@ -152,7 +152,7 @@ describe('Alarm', () => { MetricName: 'Metric', Namespace: 'CDK/Test', Period: 300, - Statistic: Match.absentProperty(), + Statistic: Match.absent(), ExtendedStatistic: 'p99', Threshold: 1000, }); @@ -270,7 +270,7 @@ describe('Alarm', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::CloudWatch::Alarm', { - Statistic: Match.absentProperty(), + Statistic: Match.absent(), ExtendedStatistic: 'tm99.9999999999', }); diff --git a/packages/@aws-cdk/aws-cognito/test/user-pool-client.test.ts b/packages/@aws-cdk/aws-cognito/test/user-pool-client.test.ts index d6fc81f28c43c..2d2a72d48f767 100644 --- a/packages/@aws-cdk/aws-cognito/test/user-pool-client.test.ts +++ b/packages/@aws-cdk/aws-cognito/test/user-pool-client.test.ts @@ -63,7 +63,7 @@ describe('User Pool Client', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::Cognito::UserPoolClient', { - ExplicitAuthFlows: Match.absentProperty(), + ExplicitAuthFlows: Match.absent(), }); }); @@ -179,7 +179,7 @@ describe('User Pool Client', () => { Template.fromStack(stack).hasResourceProperties('AWS::Cognito::UserPoolClient', { AllowedOAuthFlows: ['client_credentials'], - CallbackURLs: Match.absentProperty(), + CallbackURLs: Match.absent(), }); Template.fromStack(stack).hasResourceProperties('AWS::Cognito::UserPoolClient', { @@ -206,7 +206,7 @@ describe('User Pool Client', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::Cognito::UserPoolClient', { - CallbackURLs: Match.absentProperty(), + CallbackURLs: Match.absent(), }); }); @@ -447,7 +447,7 @@ describe('User Pool Client', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::Cognito::UserPoolClient', { UserPoolId: stack.resolve(pool.userPoolId), - PreventUserExistenceErrors: Match.absentProperty(), + PreventUserExistenceErrors: Match.absent(), }); }); @@ -515,8 +515,8 @@ describe('User Pool Client', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::Cognito::UserPoolClient', { ClientName: 'OAuthDisabled', - AllowedOAuthFlows: Match.absentProperty(), - AllowedOAuthScopes: Match.absentProperty(), + AllowedOAuthFlows: Match.absent(), + AllowedOAuthScopes: Match.absent(), AllowedOAuthFlowsUserPoolClient: false, }); Template.fromStack(stack).hasResourceProperties('AWS::Cognito::UserPoolClient', { @@ -551,7 +551,7 @@ describe('User Pool Client', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::Cognito::UserPoolClient', { - EnableTokenRevocation: Match.absentProperty(), + EnableTokenRevocation: Match.absent(), }); }); @@ -632,42 +632,42 @@ describe('User Pool Client', () => { Template.fromStack(stack).hasResourceProperties('AWS::Cognito::UserPoolClient', { ClientName: 'Client2', AccessTokenValidity: 60, - IdTokenValidity: Match.absentProperty(), - RefreshTokenValidity: Match.absentProperty(), + IdTokenValidity: Match.absent(), + RefreshTokenValidity: Match.absent(), TokenValidityUnits: { AccessToken: 'minutes', - IdToken: Match.absentProperty(), - RefreshToken: Match.absentProperty(), + IdToken: Match.absent(), + RefreshToken: Match.absent(), }, }); Template.fromStack(stack).hasResourceProperties('AWS::Cognito::UserPoolClient', { ClientName: 'Client3', - AccessTokenValidity: Match.absentProperty(), + AccessTokenValidity: Match.absent(), IdTokenValidity: 60, - RefreshTokenValidity: Match.absentProperty(), + RefreshTokenValidity: Match.absent(), TokenValidityUnits: { - AccessToken: Match.absentProperty(), + AccessToken: Match.absent(), IdToken: 'minutes', - RefreshToken: Match.absentProperty(), + RefreshToken: Match.absent(), }, }); Template.fromStack(stack).hasResourceProperties('AWS::Cognito::UserPoolClient', { ClientName: 'Client4', - AccessTokenValidity: Match.absentProperty(), - IdTokenValidity: Match.absentProperty(), + AccessTokenValidity: Match.absent(), + IdTokenValidity: Match.absent(), RefreshTokenValidity: 43200, TokenValidityUnits: { - AccessToken: Match.absentProperty(), - IdToken: Match.absentProperty(), + AccessToken: Match.absent(), + IdToken: Match.absent(), RefreshToken: 'minutes', }, }); Template.fromStack(stack).hasResourceProperties('AWS::Cognito::UserPoolClient', { ClientName: 'Client5', - TokenValidityUnits: Match.absentProperty(), - IdTokenValidity: Match.absentProperty(), - RefreshTokenValidity: Match.absentProperty(), - AccessTokenValidity: Match.absentProperty(), + TokenValidityUnits: Match.absent(), + IdTokenValidity: Match.absent(), + RefreshTokenValidity: Match.absent(), + AccessTokenValidity: Match.absent(), }); }); @@ -886,8 +886,8 @@ describe('User Pool Client', () => { // EXPECT Template.fromStack(stack).hasResourceProperties('AWS::Cognito::UserPoolClient', { - ReadAttributes: Match.absentProperty(), - WriteAttributes: Match.absentProperty(), + ReadAttributes: Match.absent(), + WriteAttributes: Match.absent(), }); }); diff --git a/packages/@aws-cdk/aws-cognito/test/user-pool.test.ts b/packages/@aws-cdk/aws-cognito/test/user-pool.test.ts index 0c61312222355..7b132803da2d6 100644 --- a/packages/@aws-cdk/aws-cognito/test/user-pool.test.ts +++ b/packages/@aws-cdk/aws-cognito/test/user-pool.test.ts @@ -17,7 +17,7 @@ describe('User Pool', () => { Template.fromStack(stack).hasResourceProperties('AWS::Cognito::UserPool', { AdminCreateUserConfig: { AllowAdminCreateUserOnly: true, - InviteMessageTemplate: Match.absentProperty(), + InviteMessageTemplate: Match.absent(), }, EmailVerificationMessage: 'The verification code to your new account is {####}', EmailVerificationSubject: 'Verify your new account', @@ -28,9 +28,9 @@ describe('User Pool', () => { EmailSubject: 'Verify your new account', SmsMessage: 'The verification code to your new account is {####}', }, - SmsAuthenticationMessage: Match.absentProperty(), - SmsConfiguration: Match.absentProperty(), - lambdaTriggers: Match.absentProperty(), + SmsAuthenticationMessage: Match.absent(), + SmsConfiguration: Match.absent(), + lambdaTriggers: Match.absent(), }); Template.fromStack(stack).hasResource('AWS::Cognito::UserPool', { @@ -68,8 +68,8 @@ describe('User Pool', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::Cognito::UserPool', { - EmailVerificationMessage: Match.absentProperty(), - EmailVerificationSubject: Match.absentProperty(), + EmailVerificationMessage: Match.absent(), + EmailVerificationSubject: Match.absent(), SmsVerificationMessage: 'The verification code to your new account is {####}', VerificationMessageTemplate: { DefaultEmailOption: 'CONFIRM_WITH_LINK', @@ -415,8 +415,8 @@ describe('User Pool', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::Cognito::UserPool', { - UsernameAttributes: Match.absentProperty(), - AliasAttributes: Match.absentProperty(), + UsernameAttributes: Match.absent(), + AliasAttributes: Match.absent(), }); }); @@ -438,7 +438,7 @@ describe('User Pool', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::Cognito::UserPool', { - UsernameAttributes: Match.absentProperty(), + UsernameAttributes: Match.absent(), AliasAttributes: ['email'], }); }); @@ -455,7 +455,7 @@ describe('User Pool', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::Cognito::UserPool', { UsernameAttributes: ['email', 'phone_number'], - AliasAttributes: Match.absentProperty(), + AliasAttributes: Match.absent(), }); }); @@ -526,7 +526,7 @@ describe('User Pool', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::Cognito::UserPool', { - UsernameConfiguration: Match.absentProperty(), + UsernameConfiguration: Match.absent(), }); }); @@ -638,7 +638,7 @@ describe('User Pool', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::Cognito::UserPool', { UserPoolName: 'Pool', - Schema: Match.absentProperty(), + Schema: Match.absent(), }); }); @@ -687,14 +687,14 @@ describe('User Pool', () => { { Name: 'custom-string-attr', AttributeDataType: 'String', - StringAttributeConstraints: Match.absentProperty(), - NumberAttributeConstraints: Match.absentProperty(), + StringAttributeConstraints: Match.absent(), + NumberAttributeConstraints: Match.absent(), }, { Name: 'custom-number-attr', AttributeDataType: 'Number', - StringAttributeConstraints: Match.absentProperty(), - NumberAttributeConstraints: Match.absentProperty(), + StringAttributeConstraints: Match.absent(), + NumberAttributeConstraints: Match.absent(), }, ], }); @@ -759,13 +759,13 @@ describe('User Pool', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::Cognito::UserPool', { UserPoolName: 'Pool1', - MfaConfiguration: Match.absentProperty(), - EnabledMfas: Match.absentProperty(), + MfaConfiguration: Match.absent(), + EnabledMfas: Match.absent(), }); Template.fromStack(stack).hasResourceProperties('AWS::Cognito::UserPool', { UserPoolName: 'Pool2', MfaConfiguration: 'OFF', - EnabledMfas: Match.absentProperty(), + EnabledMfas: Match.absent(), }); }); @@ -1120,7 +1120,7 @@ describe('User Pool', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::Cognito::UserPool', { - AccountRecoverySetting: Match.absentProperty(), + AccountRecoverySetting: Match.absent(), }); }); @@ -1153,7 +1153,7 @@ describe('User Pool', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::Cognito::UserPool', { - SmsConfiguration: Match.absentProperty(), + SmsConfiguration: Match.absent(), }); }); @@ -1245,7 +1245,7 @@ describe('User Pool', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::Cognito::UserPool', { - SmsConfiguration: Match.absentProperty(), + SmsConfiguration: Match.absent(), }); }); @@ -1267,7 +1267,7 @@ describe('User Pool', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::Cognito::UserPool', { - SmsConfiguration: Match.absentProperty(), + SmsConfiguration: Match.absent(), }); }); @@ -1351,7 +1351,7 @@ describe('User Pool', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::Cognito::UserPool', { - SmsConfiguration: Match.absentProperty(), + SmsConfiguration: Match.absent(), }); }); diff --git a/packages/@aws-cdk/aws-efs/test/efs-file-system.test.ts b/packages/@aws-cdk/aws-efs/test/efs-file-system.test.ts index 5e098503de2eb..b417ff5bf106c 100644 --- a/packages/@aws-cdk/aws-efs/test/efs-file-system.test.ts +++ b/packages/@aws-cdk/aws-efs/test/efs-file-system.test.ts @@ -42,7 +42,7 @@ testLegacyBehavior('when @aws-cdk/aws-efs:defaultEncryptionAtRest is missing, en }); Template.fromStack(customStack).hasResourceProperties('AWS::EFS::FileSystem', { - Encrypted: Match.absentProperty(), + Encrypted: Match.absent(), }); }); diff --git a/packages/@aws-cdk/aws-ivs/test/ivs.test.ts b/packages/@aws-cdk/aws-ivs/test/ivs.test.ts index 6e4cd765576e4..4104994ed882c 100644 --- a/packages/@aws-cdk/aws-ivs/test/ivs.test.ts +++ b/packages/@aws-cdk/aws-ivs/test/ivs.test.ts @@ -23,7 +23,7 @@ test('channel default properties', () => { new ivs.Channel(stack, 'Channel'); Template.fromStack(stack).hasResource('AWS::IVS::Channel', { - Properties: Match.absentProperty(), + Properties: Match.absent(), }); }); diff --git a/packages/@aws-cdk/aws-kinesisfirehose-destinations/test/s3-bucket.test.ts b/packages/@aws-cdk/aws-kinesisfirehose-destinations/test/s3-bucket.test.ts index 448d0b8efcf40..74d37d180f954 100644 --- a/packages/@aws-cdk/aws-kinesisfirehose-destinations/test/s3-bucket.test.ts +++ b/packages/@aws-cdk/aws-kinesisfirehose-destinations/test/s3-bucket.test.ts @@ -169,7 +169,7 @@ describe('S3 destination', () => { Template.fromStack(stack).resourceCountIs('AWS::Logs::LogGroup', 0); Template.fromStack(stack).hasResourceProperties('AWS::KinesisFirehose::DeliveryStream', { ExtendedS3DestinationConfiguration: { - CloudWatchLoggingOptions: Match.absentProperty(), + CloudWatchLoggingOptions: Match.absent(), }, }); }); @@ -548,7 +548,7 @@ describe('S3 destination', () => { Template.fromStack(stack).resourceCountIs('AWS::S3::Bucket', 1); Template.fromStack(stack).hasResourceProperties('AWS::KinesisFirehose::DeliveryStream', { ExtendedS3DestinationConfiguration: { - S3BackupConfiguration: Match.absentProperty(), + S3BackupConfiguration: Match.absent(), }, }); }); diff --git a/packages/@aws-cdk/aws-kinesisfirehose/test/delivery-stream.test.ts b/packages/@aws-cdk/aws-kinesisfirehose/test/delivery-stream.test.ts index f716e56a8f326..ec206b739ed01 100644 --- a/packages/@aws-cdk/aws-kinesisfirehose/test/delivery-stream.test.ts +++ b/packages/@aws-cdk/aws-kinesisfirehose/test/delivery-stream.test.ts @@ -47,10 +47,10 @@ describe('delivery stream', () => { }); Template.fromStack(stack).hasResourceProperties('AWS::KinesisFirehose::DeliveryStream', { - DeliveryStreamEncryptionConfigurationInput: Match.absentProperty(), - DeliveryStreamName: Match.absentProperty(), + DeliveryStreamEncryptionConfigurationInput: Match.absent(), + DeliveryStreamName: Match.absent(), DeliveryStreamType: 'DirectPut', - KinesisStreamSourceConfiguration: Match.absentProperty(), + KinesisStreamSourceConfiguration: Match.absent(), ExtendedS3DestinationConfiguration: { BucketARN: bucketArn, RoleARN: roleArn, @@ -205,7 +205,7 @@ describe('delivery stream', () => { Template.fromStack(stack).hasResourceProperties('AWS::KinesisFirehose::DeliveryStream', { DeliveryStreamType: 'DirectPut', DeliveryStreamEncryptionConfigurationInput: { - KeyARN: Match.absentProperty(), + KeyARN: Match.absent(), KeyType: 'AWS_OWNED_CMK', }, }); @@ -222,7 +222,7 @@ describe('delivery stream', () => { Template.fromStack(stack).resourceCountIs('AWS::IAM::Policy', 0); Template.fromStack(stack).hasResourceProperties('AWS::KinesisFirehose::DeliveryStream', { DeliveryStreamType: 'DirectPut', - DeliveryStreamEncryptionConfigurationInput: Match.absentProperty(), + DeliveryStreamEncryptionConfigurationInput: Match.absent(), }); }); @@ -326,7 +326,7 @@ describe('delivery stream', () => { DependsOn: [dependableId], }); Template.fromStack(stack).hasResource('AWS::IAM::Role', { - DependsOn: Match.absentProperty(), + DependsOn: Match.absent(), }); }); diff --git a/packages/@aws-cdk/aws-neptune/test/cluster.test.ts b/packages/@aws-cdk/aws-neptune/test/cluster.test.ts index 74f4770a8a74c..f53af7911dc6c 100644 --- a/packages/@aws-cdk/aws-neptune/test/cluster.test.ts +++ b/packages/@aws-cdk/aws-neptune/test/cluster.test.ts @@ -446,7 +446,7 @@ describe('DatabaseCluster', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::Neptune::DBCluster', { - IamAuthEnabled: Match.absentProperty(), + IamAuthEnabled: Match.absent(), }); }); diff --git a/packages/@aws-cdk/aws-redshift/test/cluster.test.ts b/packages/@aws-cdk/aws-redshift/test/cluster.test.ts index 910319b91bcd4..a1091815a30c1 100644 --- a/packages/@aws-cdk/aws-redshift/test/cluster.test.ts +++ b/packages/@aws-cdk/aws-redshift/test/cluster.test.ts @@ -146,7 +146,7 @@ describe('node count', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::Redshift::Cluster', { ClusterType: 'single-node', - NumberOfNodes: Match.absentProperty(), + NumberOfNodes: Match.absent(), }); }); @@ -164,7 +164,7 @@ describe('node count', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::Redshift::Cluster', { ClusterType: 'single-node', - NumberOfNodes: Match.absentProperty(), + NumberOfNodes: Match.absent(), }); }); diff --git a/packages/@aws-cdk/aws-synthetics/test/canary.test.ts b/packages/@aws-cdk/aws-synthetics/test/canary.test.ts index c4583ef5494cf..27491d01b2850 100644 --- a/packages/@aws-cdk/aws-synthetics/test/canary.test.ts +++ b/packages/@aws-cdk/aws-synthetics/test/canary.test.ts @@ -229,7 +229,7 @@ test('environment variables are skipped if not provided', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::Synthetics::Canary', { - RunConfig: Match.absentProperty(), + RunConfig: Match.absent(), }); }); diff --git a/packages/@aws-cdk/example-construct-library/test/example-resource.test.ts b/packages/@aws-cdk/example-construct-library/test/example-resource.test.ts index 091c0c7d1f65a..db1e8d68d4830 100644 --- a/packages/@aws-cdk/example-construct-library/test/example-resource.test.ts +++ b/packages/@aws-cdk/example-construct-library/test/example-resource.test.ts @@ -56,7 +56,7 @@ describe('Example Resource', () => { 'Ref': 'ExampleResourceWaitConditionHandle9C53A8D3', }, // this is how you can check a given property is _not_ set - 'RandomProperty': Match.absentProperty(), + 'RandomProperty': Match.absent(), }); });