@cyclonedx/cdxgen 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docker.test.js ADDED
@@ -0,0 +1,72 @@
1
+ const dockerLib = require("./docker");
2
+
3
+ test("docker connection", async () => {
4
+ const dockerConn = await dockerLib.getConnection();
5
+ expect(dockerConn);
6
+ });
7
+
8
+ test("parseImageName tests", () => {
9
+ expect(dockerLib.parseImageName("debian")).toEqual({
10
+ registry: "",
11
+ repo: "debian",
12
+ tag: "",
13
+ digest: "",
14
+ platform: ""
15
+ });
16
+ expect(dockerLib.parseImageName("debian:latest")).toEqual({
17
+ registry: "",
18
+ repo: "debian",
19
+ tag: "latest",
20
+ digest: "",
21
+ platform: ""
22
+ });
23
+ expect(dockerLib.parseImageName("shiftleft/scan:v1.15.6")).toEqual({
24
+ registry: "",
25
+ repo: "shiftleft/scan",
26
+ tag: "v1.15.6",
27
+ digest: "",
28
+ platform: ""
29
+ });
30
+ expect(
31
+ dockerLib.parseImageName("localhost:5000/shiftleft/scan:v1.15.6")
32
+ ).toEqual({
33
+ registry: "localhost:5000",
34
+ repo: "shiftleft/scan",
35
+ tag: "v1.15.6",
36
+ digest: "",
37
+ platform: ""
38
+ });
39
+ expect(dockerLib.parseImageName("localhost:5000/shiftleft/scan")).toEqual({
40
+ registry: "localhost:5000",
41
+ repo: "shiftleft/scan",
42
+ tag: "",
43
+ digest: "",
44
+ platform: ""
45
+ });
46
+ expect(
47
+ dockerLib.parseImageName(
48
+ "quay.io/shiftleft/scan-java@sha256:5d008306a7c5d09ba0161a3408fa3839dc2c9dd991ffb68adecc1040399fe9e1"
49
+ )
50
+ ).toEqual({
51
+ registry: "quay.io",
52
+ repo: "shiftleft/scan-java",
53
+ tag: "",
54
+ digest: "5d008306a7c5d09ba0161a3408fa3839dc2c9dd991ffb68adecc1040399fe9e1",
55
+ platform: ""
56
+ });
57
+ });
58
+
59
+ test("docker getImage", async () => {
60
+ jest.setTimeout(120000);
61
+ const imageData = await dockerLib.getImage("hello-world:latest");
62
+ if (imageData) {
63
+ const removeData = await dockerLib.removeImage("hello-world:latest");
64
+ expect(removeData);
65
+ }
66
+ });
67
+
68
+ test("docker getImage", async () => {
69
+ jest.setTimeout(120000);
70
+ const imageData = await dockerLib.exportImage("hello-world:latest");
71
+ expect(imageData);
72
+ });