Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test for api-key usage #20

Merged
merged 2 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading