Skip to content

Commit 443b7d7

Browse files
committed
test(cli): Implemented cli sbom submission
- with test cases for submitting sbom to dependency-track with project tags for explicitely given project or child project (given parent project ID) Signed-off-by: Günter Schafranek <[email protected]>
1 parent 13e5886 commit 443b7d7

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/cli/index.poku.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ describe("CLI tests", () => {
6161
assert.deepEqual(options.json, expectedRequestPayload);
6262
});
6363

64-
it("should successfully report the SBOM with given parent project, name, version and multiple single tags", async () => {
64+
it("should successfully report the SBOM with given parent project, name, version and multiple tags", async () => {
6565
const fakeGotResponse = {
6666
json: sinon.stub().resolves({ success: true }),
6767
};
@@ -75,22 +75,22 @@ describe("CLI tests", () => {
7575

7676
const serverUrl = "https://dtrack.example.com";
7777
const projectName = "cdxgen-test-project";
78-
const projectVersion = "1.0.0";
79-
const projectTag = "tag1";
80-
const parentProjectId = "f7cb9f02-8041-4991-9101-b01fa07a6522";
78+
const projectVersion = "1.1.0";
79+
const projectTags = ["tag1", "tag2"];
80+
const parentProjectId = "5103b8b4-4ca3-46ea-8051-036a3b2ab17e";
8181
const bomContent = {
82-
bom: "test",
82+
bom: "test2",
8383
};
8484
const apiKey = "TEST_API_KEY";
8585
const skipDtTlsCheck = false;
8686

8787
const expectedRequestPayload = {
8888
autoCreate: "true",
89-
bom: "eyJib20iOiJ0ZXN0In0=", // stringified and base64 encoded bomContent
89+
bom: "eyJib20iOiJ0ZXN0MiJ9", // stringified and base64 encoded bomContent
9090
parentUUID: parentProjectId,
9191
projectName,
9292
projectVersion,
93-
projectTags: [{ name: projectTag }],
93+
projectTags: [{ name: projectTags[0] }, { name: projectTags[1] }],
9494
};
9595

9696
await submitBom(
@@ -101,7 +101,7 @@ describe("CLI tests", () => {
101101
projectVersion,
102102
apiKey,
103103
skipDtTlsCheck,
104-
projectTag,
104+
projectTag: projectTags,
105105
},
106106
bomContent,
107107
);

0 commit comments

Comments
 (0)