mirror of
https://github.com/github/codeql-action.git
synced 2026-04-27 01:08:46 +00:00
Add git_source as supported registry type for Go
This commit is contained in:
+22
-13
@@ -11,6 +11,14 @@ setupTests(test);
|
||||
const toEncodedJSON = (data: any) =>
|
||||
Buffer.from(JSON.stringify(data)).toString("base64");
|
||||
|
||||
const mixedCredentials = [
|
||||
{ type: "npm_registry", host: "npm.pkg.github.com", token: "abc" },
|
||||
{ type: "maven_repository", host: "maven.pkg.github.com", token: "def" },
|
||||
{ type: "nuget_feed", host: "nuget.pkg.github.com", token: "ghi" },
|
||||
{ type: "goproxy_server", host: "goproxy.example.com", token: "jkl" },
|
||||
{ type: "git_source", host: "github.com/github", token: "mno" },
|
||||
];
|
||||
|
||||
test("getCredentials prefers registriesCredentials over registrySecrets", async (t) => {
|
||||
const registryCredentials = Buffer.from(
|
||||
JSON.stringify([
|
||||
@@ -94,13 +102,6 @@ test("getCredentials throws error when credential missing host and url", async (
|
||||
});
|
||||
|
||||
test("getCredentials filters by language when specified", async (t) => {
|
||||
const mixedCredentials = [
|
||||
{ type: "npm_registry", host: "npm.pkg.github.com", token: "abc" },
|
||||
{ type: "maven_repository", host: "maven.pkg.github.com", token: "def" },
|
||||
{ type: "nuget_feed", host: "nuget.pkg.github.com", token: "ghi" },
|
||||
{ type: "goproxy_server", host: "goproxy.example.com", token: "jkl" },
|
||||
];
|
||||
|
||||
const credentials = startProxyExports.getCredentials(
|
||||
getRunnerLogger(true),
|
||||
undefined,
|
||||
@@ -111,13 +112,21 @@ test("getCredentials filters by language when specified", async (t) => {
|
||||
t.is(credentials[0].type, "maven_repository");
|
||||
});
|
||||
|
||||
test("getCredentials returns all for a language when specified", async (t) => {
|
||||
const credentials = startProxyExports.getCredentials(
|
||||
getRunnerLogger(true),
|
||||
undefined,
|
||||
toEncodedJSON(mixedCredentials),
|
||||
"go",
|
||||
);
|
||||
t.is(credentials.length, 2);
|
||||
|
||||
const credentialsTypes = credentials.map((c) => c.type);
|
||||
t.assert(credentialsTypes.includes("goproxy_server"));
|
||||
t.assert(credentialsTypes.includes("git_source"));
|
||||
});
|
||||
|
||||
test("getCredentials returns all credentials when no language specified", async (t) => {
|
||||
const mixedCredentials = [
|
||||
{ type: "npm_registry", host: "npm.pkg.github.com", token: "abc" },
|
||||
{ type: "maven_repository", host: "maven.pkg.github.com", token: "def" },
|
||||
{ type: "nuget_feed", host: "nuget.pkg.github.com", token: "ghi" },
|
||||
{ type: "goproxy_server", host: "goproxy.example.com", token: "jkl" },
|
||||
];
|
||||
const credentialsInput = toEncodedJSON(mixedCredentials);
|
||||
|
||||
const credentials = startProxyExports.getCredentials(
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ const LANGUAGE_TO_REGISTRY_TYPE: Partial<Record<KnownLanguage, string[]>> = {
|
||||
python: ["python_index"],
|
||||
ruby: ["rubygems_server"],
|
||||
rust: ["cargo_registry"],
|
||||
go: ["goproxy_server"],
|
||||
go: ["goproxy_server", "git_source"],
|
||||
} as const;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user