Add tests for generateRegistries with an existing CODEQL_REGISTRIES_AUTH
This commit is contained in:
parent
3c81243bb1
commit
5492b7d104
8 changed files with 58 additions and 10 deletions
2
lib/codeql.test.js
generated
2
lib/codeql.test.js
generated
|
|
@ -676,7 +676,7 @@ const injectedConfigMacro = ava_1.default.macro({
|
|||
const hasConfigArg = args.some((arg) => arg.startsWith("--codescanning-config="));
|
||||
t.false(hasConfigArg, "Should NOT have injected a codescanning config");
|
||||
// should not have passed a qlconfig file
|
||||
const hasQlconfigArg = args.find((arg) => arg.startsWith("--qlconfig="));
|
||||
const hasQlconfigArg = args.some((arg) => arg.startsWith("--qlconfig="));
|
||||
t.false(hasQlconfigArg, "Should NOT have passed a qlconfig file");
|
||||
});
|
||||
(0, ava_1.default)("passes a code scanning config AND qlconfig to the CLI when CLI config passing is enabled", async (t) => {
|
||||
|
|
|
|||
2
lib/config-utils.js
generated
2
lib/config-utils.js
generated
|
|
@ -1119,7 +1119,7 @@ async function generateRegistries(registriesInput, codeQL, tempDir, logger) {
|
|||
return {
|
||||
registriesAuthTokens:
|
||||
// if the user has explicitly set the CODEQL_REGISTRIES_AUTH env var then use that
|
||||
process.env["CODEQL_REGISTRIES_AUTH"] ?? registriesAuthTokens,
|
||||
process.env.CODEQL_REGISTRIES_AUTH ?? registriesAuthTokens,
|
||||
qlconfigFile,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
24
lib/config-utils.test.js
generated
24
lib/config-utils.test.js
generated
|
|
@ -1128,7 +1128,7 @@ const calculateAugmentationErrorMacro = ava_1.default.macro({
|
|||
// associated env vars
|
||||
return await util.withTmpDir(async (tmpDir) => {
|
||||
process.env.GITHUB_TOKEN = "not-a-token";
|
||||
process.env.CODEQL_REGISTRIES_AUTH = "not-a-registries-auth";
|
||||
process.env.CODEQL_REGISTRIES_AUTH = undefined;
|
||||
const logger = (0, logging_1.getRunnerLogger)(true);
|
||||
const registriesInput = yaml.dump([
|
||||
{
|
||||
|
|
@ -1187,7 +1187,7 @@ const calculateAugmentationErrorMacro = ava_1.default.macro({
|
|||
]);
|
||||
// Verify that the env vars were unset.
|
||||
t.deepEqual(process.env.GITHUB_TOKEN, "not-a-token");
|
||||
t.deepEqual(process.env.CODEQL_REGISTRIES_AUTH, "not-a-registries-auth");
|
||||
t.deepEqual(process.env.CODEQL_REGISTRIES_AUTH, undefined);
|
||||
});
|
||||
});
|
||||
(0, ava_1.default)("downloadPacks-with-registries fails on 2.10.3", async (t) => {
|
||||
|
|
@ -1277,6 +1277,26 @@ const calculateAugmentationErrorMacro = ava_1.default.macro({
|
|||
t.is(qlconfigFile, undefined);
|
||||
});
|
||||
});
|
||||
(0, ava_1.default)("generateRegistries prefers original CODEQL_REGISTRIES_AUTH", async (t) => {
|
||||
return await util.withTmpDir(async (tmpDir) => {
|
||||
process.env.CODEQL_REGISTRIES_AUTH = "original";
|
||||
const registriesInput = yaml.dump([
|
||||
{
|
||||
url: "http://ghcr.io",
|
||||
packages: ["codeql/*", "dsp-testing/*"],
|
||||
token: "not-a-token",
|
||||
},
|
||||
]);
|
||||
const codeQL = (0, codeql_1.setCodeQL)({
|
||||
// Accepted CLI versions are 2.10.4 or higher
|
||||
getVersion: () => Promise.resolve(codeql_1.CODEQL_VERSION_GHES_PACK_DOWNLOAD),
|
||||
});
|
||||
const logger = (0, logging_1.getRunnerLogger)(true);
|
||||
const { registriesAuthTokens, qlconfigFile } = await configUtils.generateRegistries(registriesInput, codeQL, tmpDir, logger);
|
||||
t.is(registriesAuthTokens, "original");
|
||||
t.is(qlconfigFile, path.join(tmpDir, "qlconfig.yml"));
|
||||
});
|
||||
});
|
||||
// getLanguages
|
||||
const mockRepositoryNwo = (0, repository_1.parseRepositoryNwo)("owner/repo");
|
||||
// eslint-disable-next-line github/array-foreach
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue