Skip to content

Commit b1dfdd2

Browse files
authored
chore: revert proxy traversal integ test (#33139)
Reverts #33092 This test hadn't gone through the testing pipeline successfully yet.
1 parent 49fa74f commit b1dfdd2

File tree

7 files changed

+56
-228
lines changed

7 files changed

+56
-228
lines changed

packages/@aws-cdk-testing/cli-integ/lib/package-sources/release-source.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ import { shell, rimraf, addToShellPath } from '../shell';
77

88
export class ReleasePackageSourceSetup implements IPackageSourceSetup {
99
readonly name = 'release';
10-
readonly description: string;
10+
readonly description = `release @ ${this.version}`;
1111

1212
private tempDir?: string;
1313

1414
constructor(private readonly version: string, private readonly frameworkVersion?: string) {
15-
this.description = `release @ ${this.version}`;
1615
}
1716

1817
public async prepare(): Promise<void> {

packages/@aws-cdk-testing/cli-integ/lib/package-sources/repo-source.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ import { shell, addToShellPath } from '../shell';
77

88
export class RepoPackageSourceSetup implements IPackageSourceSetup {
99
readonly name = 'repo';
10-
readonly description: string;
10+
readonly description = `repo(${this.repoRoot})`;
1111

1212
constructor(private readonly repoRoot: string) {
13-
this.description = `repo(${this.repoRoot})`;
1413
}
1514

1615
public async prepare(): Promise<void> {

packages/@aws-cdk-testing/cli-integ/lib/proxy.ts

Lines changed: 0 additions & 62 deletions
This file was deleted.

packages/@aws-cdk-testing/cli-integ/lib/with-cdk-app.ts

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ export interface CdkGarbageCollectionCommandOptions {
321321
}
322322

323323
export class TestFixture extends ShellHelper {
324-
public readonly qualifier: string;
324+
public readonly qualifier = this.randomString.slice(0, 10);
325325
private readonly bucketsToDelete = new Array<string>();
326326
public readonly packages: IPackageSource;
327327

@@ -334,7 +334,6 @@ export class TestFixture extends ShellHelper {
334334

335335
super(integTestDir, output);
336336

337-
this.qualifier = this.randomString.slice(0, 10);
338337
this.packages = packageSourceInSubprocess();
339338
}
340339

@@ -343,22 +342,16 @@ export class TestFixture extends ShellHelper {
343342
}
344343

345344
public async cdkDeploy(stackNames: string | string[], options: CdkCliOptions = {}, skipStackRename?: boolean) {
346-
return this.cdk(this.cdkDeployCommandLine(stackNames, options, skipStackRename));
347-
}
348-
349-
public cdkDeployCommandLine(stackNames: string | string[], options: CdkCliOptions = {}, skipStackRename?: boolean) {
350345
stackNames = typeof stackNames === 'string' ? [stackNames] : stackNames;
346+
351347
const neverRequireApproval = options.neverRequireApproval ?? true;
352348

353-
return [
354-
'deploy',
349+
return this.cdk(['deploy',
355350
...(neverRequireApproval ? ['--require-approval=never'] : []), // Default to no approval in an unattended test
356351
...(options.options ?? []),
357-
...(options.verbose ? ['-v'] : []),
358352
// use events because bar renders bad in tests
359353
'--progress', 'events',
360-
...(skipStackRename ? stackNames : this.fullStackName(stackNames)),
361-
];
354+
...(skipStackRename ? stackNames : this.fullStackName(stackNames))], options);
362355
}
363356

364357
public async cdkSynth(options: CdkCliOptions = {}) {
@@ -508,24 +501,15 @@ export class TestFixture extends ShellHelper {
508501
return this.shell(['cdk', ...(verbose ? ['-v'] : []), ...args], {
509502
...options,
510503
modEnv: {
511-
...this.cdkShellEnv(),
504+
AWS_REGION: this.aws.region,
505+
AWS_DEFAULT_REGION: this.aws.region,
506+
STACK_NAME_PREFIX: this.stackNamePrefix,
507+
PACKAGE_LAYOUT_VERSION: this.packages.majorVersion(),
512508
...options.modEnv,
513509
},
514510
});
515511
}
516512

517-
/**
518-
* Return the environment variables with which to execute CDK
519-
*/
520-
public cdkShellEnv() {
521-
return {
522-
AWS_REGION: this.aws.region,
523-
AWS_DEFAULT_REGION: this.aws.region,
524-
STACK_NAME_PREFIX: this.stackNamePrefix,
525-
PACKAGE_LAYOUT_VERSION: this.packages.majorVersion(),
526-
};
527-
}
528-
529513
public template(stackName: string): any {
530514
const fullStackName = this.fullStackName(stackName);
531515
const templatePath = path.join(this.integTestDir, 'cdk.out', `${fullStackName}.template.json`);

packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { existsSync, promises as fs } from 'fs';
2+
import * as querystring from 'node:querystring';
23
import * as os from 'os';
34
import * as path from 'path';
45
import {
@@ -22,6 +23,8 @@ import { InvokeCommand } from '@aws-sdk/client-lambda';
2223
import { PutObjectLockConfigurationCommand } from '@aws-sdk/client-s3';
2324
import { CreateTopicCommand, DeleteTopicCommand } from '@aws-sdk/client-sns';
2425
import { AssumeRoleCommand, GetCallerIdentityCommand } from '@aws-sdk/client-sts';
26+
import * as mockttp from 'mockttp';
27+
import { CompletedRequest } from 'mockttp';
2528
import {
2629
cloneDirectory,
2730
integTest,
@@ -38,7 +41,6 @@ import {
3841
withSamIntegrationFixture,
3942
withSpecificFixture,
4043
} from '../../lib';
41-
import { awsActionsFromRequests, startProxyServer } from '../../lib/proxy';
4244

4345
jest.setTimeout(2 * 60 * 60_000); // Includes the time to acquire locks, worst-case single-threaded runtime
4446

@@ -2875,29 +2877,60 @@ integTest('cdk notices are displayed correctly', withDefaultFixture(async (fixtu
28752877

28762878
integTest('requests go through a proxy when configured',
28772879
withDefaultFixture(async (fixture) => {
2878-
const proxyServer = await startProxyServer();
2880+
// Set up key and certificate
2881+
const { key, cert } = await mockttp.generateCACertificate();
2882+
const certDir = await fs.mkdtemp(path.join(os.tmpdir(), 'cdk-'));
2883+
const certPath = path.join(certDir, 'cert.pem');
2884+
const keyPath = path.join(certDir, 'key.pem');
2885+
await fs.writeFile(keyPath, key);
2886+
await fs.writeFile(certPath, cert);
2887+
2888+
const proxyServer = mockttp.getLocal({
2889+
https: { keyPath, certPath },
2890+
});
2891+
2892+
// We don't need to modify any request, so the proxy
2893+
// passes through all requests to the target host.
2894+
const endpoint = await proxyServer
2895+
.forAnyRequest()
2896+
.thenPassThrough();
2897+
2898+
proxyServer.enableDebug();
2899+
await proxyServer.start();
2900+
2901+
// The proxy is now ready to intercept requests
2902+
28792903
try {
28802904
await fixture.cdkDeploy('test-2', {
28812905
captureStderr: true,
28822906
options: [
28832907
'--proxy', proxyServer.url,
2884-
'--ca-bundle-path', proxyServer.certPath,
2908+
'--ca-bundle-path', certPath,
28852909
],
28862910
modEnv: {
28872911
CDK_HOME: fixture.integTestDir,
28882912
},
28892913
});
2890-
2891-
const requests = await proxyServer.getSeenRequests();
2892-
2893-
expect(requests.map(req => req.url))
2894-
.toContain('https://cli.cdk.dev-tools.aws.dev/notices.json');
2895-
2896-
const actionsUsed = awsActionsFromRequests(requests);
2897-
expect(actionsUsed).toContain('AssumeRole');
2898-
expect(actionsUsed).toContain('CreateChangeSet');
28992914
} finally {
2915+
await fs.rm(certDir, { recursive: true, force: true });
29002916
await proxyServer.stop();
29012917
}
2918+
2919+
const requests = await endpoint.getSeenRequests();
2920+
2921+
expect(requests.map(req => req.url))
2922+
.toContain('https://cli.cdk.dev-tools.aws.dev/notices.json');
2923+
2924+
const actionsUsed = actions(requests);
2925+
expect(actionsUsed).toContain('AssumeRole');
2926+
expect(actionsUsed).toContain('CreateChangeSet');
29022927
}),
29032928
);
2929+
2930+
function actions(requests: CompletedRequest[]): string[] {
2931+
return [...new Set(requests
2932+
.map(req => req.body.buffer.toString('utf-8'))
2933+
.map(body => querystring.decode(body))
2934+
.map(x => x.Action as string)
2935+
.filter(action => action != null))];
2936+
}

packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/proxy.integtest.ts

Lines changed: 0 additions & 125 deletions
This file was deleted.

packages/@aws-cdk-testing/cli-integ/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"compilerOptions": {
33
"target": "ES2020",
44
"module": "commonjs",
5-
"lib": ["ES2020", "dom"],
5+
"lib": ["es2019", "es2020", "dom"],
66
"strict": true,
77
"alwaysStrict": true,
88
"declaration": true,

0 commit comments

Comments
 (0)