Skip to content

Commit 6f3363d

Browse files
authored
Merge pull request #414 from step-security/subscription
fix: updated subscription check code
2 parents 04a1322 + 86b1103 commit 6f3363d

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

dist/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ const helpers_1 = require("./helpers");
66
const processor_1 = require("./processor");
77
const processor = new processor_1.Processor();
88
async function validateSubscription() {
9+
var _a;
910
const API_URL = `https://agent.api.stepsecurity.io/v1/github/${process.env.GITHUB_REPOSITORY}/actions/subscription`;
1011
try {
1112
await axios_1.default.get(API_URL, { timeout: 3000 });
1213
}
1314
catch (error) {
14-
if ((0, axios_1.isAxiosError)(error) && error.response) {
15+
if ((0, axios_1.isAxiosError)(error) && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 403) {
1516
core.error('Subscription is not valid. Reach out to [email protected]');
1617
process.exit(1);
1718
}

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ async function validateSubscription(): Promise<void> {
1212
try {
1313
await axios.get(API_URL, {timeout: 3000})
1414
} catch (error) {
15-
if (isAxiosError(error) && error.response) {
15+
if (isAxiosError(error) && error.response?.status === 403) {
1616
core.error(
1717
'Subscription is not valid. Reach out to [email protected]'
1818
)

test/index.e2e.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as execa from "execa";
33
import { ddb, DYNAMODB_ENDPOINT, tableName, toJS } from "./helper";
44

55
export async function invokeAction(input: { [key: string]: string | undefined }) {
6-
const res = await execa("ts-node", ["src/index.ts"], {
6+
const res = await execa.execa("ts-node", ["src/index.ts"], {
77
preferLocal: true,
88
env: Object.fromEntries(
99
Object.entries(input).map(([key, value]) => [`INPUT_${key.toUpperCase()}`, value]),
@@ -38,7 +38,7 @@ describe("dynamodb-actions", () => {
3838

3939
expect(e).to.eq(null);
4040
expect(res?.exitCode).to.eq(0);
41-
expect(res?.stdout).to.eq(`::set-output name=item::{"value":"bar","createdAt":12345,"key":"foo"}`);
41+
expect(res?.stdout).to.eq(`\n::set-output name=item::{"value":"bar","createdAt":12345,"key":"foo"}`);
4242
});
4343
});
4444

0 commit comments

Comments
 (0)