diff --git a/lib/start-proxy-action.js b/lib/start-proxy-action.js index 04b0b05d3..8d101315a 100644 --- a/lib/start-proxy-action.js +++ b/lib/start-proxy-action.js @@ -47823,7 +47823,7 @@ var LANGUAGE_TO_REGISTRY_TYPE = { python: ["python_index"], ruby: ["rubygems_server"], rust: ["cargo_registry"], - go: ["goproxy_server"] + go: ["goproxy_server", "git_source"] }; function isDefined(value) { return value !== void 0 && value !== null; diff --git a/src/start-proxy.test.ts b/src/start-proxy.test.ts index c9682edcf..3e2748aaf 100644 --- a/src/start-proxy.test.ts +++ b/src/start-proxy.test.ts @@ -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( diff --git a/src/start-proxy.ts b/src/start-proxy.ts index e5a32b66a..0532e68f0 100644 --- a/src/start-proxy.ts +++ b/src/start-proxy.ts @@ -62,7 +62,7 @@ const LANGUAGE_TO_REGISTRY_TYPE: Partial> = { python: ["python_index"], ruby: ["rubygems_server"], rust: ["cargo_registry"], - go: ["goproxy_server"], + go: ["goproxy_server", "git_source"], } as const; /**