From a9a28d0411daab9c2133299bc59f6eea7a53c4c6 Mon Sep 17 00:00:00 2001 From: Mario Campos Date: Thu, 2 Apr 2026 10:58:47 -0500 Subject: [PATCH 1/2] Add tests for getCredentials with multiple goproxy_servers and maven_repositories --- src/start-proxy.test.ts | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/start-proxy.test.ts b/src/start-proxy.test.ts index 7643e6264a..36dfcbc5f2 100644 --- a/src/start-proxy.test.ts +++ b/src/start-proxy.test.ts @@ -252,6 +252,47 @@ test("getCredentials returns all for a language when specified", async (t) => { t.assert(credentialsTypes.includes("git_source")); }); +test("getCredentials returns all goproxy_servers for a language when specified", async (t) => { + const multipleGoproxyServers = [ + { type: "goproxy_server", host: "goproxy1.example.com", token: "token1" }, + { type: "goproxy_server", host: "goproxy2.example.com", token: "token2" }, + { type: "git_source", host: "github.com/github", token: "mno" }, + ]; + + const credentials = startProxyExports.getCredentials( + getRunnerLogger(true), + undefined, + toEncodedJSON(multipleGoproxyServers), + KnownLanguage.go, + ); + t.is(credentials.length, 3); + + const goproxyServers = credentials.filter((c) => c.type === "goproxy_server"); + t.is(goproxyServers.length, 2); + t.assert(goproxyServers.some((c) => c.host === "goproxy1.example.com")); + t.assert(goproxyServers.some((c) => c.host === "goproxy2.example.com")); +}); + +test("getCredentials returns all maven_repositories for a language when specified", async (t) => { + const multipleMavenRepositories = [ + { type: "maven_repository", host: "maven1.pkg.github.com", token: "token1" }, + { type: "maven_repository", host: "maven2.pkg.github.com", token: "token2" }, + { type: "git_source", host: "github.com/github", token: "mno" }, + ]; + + const credentials = startProxyExports.getCredentials( + getRunnerLogger(true), + undefined, + toEncodedJSON(multipleMavenRepositories), + KnownLanguage.java, + ); + t.is(credentials.length, 2); + + const mavenRepositories = credentials.filter((c) => c.type === "maven_repository"); + t.assert(mavenRepositories.some((c) => c.host === "maven1.pkg.github.com")); + t.assert(mavenRepositories.some((c) => c.host === "maven2.pkg.github.com")); +}); + test("getCredentials returns all credentials when no language specified", async (t) => { const credentialsInput = toEncodedJSON(mixedCredentials); From f8935b51d5e422ade9b0ac6002cd90d18c377966 Mon Sep 17 00:00:00 2001 From: Mario Campos Date: Thu, 2 Apr 2026 11:38:03 -0500 Subject: [PATCH 2/2] Run `npm run lint-fix` to format the code --- src/start-proxy.test.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/start-proxy.test.ts b/src/start-proxy.test.ts index 36dfcbc5f2..74943daf01 100644 --- a/src/start-proxy.test.ts +++ b/src/start-proxy.test.ts @@ -275,8 +275,16 @@ test("getCredentials returns all goproxy_servers for a language when specified", test("getCredentials returns all maven_repositories for a language when specified", async (t) => { const multipleMavenRepositories = [ - { type: "maven_repository", host: "maven1.pkg.github.com", token: "token1" }, - { type: "maven_repository", host: "maven2.pkg.github.com", token: "token2" }, + { + type: "maven_repository", + host: "maven1.pkg.github.com", + token: "token1", + }, + { + type: "maven_repository", + host: "maven2.pkg.github.com", + token: "token2", + }, { type: "git_source", host: "github.com/github", token: "mno" }, ]; @@ -288,7 +296,9 @@ test("getCredentials returns all maven_repositories for a language when specifie ); t.is(credentials.length, 2); - const mavenRepositories = credentials.filter((c) => c.type === "maven_repository"); + const mavenRepositories = credentials.filter( + (c) => c.type === "maven_repository", + ); t.assert(mavenRepositories.some((c) => c.host === "maven1.pkg.github.com")); t.assert(mavenRepositories.some((c) => c.host === "maven2.pkg.github.com")); });