Send the version and mode with the user agent
This commit changes the way the action determines if running in action or runner mode. There is now an environment variable that is set at the beginning of the process and elsewhere in the process, we can check to see if the variable is set.
This commit is contained in:
parent
fad7cc482d
commit
47588796b4
48 changed files with 361 additions and 224 deletions
12
lib/api-client.test.js
generated
12
lib/api-client.test.js
generated
|
|
@ -13,12 +13,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
const githubUtils = __importStar(require("@actions/github/lib/utils"));
|
||||
const ava_1 = __importDefault(require("ava"));
|
||||
const sinon_1 = __importDefault(require("sinon"));
|
||||
const actions_util_1 = require("./actions-util");
|
||||
const api_client_1 = require("./api-client");
|
||||
const testing_utils_1 = require("./testing-utils");
|
||||
// eslint-disable-next-line import/no-commonjs
|
||||
const pkg = require("../package.json");
|
||||
testing_utils_1.setupTests(ava_1.default);
|
||||
let githubStub;
|
||||
ava_1.default.beforeEach(() => {
|
||||
githubStub = sinon_1.default.stub(githubUtils, "GitHub");
|
||||
actions_util_1.setMode(actions_util_1.Mode.actions);
|
||||
});
|
||||
ava_1.default("Get the client API", async (t) => {
|
||||
doTest(t, {
|
||||
|
|
@ -28,7 +32,7 @@ ava_1.default("Get the client API", async (t) => {
|
|||
}, undefined, {
|
||||
auth: "token xyz",
|
||||
baseUrl: "http://hucairz/api/v3",
|
||||
userAgent: "CodeQL Action",
|
||||
userAgent: `CodeQL Action/${pkg.version}`,
|
||||
});
|
||||
});
|
||||
ava_1.default("Get the client API external", async (t) => {
|
||||
|
|
@ -39,7 +43,7 @@ ava_1.default("Get the client API external", async (t) => {
|
|||
}, { allowExternal: true }, {
|
||||
auth: "token abc",
|
||||
baseUrl: "http://hucairz/api/v3",
|
||||
userAgent: "CodeQL Action",
|
||||
userAgent: `CodeQL Action/${pkg.version}`,
|
||||
});
|
||||
});
|
||||
ava_1.default("Get the client API external not present", async (t) => {
|
||||
|
|
@ -49,7 +53,7 @@ ava_1.default("Get the client API external not present", async (t) => {
|
|||
}, { allowExternal: true }, {
|
||||
auth: "token xyz",
|
||||
baseUrl: "http://hucairz/api/v3",
|
||||
userAgent: "CodeQL Action",
|
||||
userAgent: `CodeQL Action/${pkg.version}`,
|
||||
});
|
||||
});
|
||||
ava_1.default("Get the client API with github url", async (t) => {
|
||||
|
|
@ -59,7 +63,7 @@ ava_1.default("Get the client API with github url", async (t) => {
|
|||
}, undefined, {
|
||||
auth: "token xyz",
|
||||
baseUrl: "https://api.github.com",
|
||||
userAgent: "CodeQL Action",
|
||||
userAgent: `CodeQL Action/${pkg.version}`,
|
||||
});
|
||||
});
|
||||
function doTest(t, clientArgs, clientOptions, expected) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue