Check that individual proxy configurations are objects

This commit is contained in:
Michael B. Gale
2025-06-27 14:06:57 +01:00
parent e9938e34d5
commit ca0540d370
6 changed files with 40 additions and 2 deletions
+22
View File
@@ -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" }]),