|
| 1 | +import { spawnSync } from 'child_process' |
1 | 2 | import Docker from 'dockerode' |
2 | | -import {Credential} from '../src/api-client' |
3 | | -import {ImageService} from '../src/image-service' |
4 | | -import {PROXY_IMAGE_NAME} from '../src/docker-tags' |
5 | | -import {ProxyBuilder} from '../src/proxy' |
6 | | -import {integration, removeDanglingUpdaterContainers} from './helpers' |
7 | | -import {spawnSync} from 'child_process' |
8 | 3 | import fs from 'fs' |
9 | 4 | import path from 'path' |
| 5 | +import { Credential } from '../src/api-client' |
| 6 | +import { PROXY_IMAGE_NAME } from '../src/docker-tags' |
| 7 | +import { ImageService } from '../src/image-service' |
| 8 | +import { ProxyBuilder } from '../src/proxy' |
| 9 | +import { integration, removeDanglingUpdaterContainers } from './helpers' |
10 | 10 |
|
11 | 11 | integration('ProxyBuilder', () => { |
12 | 12 | const docker = new Docker() |
@@ -182,4 +182,46 @@ integration('ProxyBuilder', () => { |
182 | 182 | const output = proc.stdout.toString().trim() |
183 | 183 | expect(output).toEqual(url) |
184 | 184 | }) |
| 185 | + |
| 186 | + jest.setTimeout(20000) |
| 187 | + it('forwards OIDC token request URL if configured', async () => { |
| 188 | + const url = 'https://vstoken.actions.githubusercontent.com/_apis/distributedtask/hubs/build/plans/123/jobs/456/oidctoken' |
| 189 | + process.env.ACTIONS_ID_TOKEN_REQUEST_URL = url |
| 190 | + |
| 191 | + const proxy = await builder.run( |
| 192 | + jobId, |
| 193 | + jobToken, |
| 194 | + dependabotApiUrl, |
| 195 | + credentials |
| 196 | + ) |
| 197 | + await proxy.container.start() |
| 198 | + |
| 199 | + const id = proxy.container.id |
| 200 | + const proc = spawnSync('docker', ['exec', id, 'printenv', 'ACTIONS_ID_TOKEN_REQUEST_URL']) |
| 201 | + const output = proc.stdout.toString().trim() |
| 202 | + expect(output).toEqual(url) |
| 203 | + |
| 204 | + await proxy.shutdown() |
| 205 | + }) |
| 206 | + |
| 207 | + jest.setTimeout(20000) |
| 208 | + it('forwards OIDC token request token if configured', async () => { |
| 209 | + const token = 'e30=' |
| 210 | + process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN = token |
| 211 | + |
| 212 | + const proxy = await builder.run( |
| 213 | + jobId, |
| 214 | + jobToken, |
| 215 | + dependabotApiUrl, |
| 216 | + credentials |
| 217 | + ) |
| 218 | + await proxy.container.start() |
| 219 | + |
| 220 | + const id = proxy.container.id |
| 221 | + const proc = spawnSync('docker', ['exec', id, 'printenv', 'ACTIONS_ID_TOKEN_REQUEST_TOKEN']) |
| 222 | + const output = proc.stdout.toString().trim() |
| 223 | + expect(output).toEqual(token) |
| 224 | + |
| 225 | + await proxy.shutdown() |
| 226 | + }) |
185 | 227 | }) |
0 commit comments