Skip to content

Commit

Permalink
add test for api-key usage (#20)
Browse files Browse the repository at this point in the history
* add test for api-key usage

Signed-off-by: Benji Visser <benji@093b.org>

* update test

Signed-off-by: Benji Visser <benji@093b.org>

---------

Signed-off-by: Benji Visser <benji@093b.org>
  • Loading branch information
noqcks committed Dec 8, 2023
1 parent 585407c commit c21b67c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -118,6 +120,7 @@ async function run() {
async function runScan({
source,
failBuild,
apiKey,
outputFormat,
}) {
const out = {};
Expand Down Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions tests/xeol_command.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit c21b67c

Please sign in to comment.