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 1 commit
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
10 changes: 10 additions & 0 deletions tests/action.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ describe("scan-action", () => {
expect(outputs.stdout).toContain("Failed. Xeol found packages that were End-of-Life (EOL)");
});

it("runs with api-key input", () => {
const outputs = runAction({
path: "tests/fixtures/npm-project",
"fail-build": "true",
"output-format": "json",
"api-key": "1234567890",
});
expect(outputs.stdout).toContain("--api-key");
});

it("runs with sbom", () => {
const outputs = runAction({
sbom: "fixtures/test_sbom.spdx.json",
Expand Down
Loading