-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add dependency proxy variables
- Loading branch information
Showing
5 changed files
with
96 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
job: | ||
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/busybox:latest | ||
script: | ||
- echo 1 |
66 changes: 66 additions & 0 deletions
66
tests/test-cases/dependency-proxy/integration.dependency-proxy.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import {WriteStreamsMock} from "../../../src/write-streams"; | ||
import {handler} from "../../../src/handler"; | ||
// import chalk from "chalk"; | ||
import {initSpawnSpy, initSpawnSpyReject} from "../../mocks/utils.mock"; | ||
import {WhenStatics} from "../../mocks/when-statics"; | ||
import {cleanupJobResources, Job} from "../../../src/job"; | ||
import {Utils} from "../../../src/utils"; | ||
import {type} from "os"; | ||
|
||
let jobs: Job[] = []; | ||
|
||
beforeEach(() => { | ||
jobs = []; | ||
initSpawnSpy(WhenStatics.all); | ||
}); | ||
|
||
afterEach(async () => { | ||
await cleanupJobResources(jobs); | ||
}); | ||
|
||
describe("dependency-proxy", () => { | ||
test("dependency proxy server not authenticated", async () => { | ||
try { | ||
const writeStreams = new WriteStreamsMock(); | ||
// const ciDependencyProxyServerNotAuthenticated = { | ||
// cmdArgs: "docker login gitlab.com:443".split(" "), | ||
// rejection: { | ||
// stderr: "Error: Cannot perform an interactive login from a non TTY device", | ||
// }, | ||
// }; | ||
// initSpawnSpyReject([ciDependencyProxyServerNotAuthenticated]); | ||
|
||
await handler({ | ||
cwd: "tests/test-cases/dependency-proxy", | ||
}, writeStreams, jobs); | ||
|
||
} catch (e: any) { | ||
expect(e.message).toEqual("Please authenticate to the Dependency Proxy (gitlab.com:443) https://docs.gitlab.com/ee/user/packages/dependency_proxy/#authenticate-with-the-dependency-proxy"); | ||
return; | ||
} | ||
throw new Error("Error is expected but not thrown/caught"); | ||
}); | ||
|
||
test("should attempt to pull the correct image", async () => { | ||
const writeStreams = new WriteStreamsMock(); | ||
|
||
const ciDependencyProxyServerAuthenticated = { | ||
cmdArgs: "docker login gitlab.com:443".split(" "), | ||
returnValue: "Login Succeeded", | ||
}; | ||
initSpawnSpy([ciDependencyProxyServerAuthenticated]); | ||
|
||
try { | ||
await handler({ | ||
cwd: "tests/test-cases/dependency-proxy", | ||
}, writeStreams, jobs); | ||
} catch (e: any) { | ||
// In ci environment, gitlab.com:443 is not authenticated, but at least this shows that we're pulling from the correct path | ||
expect(e.shortMessage).toEqual("Command failed with exit code 1: docker pull gitlab.com:443/gcl/dependency_proxy/containers/busybox:latest"); | ||
return; | ||
} | ||
throw new Error("Error is expected but not thrown/caught"); | ||
|
||
}); | ||
|
||
}); |