-
Notifications
You must be signed in to change notification settings - Fork 210
Expand file tree
/
Copy pathintegration.test.ts
More file actions
85 lines (70 loc) · 3.13 KB
/
Copy pathintegration.test.ts
File metadata and controls
85 lines (70 loc) · 3.13 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
78
79
80
81
82
83
84
85
import {WriteStreamsMock} from "../../../src/write-streams";
import {handler} from "../../../src/handler";
import {initSpawnSpy, initSpawnSpyReject} from "../../mocks/utils.mock";
import {WhenStatics} from "../../mocks/when-statics";
describe("dependency-proxy", () => {
beforeEach(() => {
initSpawnSpy(WhenStatics.all);
});
describe("dependency proxy server not authenticated", () => {
test("podman", async () => {
initSpawnSpyReject([
{
cmdArgs: "podman login gitlab.com:443".split(" "),
rejection: {
stderr: "Username: Error: getting username and password: reading username: EOF",
},
},
]);
try {
const writeStreams = new WriteStreamsMock();
await handler({
cwd: "tests/test-cases/dependency-proxy",
containerExecutable: "podman",
}, writeStreams);
} 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("docker", async () => {
initSpawnSpyReject([
{
cmdArgs: "docker login gitlab.com:443".split(" "),
rejection: {
stderr: "Cannot perform an interactive login from a non TTY device",
},
},
]);
try {
const writeStreams = new WriteStreamsMock();
await handler({
cwd: "tests/test-cases/dependency-proxy",
}, writeStreams);
} 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([...WhenStatics.all, ciDependencyProxyServerAuthenticated]);
try {
await handler({
cwd: "tests/test-cases/dependency-proxy",
}, writeStreams);
} 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.command).toEqual("docker pull gitlab.com:443/gcl/dependency_proxy/containers/busybox:latest");
return;
}
throw new Error("Error is expected but not thrown/caught");
});
});