-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathupdater-builder-integration.test.ts
More file actions
77 lines (68 loc) · 2.15 KB
/
updater-builder-integration.test.ts
File metadata and controls
77 lines (68 loc) · 2.15 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import {updaterImageName, PROXY_IMAGE_NAME} from '../src/docker-tags'
import {ImageService} from '../src/image-service'
import {removeDanglingUpdaterContainers, integration} from './helpers'
import Docker from 'dockerode'
import {Credential, JobDetails} from '../src/api-client'
import {ProxyBuilder} from '../src/proxy'
import {JobParameters} from '../src/inputs'
import {UpdaterBuilder} from '../src/updater-builder'
integration('UpdaterBuilder', () => {
const docker = new Docker()
const dependabotApiUrl = `http://localhost:9000`
const jobToken = 'xxxyyyzzzz'
const credentials: Credential[] = [
{
type: 'git_source',
host: 'github.com',
username: 'x-access-token',
password: 'ghp_some_token'
}
]
const details: JobDetails = {
'allowed-updates': [],
'credentials-metadata': [],
id: '1',
'package-manager': 'npm_and_yarn',
experiments: {}
}
beforeAll(async () => {
await ImageService.pull(PROXY_IMAGE_NAME)
await ImageService.pull(updaterImageName('bundler'))
})
afterEach(async () => {
await removeDanglingUpdaterContainers()
})
it('createUpdaterContainer returns a container only connected to the internal network', async () => {
const proxy = await new ProxyBuilder(docker, PROXY_IMAGE_NAME).run(
1,
jobToken,
dependabotApiUrl,
credentials
)
await proxy.container.start()
const input = {job: details}
const params = new JobParameters(
1,
'job-token',
'cred-token',
'https://example.com',
'172.17.0.1',
updaterImageName('bundler')
)
const container = await new UpdaterBuilder(
docker,
params,
input,
proxy,
updaterImageName('bundler')
).run('updater-image-test')
const containerInfo = await container.inspect()
const networkNames = Object.keys(containerInfo.NetworkSettings.Networks)
expect(networkNames).toEqual(['dependabot-job-1-internal-network'])
const network = docker.getNetwork(networkNames[0])
const networkInfo = await network.inspect()
expect(networkInfo.Internal).toBe(true)
await proxy.shutdown()
await container.remove()
}, 15000)
})