mirror of
https://github.com/github/codeql-action.git
synced 2026-04-24 15:58:49 +00:00
Check that individual proxy configurations are objects
This commit is contained in:
@@ -6,6 +6,9 @@ import { setupTests } from "./testing-utils";
|
||||
|
||||
setupTests(test);
|
||||
|
||||
const toEncodedJSON = (data: any) =>
|
||||
Buffer.from(JSON.stringify(data)).toString("base64");
|
||||
|
||||
test("getCredentials prefers registriesCredentials over registrySecrets", async (t) => {
|
||||
const registryCredentials = Buffer.from(
|
||||
JSON.stringify([
|
||||
@@ -46,6 +49,25 @@ test("getCredentials throws an error when configurations are not an array", asyn
|
||||
);
|
||||
});
|
||||
|
||||
test("getCredentials throws error when credential is not an object", async (t) => {
|
||||
const testCredentials = [["foo"], [null]].map(toEncodedJSON);
|
||||
|
||||
for (const testCredential of testCredentials) {
|
||||
t.throws(
|
||||
() =>
|
||||
startProxyExports.getCredentials(
|
||||
getRunnerLogger(true),
|
||||
undefined,
|
||||
testCredential,
|
||||
undefined,
|
||||
),
|
||||
{
|
||||
message: "Invalid credentials - must be an object",
|
||||
},
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test("getCredentials throws error when credential missing host and url", async (t) => {
|
||||
const registryCredentials = Buffer.from(
|
||||
JSON.stringify([{ type: "npm_registry", token: "abc" }]),
|
||||
|
||||
Reference in New Issue
Block a user