From c21b67c2dbe0f1bbdb9b06f9077774534cf31081 Mon Sep 17 00:00:00 2001 From: Benji Visser Date: Fri, 8 Dec 2023 05:58:04 -0800 Subject: [PATCH] add test for api-key usage (#20) * add test for api-key usage Signed-off-by: Benji Visser * update test Signed-off-by: Benji Visser --------- Signed-off-by: Benji Visser --- dist/index.js | 6 ++++++ tests/xeol_command.test.js | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/dist/index.js b/dist/index.js index a7761aa..5e8cbf2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -101,10 +101,12 @@ async function run() { // a check must happen to ensure one is selected at least, and then return it const source = sourceInput(); const failBuild = core.getInput("fail-build") || "true"; + const apiKey = core.getInput("api-key") || ""; const outputFormat = core.getInput("output-format") || "table"; const out = await runScan({ source, failBuild, + apiKey, outputFormat, }); Object.keys(out).map((key) => { @@ -118,6 +120,7 @@ async function run() { async function runScan({ source, failBuild, + apiKey, outputFormat, }) { const out = {}; @@ -178,6 +181,9 @@ async function runScan({ if (failBuild) { cmdArgs.push("--fail-on-eol-found"); } + if (apiKey) { + cmdArgs.push("--api-key", apiKey); + } cmdArgs.push(source); // This /dev/null writable stream is required so the entire Xeol output diff --git a/tests/xeol_command.test.js b/tests/xeol_command.test.js index a7a1fc3..0c2179e 100644 --- a/tests/xeol_command.test.js +++ b/tests/xeol_command.test.js @@ -44,6 +44,17 @@ describe("Xeol command", () => { expect(cmd).toBe("xeol -o json asdf"); }); + it("is invoked with api-key", async () => { + let cmd = await mockExec({ + source: "asdf", + failBuild: "false", + outputFormat: "json", + version: "0.6.0", + apiKey: "1234", + }); + expect(cmd).toBe("xeol -o json --api-key 1234 asdf"); + }) + it("is invoked with fail", async () => { let cmd = await mockExec({ source: "asdf",