generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathcdk-requests-go-through-a-proxy-when-configured.integtest.ts
More file actions
56 lines (47 loc) · 2.02 KB
/
cdk-requests-go-through-a-proxy-when-configured.integtest.ts
File metadata and controls
56 lines (47 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { promises as fs } from 'fs';
import * as path from 'path';
import { integTest, withDefaultFixture } from '../../../lib';
import { awsActionsFromRequests, startProxyServer } from '../../../lib/proxy';
jest.setTimeout(2 * 60 * 60_000); // Includes the time to acquire locks, worst-case single-threaded runtime
integTest('requests go through a proxy when configured',
withDefaultFixture(async (fixture) => {
const proxyServer = await startProxyServer();
try {
// Matches CDK_HOME below.
const cdkCacheDir = path.join(fixture.integTestDir, 'cache');
// Delete notices cache if it exists
await fs.rm(path.join(cdkCacheDir, 'notices.json'), { force: true });
// Delete connection cache if it exists
await fs.rm(path.join(cdkCacheDir, 'connection.json'), { force: true });
await fixture.cdkDeploy('test-2', {
captureStderr: true,
options: [
'--proxy', proxyServer.url,
'--ca-bundle-path', proxyServer.certPath,
],
modEnv: {
CDK_HOME: fixture.integTestDir,
},
});
const connections = JSON.parse(await fs.readFile(path.join(cdkCacheDir, 'connection.json'), 'utf8'));
// eslint-disable-next-line no-console
console.log('connections', connections);
const requests = await proxyServer.getSeenRequests();
const urls = requests.map(req => req.url);
// eslint-disable-next-line no-console
console.log('1', JSON.stringify(urls));
// eslint-disable-next-line no-console
console.log('2', JSON.stringify(urls.reverse()));
const urls2 = urls.filter(u => u.startsWith('https://cli.cdk.dev'));
// eslint-disable-next-line no-console
console.log('3', urls2);
expect(urls)
.toContain('https://cli.cdk.dev-tools.aws.dev/notices.json');
const actionsUsed = awsActionsFromRequests(requests);
expect(actionsUsed).toContain('AssumeRole');
expect(actionsUsed).toContain('CreateChangeSet');
} finally {
await proxyServer.stop();
}
}),
);