Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mrgrain committed Sep 8, 2023
1 parent 9ab70c3 commit 7d8dca2
Show file tree
Hide file tree
Showing 85 changed files with 2,472 additions and 997 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ class BundlingStage extends cdk.Stage {
new lambda.Function(stack, 'Handler', {
code: lambda.Code.fromAsset(path.join(__dirname, 'lambda')),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_16_X,
runtime: lambda.Runtime.NODEJS_LATEST,
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as path from 'path';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import { App, Stack } from 'aws-cdk-lib';
import { MockIntegration, PassthroughBehavior, RestApi, RequestAuthorizer, IdentitySource } from 'aws-cdk-lib/aws-apigateway';
import { STANDARD_NODEJS_RUNTIME } from '../../../config';

// Against the RestApi endpoint from the stack output, run
// `curl -s -o /dev/null -w "%{http_code}" <url>` should return 401
Expand All @@ -12,7 +13,7 @@ const app = new App();
const stack = new Stack(app, 'RequestAuthorizerInteg');

const authorizerFn = new lambda.Function(stack, 'MyAuthorizerFunction', {
runtime: lambda.Runtime.NODEJS_16_X,
runtime: STANDARD_NODEJS_RUNTIME,
handler: 'index.handler',
code: lambda.AssetCode.fromAsset(path.join(__dirname, 'integ.request-authorizer.handler')),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as lambda from 'aws-cdk-lib/aws-lambda';
import { App, Stack } from 'aws-cdk-lib';
import { IntegTest } from '@aws-cdk/integ-tests-alpha';
import { AuthorizationType, MockIntegration, PassthroughBehavior, RestApi, TokenAuthorizer } from 'aws-cdk-lib/aws-apigateway';
import { STANDARD_NODEJS_RUNTIME } from '../../../config';

/*
* Stack verification steps:
Expand All @@ -16,7 +17,7 @@ const app = new App();
const stack = new Stack(app, 'TokenAuthorizerIAMRoleInteg');

const authorizerFn = new lambda.Function(stack, 'MyAuthorizerFunction', {
runtime: lambda.Runtime.NODEJS_16_X,
runtime: STANDARD_NODEJS_RUNTIME,
handler: 'index.handler',
code: lambda.AssetCode.fromAsset(path.join(__dirname, 'integ.token-authorizer.handler')),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import * as lambda from 'aws-cdk-lib/aws-lambda';
import { App, Stack, Duration } from 'aws-cdk-lib';
import { IntegTest, ExpectedResult, Match } from '@aws-cdk/integ-tests-alpha';
import { MockIntegration, PassthroughBehavior, RestApi, TokenAuthorizer, Cors } from 'aws-cdk-lib/aws-apigateway';
import { STANDARD_NODEJS_RUNTIME } from '../../../config';

const app = new App();
const stack = new Stack(app, 'TokenAuthorizerInteg');

const authorizerFn = new lambda.Function(stack, 'MyAuthorizerFunction', {
runtime: lambda.Runtime.NODEJS_16_X,
runtime: STANDARD_NODEJS_RUNTIME,
handler: 'index.handler',
code: lambda.AssetCode.fromAsset(path.join(__dirname, 'integ.token-authorizer.handler')),
});
Expand Down Expand Up @@ -90,7 +91,7 @@ exports.handler = async function(event) {
}
`),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_16_X,
runtime: STANDARD_NODEJS_RUNTIME,
});

const invokeGet = integ.assertions.invokeFunction({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { App, Stack, StackProps } from 'aws-cdk-lib';
import { IntegTest } from '@aws-cdk/integ-tests-alpha';
import { Construct } from 'constructs';
import * as apigw from 'aws-cdk-lib/aws-apigateway';
import { STANDARD_NODEJS_RUNTIME } from '../../config';

class TestStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
Expand All @@ -14,7 +15,7 @@ class TestStack extends Stack {
});

const handler = new lambda.Function(this, 'handler', {
runtime: lambda.Runtime.NODEJS_16_X,
runtime: STANDARD_NODEJS_RUNTIME,
handler: 'index.handler',
code: lambda.Code.fromAsset(path.join(__dirname, 'integ.cors.handler')),
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { Code, Function, Runtime } from 'aws-cdk-lib/aws-lambda';
import { Code, Function } from 'aws-cdk-lib/aws-lambda';
import { App, Stack } from 'aws-cdk-lib';
import { IntegTest } from '@aws-cdk/integ-tests-alpha';
import { Construct } from 'constructs';
import { LambdaRestApi, PassthroughBehavior } from 'aws-cdk-lib/aws-apigateway';
import { STANDARD_NODEJS_RUNTIME } from '../../config';

class LambdaApiIntegrationOptionsNonProxyIntegrationStack extends Stack {
constructor(scope: Construct) {
super(scope, 'LambdaApiIntegrationOptionsNonProxyIntegrationStack');

const fn = new Function(this, 'myfn', {
code: Code.fromInline('foo'),
runtime: Runtime.NODEJS_16_X,
runtime: STANDARD_NODEJS_RUNTIME,
handler: 'index.handler',
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { Code, Function, Runtime } from 'aws-cdk-lib/aws-lambda';
import { Code, Function } from 'aws-cdk-lib/aws-lambda';
import { App, Stack } from 'aws-cdk-lib';
import { IntegTest } from '@aws-cdk/integ-tests-alpha';
import { Construct } from 'constructs';
import { Deployment, LambdaRestApi, Stage } from 'aws-cdk-lib/aws-apigateway';
import { STANDARD_NODEJS_RUNTIME } from '../../config';

class LateBoundDeploymentStageStack extends Stack {
constructor(scope: Construct) {
super(scope, 'LateBoundDeploymentStageStack');

const fn = new Function(this, 'myfn', {
code: Code.fromInline('foo'),
runtime: Runtime.NODEJS_16_X,
runtime: STANDARD_NODEJS_RUNTIME,
handler: 'index.handler',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as integ from '@aws-cdk/integ-tests-alpha';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import { LambdaIntegration, RestApi } from 'aws-cdk-lib/aws-apigateway';
import { App, Stack } from 'aws-cdk-lib';
import { STANDARD_NODEJS_RUNTIME } from '../../config';

const app = new App();

Expand All @@ -10,7 +11,7 @@ const stack = new Stack(app, 'aws-cdk-lambda-1');
const fn = new lambda.Function(stack, 'MyLambda', {
code: new lambda.InlineCode('foo'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_16_X,
runtime: STANDARD_NODEJS_RUNTIME,
});

const apigw = new RestApi(stack, 'MyRestApi', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@ import * as lambda from 'aws-cdk-lib/aws-lambda';
import * as cdk from 'aws-cdk-lib';
import { IntegTest } from '@aws-cdk/integ-tests-alpha';
import * as apigw from 'aws-cdk-lib/aws-apigateway';
import { STANDARD_NODEJS_RUNTIME } from '../../config';

class BookStack extends cdk.Stack {
constructor(scope: cdk.App, id: string) {
super(scope, id);

const booksHandler = new apigw.LambdaIntegration(new lambda.Function(this, 'BooksHandler', {
runtime: lambda.Runtime.NODEJS_16_X,
runtime: STANDARD_NODEJS_RUNTIME,
handler: 'index.handler',
code: lambda.Code.fromInline(`exports.handler = ${echoHandlerCode}`),
}));

const bookHandler = new apigw.LambdaIntegration(new lambda.Function(this, 'BookHandler', {
runtime: lambda.Runtime.NODEJS_16_X,
runtime: STANDARD_NODEJS_RUNTIME,
handler: 'index.handler',
code: lambda.Code.fromInline(`exports.handler = ${echoHandlerCode}`),
}));

const hello = new apigw.LambdaIntegration(new lambda.Function(this, 'Hello', {
runtime: lambda.Runtime.NODEJS_16_X,
runtime: STANDARD_NODEJS_RUNTIME,
handler: 'index.handler',
code: lambda.Code.fromInline(`exports.handler = ${helloCode}`),
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as cdk from 'aws-cdk-lib';
import { IntegTest } from '@aws-cdk/integ-tests-alpha';
import * as constructs from 'constructs';
import * as apig from 'aws-cdk-lib/aws-apigateway';
import { STANDARD_NODEJS_RUNTIME } from '../../config';

class FirstStack extends cdk.Stack {
public readonly firstLambda: lambda.Function;
Expand All @@ -19,7 +20,7 @@ class FirstStack extends cdk.Stack {
}
}`),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_16_X,
runtime: STANDARD_NODEJS_RUNTIME,
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import * as lambda from 'aws-cdk-lib/aws-lambda';
import * as cdk from 'aws-cdk-lib';
import { IntegTest } from '@aws-cdk/integ-tests-alpha';
import * as apigw from 'aws-cdk-lib/aws-apigateway';
import { STANDARD_NODEJS_RUNTIME } from '../../config';

class MultiStack extends cdk.Stack {
constructor(scope: cdk.App, id: string) {
super(scope, id);

const hello = new apigw.LambdaIntegration(new lambda.Function(this, 'Hello', {
runtime: lambda.Runtime.NODEJS_16_X,
runtime: STANDARD_NODEJS_RUNTIME,
handler: 'index.handler',
code: lambda.Code.fromInline(`exports.handler = ${helloCode}`),
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as cdk from 'aws-cdk-lib';
import { Size } from 'aws-cdk-lib';
import { IntegTest } from '@aws-cdk/integ-tests-alpha';
import * as apigateway from 'aws-cdk-lib/aws-apigateway';
import { STANDARD_NODEJS_RUNTIME } from '../../config';

class Test extends cdk.Stack {
constructor(scope: cdk.App, id: string) {
Expand All @@ -28,7 +29,7 @@ class Test extends cdk.Stack {
});

const handler = new lambda.Function(this, 'MyHandler', {
runtime: lambda.Runtime.NODEJS_16_X,
runtime: STANDARD_NODEJS_RUNTIME,
code: lambda.Code.fromInline(`exports.handler = ${handlerCode}`),
handler: 'index.handler',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as cdk from 'aws-cdk-lib';
import { Size } from 'aws-cdk-lib';
import { IntegTest } from '@aws-cdk/integ-tests-alpha';
import * as apigateway from 'aws-cdk-lib/aws-apigateway';
import { STANDARD_NODEJS_RUNTIME } from '../../config';

class Test extends cdk.Stack {
constructor(scope: cdk.App, id: string) {
Expand All @@ -30,7 +31,7 @@ class Test extends cdk.Stack {
});

const handler = new lambda.Function(this, 'MyHandler', {
runtime: lambda.Runtime.NODEJS_16_X,
runtime: STANDARD_NODEJS_RUNTIME,
code: lambda.Code.fromInline(`exports.handler = ${handlerCode}`),
handler: 'index.handler',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as path from 'path';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import * as cdk from 'aws-cdk-lib';
import * as appsync from 'aws-cdk-lib/aws-appsync';
import { STANDARD_NODEJS_RUNTIME } from '../../config';

/*
* Creates an Appsync GraphQL API and schema in a code-first approach.
Expand All @@ -29,7 +30,7 @@ const api = new appsync.GraphqlApi(stack, 'LambdaAPI', {
const func = new lambda.Function(stack, 'func', {
code: lambda.Code.fromAsset(path.join(__dirname, 'verify/lambda-tutorial')),
handler: 'lambda-tutorial.handler',
runtime: lambda.Runtime.NODEJS_16_X,
runtime: STANDARD_NODEJS_RUNTIME,
});

const lambdaDS = api.addLambdaDataSource('LambdaDS', func);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { join } from 'path';
import { UserPool } from 'aws-cdk-lib/aws-cognito';
import { AttributeType, BillingMode, Table } from 'aws-cdk-lib/aws-dynamodb';
import { Role, ServicePrincipal } from 'aws-cdk-lib/aws-iam';
import { Code, Function, Runtime } from 'aws-cdk-lib/aws-lambda';
import { Code, Function } from 'aws-cdk-lib/aws-lambda';
import { App, RemovalPolicy, Stack } from 'aws-cdk-lib';
import {
AuthorizationType,
Expand All @@ -14,6 +14,7 @@ import {
IamResource,
SchemaFile,
} from 'aws-cdk-lib/aws-appsync';
import { STANDARD_NODEJS_RUNTIME } from '../../config';

/*
* Creates an Appsync GraphQL API and Lambda with IAM Roles.
Expand Down Expand Up @@ -96,14 +97,14 @@ api.grantMutation(lambdaIAM, 'addTest');
new Function(stack, 'testQuery', {
code: Code.fromAsset(join(__dirname, 'verify/iam-query')),
handler: 'iam-query.handler',
runtime: Runtime.NODEJS_16_X,
runtime: STANDARD_NODEJS_RUNTIME,
environment: { APPSYNC_ENDPOINT: api.graphqlUrl },
role: lambdaIAM,
});
new Function(stack, 'testFail', {
code: Code.fromAsset(join(__dirname, 'verify/iam-query')),
handler: 'iam-query.handler',
runtime: Runtime.NODEJS_16_X,
runtime: STANDARD_NODEJS_RUNTIME,
environment: { APPSYNC_ENDPOINT: api.graphqlUrl },
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as cdk from 'aws-cdk-lib';
import { IntegTest } from '@aws-cdk/integ-tests-alpha';
import { Construct } from 'constructs';
import * as appsync from 'aws-cdk-lib/aws-appsync';
import { STANDARD_NODEJS_RUNTIME } from '../../config';

class GraphQLApiLambdaAuthStack extends cdk.Stack {
constructor(scope: Construct) {
Expand All @@ -14,7 +15,7 @@ class GraphQLApiLambdaAuthStack extends cdk.Stack {
path.join(__dirname, 'verify/lambda-tutorial'),
),
handler: 'lambda-tutorial.handler',
runtime: lambda.Runtime.NODEJS_16_X,
runtime: STANDARD_NODEJS_RUNTIME,
});

new appsync.GraphqlApi(this, 'api1', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
* - GetAtt.Attribute1: "foo"
* - GetAtt.Attribute2: 1234
*/
import { App, CfnOutput, CustomResource, CustomResourceProvider, CustomResourceProviderRuntime, Stack, Token } from 'aws-cdk-lib';
import { App, CfnOutput, CustomResource, CustomResourceProvider, Stack, Token } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { STANDARD_CUSTOM_RESOURCE_PROVIDER_RUNTIME } from '../../config';

/* eslint-disable @aws-cdk/no-core-construct */

Expand All @@ -20,7 +21,7 @@ class TestStack extends Stack {

const serviceToken = CustomResourceProvider.getOrCreate(this, resourceType, {
codeDirectory: `${__dirname}/core-custom-resource-provider-fixture`,
runtime: CustomResourceProviderRuntime.NODEJS_16_X,
runtime: STANDARD_CUSTOM_RESOURCE_PROVIDER_RUNTIME,
description: 'veni vidi vici',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ import { RetentionDays } from 'aws-cdk-lib/aws-logs';
import { App, Stack, CfnResource, NestedStack } from 'aws-cdk-lib';
import * as integ from '@aws-cdk/integ-tests-alpha';
import { Construct } from 'constructs';
import { STANDARD_NODEJS_RUNTIME } from '../../config';

class TestStack extends Stack {
constructor(scope: Construct, id: string) {
super(scope, id);
new lambda.Function(this, 'MyLambda', {
code: new lambda.InlineCode('foo'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_16_X,
runtime: STANDARD_NODEJS_RUNTIME,
logRetention: RetentionDays.ONE_DAY,
});
const logRetentionFunction = this.node.tryFindChild('LogRetentionaae0aa3c5b4d4f87b02d85b201efdd8a')!;
Expand All @@ -47,12 +48,12 @@ class TestNestedStack extends Stack {
const resource1 = new lambda.Function(stack1, 'Lambda1', {
code: new lambda.InlineCode('foo'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_16_X,
runtime: STANDARD_NODEJS_RUNTIME,
}).node.defaultChild! as CfnResource;
const resource2 = new lambda.Function(stack2, 'Lambda2', {
code: new lambda.InlineCode('foo'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_16_X,
runtime: STANDARD_NODEJS_RUNTIME,
}).node.defaultChild! as CfnResource;

// The following two statements should cancel each other out
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as sns_subscriptions from 'aws-cdk-lib/aws-sns-subscriptions';
import * as sqs from 'aws-cdk-lib/aws-sqs';
import { App, CfnParameter, NestedStack, Stack } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { STANDARD_NODEJS_RUNTIME } from '../../config';

/* eslint-disable @aws-cdk/no-core-construct */

Expand Down Expand Up @@ -40,7 +41,7 @@ class MyNestedStack extends NestedStack {

if (props.subscriber) {
new lambda.Function(this, 'fn', {
runtime: lambda.Runtime.NODEJS_16_X,
runtime: STANDARD_NODEJS_RUNTIME,
code: lambda.Code.fromInline('console.error("hi")'),
handler: 'index.handler',
environment: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as path from 'path';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import { App, NestedStack, Stack } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { STANDARD_NODEJS_RUNTIME } from '../../config';

/* eslint-disable @aws-cdk/no-core-construct */

Expand All @@ -11,7 +12,7 @@ class MyNestedStack extends NestedStack {

new lambda.Function(this, 'Handler', {
code: lambda.Code.fromAsset(path.join(__dirname, 'asset-directory-fixture')),
runtime: lambda.Runtime.NODEJS_16_X,
runtime: STANDARD_NODEJS_RUNTIME,
handler: 'index.handler',
});
}
Expand Down
Loading

0 comments on commit 7d8dca2

Please sign in to comment.