diff --git a/dist/index.js b/dist/index.js index 1f4269f..9ee9b2c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -6,12 +6,13 @@ const helpers_1 = require("./helpers"); const processor_1 = require("./processor"); const processor = new processor_1.Processor(); async function validateSubscription() { + var _a; const API_URL = `https://agent.api.stepsecurity.io/v1/github/${process.env.GITHUB_REPOSITORY}/actions/subscription`; try { await axios_1.default.get(API_URL, { timeout: 3000 }); } catch (error) { - if ((0, axios_1.isAxiosError)(error) && error.response) { + if ((0, axios_1.isAxiosError)(error) && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 403) { core.error('Subscription is not valid. Reach out to support@stepsecurity.io'); process.exit(1); } diff --git a/src/index.ts b/src/index.ts index db1421c..2862707 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,7 +12,7 @@ async function validateSubscription(): Promise { try { await axios.get(API_URL, {timeout: 3000}) } catch (error) { - if (isAxiosError(error) && error.response) { + if (isAxiosError(error) && error.response?.status === 403) { core.error( 'Subscription is not valid. Reach out to support@stepsecurity.io' ) diff --git a/test/index.e2e.ts b/test/index.e2e.ts index 6f2c7fe..15970db 100644 --- a/test/index.e2e.ts +++ b/test/index.e2e.ts @@ -3,7 +3,7 @@ import * as execa from "execa"; import { ddb, DYNAMODB_ENDPOINT, tableName, toJS } from "./helper"; export async function invokeAction(input: { [key: string]: string | undefined }) { - const res = await execa("ts-node", ["src/index.ts"], { + const res = await execa.execa("ts-node", ["src/index.ts"], { preferLocal: true, env: Object.fromEntries( Object.entries(input).map(([key, value]) => [`INPUT_${key.toUpperCase()}`, value]), @@ -38,7 +38,7 @@ describe("dynamodb-actions", () => { expect(e).to.eq(null); expect(res?.exitCode).to.eq(0); - expect(res?.stdout).to.eq(`::set-output name=item::{"value":"bar","createdAt":12345,"key":"foo"}`); + expect(res?.stdout).to.eq(`\n::set-output name=item::{"value":"bar","createdAt":12345,"key":"foo"}`); }); });