forked from CycloneDX/cdxgen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker.test.js
119 lines (115 loc) · 2.75 KB
/
docker.test.js
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import {
getConnection,
parseImageName,
getImage,
removeImage,
exportImage,
isWin
} from "./docker.js";
import { expect, test } from "@jest/globals";
test("docker connection", async () => {
if (!(isWin && process.env.CI === "true")) {
const dockerConn = await getConnection();
expect(dockerConn);
}
}, 120000);
test("parseImageName tests", () => {
if (isWin && process.env.CI === "true") {
return;
}
expect(parseImageName("debian")).toEqual({
registry: "",
repo: "debian",
tag: "",
digest: "",
platform: "",
group: "",
name: "debian"
});
expect(parseImageName("debian:latest")).toEqual({
registry: "",
repo: "debian",
tag: "latest",
digest: "",
platform: "",
group: "",
name: "debian"
});
expect(parseImageName("library/debian:latest")).toEqual({
registry: "",
repo: "library/debian",
tag: "latest",
digest: "",
platform: "",
group: "library",
name: "debian"
});
expect(parseImageName("shiftleft/scan:v1.15.6")).toEqual({
registry: "",
repo: "shiftleft/scan",
tag: "v1.15.6",
digest: "",
platform: "",
group: "shiftleft",
name: "scan"
});
expect(parseImageName("localhost:5000/shiftleft/scan:v1.15.6")).toEqual({
registry: "localhost:5000",
repo: "shiftleft/scan",
tag: "v1.15.6",
digest: "",
platform: "",
group: "shiftleft",
name: "scan"
});
expect(parseImageName("localhost:5000/shiftleft/scan")).toEqual({
registry: "localhost:5000",
repo: "shiftleft/scan",
tag: "",
digest: "",
platform: "",
group: "shiftleft",
name: "scan"
});
expect(
parseImageName("foocorp.jfrog.io/docker/library/eclipse-temurin:latest")
).toEqual({
registry: "foocorp.jfrog.io",
repo: "docker/library/eclipse-temurin",
tag: "latest",
digest: "",
platform: "",
group: "docker/library",
name: "eclipse-temurin"
});
expect(
parseImageName(
"quay.io/shiftleft/scan-java@sha256:5d008306a7c5d09ba0161a3408fa3839dc2c9dd991ffb68adecc1040399fe9e1"
)
).toEqual({
registry: "quay.io",
repo: "shiftleft/scan-java",
tag: "",
digest: "5d008306a7c5d09ba0161a3408fa3839dc2c9dd991ffb68adecc1040399fe9e1",
platform: "",
group: "shiftleft",
name: "scan-java"
});
}, 120000);
test("docker getImage", async () => {
if (isWin && process.env.CI === "true") {
return;
}
const imageData = await getImage("hello-world:latest");
if (imageData) {
const removeData = await removeImage("hello-world:latest");
expect(removeData);
}
}, 120000);
test("docker getImage", async () => {
if (isWin && process.env.CI === "true") {
return;
}
const imageData = await exportImage("hello-world:latest");
expect(imageData);
}, 120000);