Skip to content

Commit b0ba52e

Browse files
chore: remove testLegacyBehavior and update testFutureBehavior tests (#21949)
testLegacyBehavior only runs tests in v1 and skips them in v2, so none of these tests were running anyway. testFutureBehavior just runs the tests with the feature-flag as true, which is the default to these in v2 anyway. I'm removing these functions and their uses so that contributors aren't mislead to think they should use them. I also fixed some spacing issues in test packages. The diff on this is kind of hard to follow but the summary of the change is this: - all testLegacyBehavior tests have been deleted - all testFutureBehavior tests have been updated to be standard tests - describe blocks were removed where they wrapped around legacy or future sets of tests - spacing fixed ---- ### All Submissions: * [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 809e1b0 commit b0ba52e

File tree

30 files changed

+425
-2621
lines changed

30 files changed

+425
-2621
lines changed

packages/@aws-cdk/aws-apigateway/test/usage-plan.test.ts

+25-30
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { Template } from '@aws-cdk/assertions';
2-
import { testFutureBehavior } from '@aws-cdk/cdk-build-tools/lib/feature-flag';
32
import * as cdk from '@aws-cdk/core';
4-
import * as cxapi from '@aws-cdk/cx-api';
53
import * as apigateway from '../lib';
64

75
const RESOURCE_TYPE = 'AWS::ApiGateway::UsagePlan';
@@ -298,35 +296,32 @@ describe('usage plan', () => {
298296
expect(logicalIds).toEqual(['mylogicalid']);
299297
});
300298

301-
describe('future flag: @aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId', () => {
302-
const flags = { [cxapi.APIGATEWAY_USAGEPLANKEY_ORDERINSENSITIVE_ID]: true };
303-
304-
testFutureBehavior('UsagePlanKeys have unique logical ids', flags, cdk.App, (app) => {
305-
// GIVEN
306-
const stack = new cdk.Stack(app, 'my-stack');
307-
const usagePlan = new apigateway.UsagePlan(stack, 'my-usage-plan');
308-
const apiKey1 = new apigateway.ApiKey(stack, 'my-api-key-1', {
309-
apiKeyName: 'my-api-key-1',
310-
});
311-
const apiKey2 = new apigateway.ApiKey(stack, 'my-api-key-2', {
312-
apiKeyName: 'my-api-key-2',
313-
});
314-
315-
// WHEN
316-
usagePlan.addApiKey(apiKey1);
317-
usagePlan.addApiKey(apiKey2);
318-
319-
// THEN
320-
const template = app.synth().getStackByName(stack.stackName).template;
321-
const logicalIds = Object.entries(template.Resources)
322-
.filter(([_, v]) => (v as any).Type === 'AWS::ApiGateway::UsagePlanKey')
323-
.map(([k, _]) => k);
324-
325-
expect(logicalIds).toEqual([
326-
'myusageplanUsagePlanKeyResourcemystackmyapikey1EE9AA1B359121274',
327-
'myusageplanUsagePlanKeyResourcemystackmyapikey2B4E8EB1456DC88E9',
328-
]);
299+
test('UsagePlanKeys have unique logical ids', () => {
300+
// GIVEN
301+
const app = new cdk.App();
302+
const stack = new cdk.Stack(app, 'my-stack');
303+
const usagePlan = new apigateway.UsagePlan(stack, 'my-usage-plan');
304+
const apiKey1 = new apigateway.ApiKey(stack, 'my-api-key-1', {
305+
apiKeyName: 'my-api-key-1',
329306
});
307+
const apiKey2 = new apigateway.ApiKey(stack, 'my-api-key-2', {
308+
apiKeyName: 'my-api-key-2',
309+
});
310+
311+
// WHEN
312+
usagePlan.addApiKey(apiKey1);
313+
usagePlan.addApiKey(apiKey2);
314+
315+
// THEN
316+
const template = app.synth().getStackByName(stack.stackName).template;
317+
const logicalIds = Object.entries(template.Resources)
318+
.filter(([_, v]) => (v as any).Type === 'AWS::ApiGateway::UsagePlanKey')
319+
.map(([k, _]) => k);
320+
321+
expect(logicalIds).toEqual([
322+
'myusageplanUsagePlanKeyResourcemystackmyapikey1EE9AA1B359121274',
323+
'myusageplanUsagePlanKeyResourcemystackmyapikey2B4E8EB1456DC88E9',
324+
]);
330325
});
331326
});
332327
});

packages/@aws-cdk/aws-cloudfront/test/distribution.test.ts

+18-63
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import { Match, Template } from '@aws-cdk/assertions';
22
import * as acm from '@aws-cdk/aws-certificatemanager';
33
import * as lambda from '@aws-cdk/aws-lambda';
44
import * as s3 from '@aws-cdk/aws-s3';
5-
import { testFutureBehavior, testLegacyBehavior } from '@aws-cdk/cdk-build-tools/lib/feature-flag';
65
import { App, Duration, Stack } from '@aws-cdk/core';
7-
import { CLOUDFRONT_DEFAULT_SECURITY_POLICY_TLS_V1_2_2021 } from '@aws-cdk/cx-api';
86
import {
97
CfnDistribution,
108
Distribution,
@@ -289,7 +287,6 @@ ellipsis so a user would know there was more to ...`,
289287
});
290288

291289
describe('multiple behaviors', () => {
292-
293290
test('a second behavior can\'t be specified with the catch-all path pattern', () => {
294291
const origin = defaultOrigin();
295292

@@ -443,7 +440,6 @@ describe('multiple behaviors', () => {
443440
});
444441

445442
describe('certificates', () => {
446-
447443
test('should fail if using an imported certificate from outside of us-east-1', () => {
448444
const origin = defaultOrigin();
449445
const certificate = acm.Certificate.fromCertificateArn(stack, 'Cert', 'arn:aws:acm:eu-west-1:123456789012:certificate/12345678-1234-1234-1234-123456789012');
@@ -475,61 +471,25 @@ describe('certificates', () => {
475471
}).toThrow(/Must specify at least one domain name/);
476472
});
477473

478-
describe('adding a certificate and domain renders the correct ViewerCertificate and Aliases property', () => {
479-
testFutureBehavior(
480-
'when @aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021 is enabled, use the TLSv1.2_2021 security policy by default',
481-
{ [CLOUDFRONT_DEFAULT_SECURITY_POLICY_TLS_V1_2_2021]: true },
482-
App,
483-
(customApp) => {
484-
const customStack = new Stack(customApp);
485-
486-
const certificate = acm.Certificate.fromCertificateArn(customStack, 'Cert', 'arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012');
487-
488-
new Distribution(customStack, 'Dist', {
489-
defaultBehavior: { origin: defaultOrigin() },
490-
domainNames: ['example.com', 'www.example.com'],
491-
certificate,
492-
});
493-
494-
Template.fromStack(customStack).hasResourceProperties('AWS::CloudFront::Distribution', {
495-
DistributionConfig: {
496-
Aliases: ['example.com', 'www.example.com'],
497-
ViewerCertificate: {
498-
AcmCertificateArn: 'arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012',
499-
SslSupportMethod: 'sni-only',
500-
MinimumProtocolVersion: 'TLSv1.2_2021',
501-
},
502-
},
503-
});
504-
},
505-
);
506-
507-
testLegacyBehavior(
508-
'when @aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021 is disabled, use the TLSv1.2_2019 security policy by default',
509-
App,
510-
(customApp) => {
511-
const customStack = new Stack(customApp);
512-
513-
const certificate = acm.Certificate.fromCertificateArn(customStack, 'Cert', 'arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012');
514-
515-
new Distribution(customStack, 'Dist', {
516-
defaultBehavior: { origin: defaultOrigin() },
517-
domainNames: ['example.com', 'www.example.com'],
518-
certificate,
519-
});
520-
521-
Template.fromStack(customStack).hasResourceProperties('AWS::CloudFront::Distribution', {
522-
DistributionConfig: {
523-
Aliases: ['example.com', 'www.example.com'],
524-
ViewerCertificate: {
525-
AcmCertificateArn: 'arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012',
526-
SslSupportMethod: 'sni-only',
527-
MinimumProtocolVersion: 'TLSv1.2_2019',
528-
},
529-
},
530-
});
474+
test('use the TLSv1.2_2021 security policy by default', () => {
475+
const certificate = acm.Certificate.fromCertificateArn(stack, 'Cert', 'arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012');
476+
477+
new Distribution(stack, 'Dist', {
478+
defaultBehavior: { origin: defaultOrigin() },
479+
domainNames: ['example.com', 'www.example.com'],
480+
certificate,
481+
});
482+
483+
Template.fromStack(stack).hasResourceProperties('AWS::CloudFront::Distribution', {
484+
DistributionConfig: {
485+
Aliases: ['example.com', 'www.example.com'],
486+
ViewerCertificate: {
487+
AcmCertificateArn: 'arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012',
488+
SslSupportMethod: 'sni-only',
489+
MinimumProtocolVersion: 'TLSv1.2_2021',
490+
},
531491
},
532-
);
492+
});
533493
});
534494

535495
test('adding a certificate with non default security policy protocol', () => {
@@ -552,11 +512,9 @@ describe('certificates', () => {
552512
},
553513
});
554514
});
555-
556515
});
557516

558517
describe('custom error responses', () => {
559-
560518
test('should fail if only the error code is provided', () => {
561519
const origin = defaultOrigin();
562520

@@ -611,7 +569,6 @@ describe('custom error responses', () => {
611569
},
612570
});
613571
});
614-
615572
});
616573

617574
describe('logging', () => {
@@ -915,7 +872,6 @@ describe('with Lambda@Edge functions', () => {
915872
});
916873

917874
describe('with CloudFront functions', () => {
918-
919875
test('can add a CloudFront function to the default behavior', () => {
920876
new Distribution(stack, 'MyDist', {
921877
defaultBehavior: {
@@ -949,7 +905,6 @@ describe('with CloudFront functions', () => {
949905
},
950906
});
951907
});
952-
953908
});
954909

955910
test('price class is included if provided', () => {

packages/@aws-cdk/aws-codepipeline-actions/test/lambda/lambda-invoke-action.test.ts

+4-8
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,11 @@ import * as codepipeline from '@aws-cdk/aws-codepipeline';
33
import * as lambda from '@aws-cdk/aws-lambda';
44
import * as s3 from '@aws-cdk/aws-s3';
55
import * as sns from '@aws-cdk/aws-sns';
6-
import { testFutureBehavior } from '@aws-cdk/cdk-build-tools/lib/feature-flag';
76
import { App, Aws, Lazy, SecretValue, Stack, Token } from '@aws-cdk/core';
8-
import * as cxapi from '@aws-cdk/cx-api';
97
import * as cpactions from '../../lib';
108

119
/* eslint-disable quote-props */
1210

13-
const s3GrantWriteCtx = { [cxapi.S3_GRANT_WRITE_WITHOUT_ACL]: true };
14-
1511
describe('', () => {
1612
describe('Lambda invoke Action', () => {
1713
test('properly serializes the object passed in userParameters', () => {
@@ -160,11 +156,11 @@ describe('', () => {
160156
}));
161157
});
162158

163-
testFutureBehavior("assigns the Action's Role with write permissions to the Bucket if it has only outputs", s3GrantWriteCtx, App, (app) => {
159+
test("assigns the Action's Role with write permissions to the Bucket if it has only outputs", () => {
164160
const stack = stackIncludingLambdaInvokeCodePipeline({
165161
lambdaOutput: new codepipeline.Artifact(),
166162
// no input to the Lambda Action - we want write permissions only in this case
167-
}, app);
163+
});
168164

169165
Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', {
170166
PolicyName: 'PipelineInvokeLambdaCodePipelineActionRoleDefaultPolicy103F34DA',
@@ -205,11 +201,11 @@ describe('', () => {
205201
});
206202
});
207203

208-
testFutureBehavior("assigns the Action's Role with read-write permissions to the Bucket if it has both inputs and outputs", s3GrantWriteCtx, App, (app) => {
204+
test("assigns the Action's Role with read-write permissions to the Bucket if it has both inputs and outputs", () => {
209205
const stack = stackIncludingLambdaInvokeCodePipeline({
210206
lambdaInput: new codepipeline.Artifact(),
211207
lambdaOutput: new codepipeline.Artifact(),
212-
}, app);
208+
});
213209

214210
Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', {
215211
PolicyName: 'PipelineInvokeLambdaCodePipelineActionRoleDefaultPolicy103F34DA',

0 commit comments

Comments
 (0)