Skip to content

Commit b623f5f

Browse files
authored
Merge pull request #3799 from github/mario-campos/test-multiple-registries
Add tests for getCredentials with multiple goproxy_servers and maven_…
2 parents e6c8394 + 35a3898 commit b623f5f

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

src/start-proxy.test.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,57 @@ test("getCredentials returns all for a language when specified", async (t) => {
252252
t.assert(credentialsTypes.includes("git_source"));
253253
});
254254

255+
test("getCredentials returns all goproxy_servers for Go when specified", async (t) => {
256+
const multipleGoproxyServers = [
257+
{ type: "goproxy_server", host: "goproxy1.example.com", token: "token1" },
258+
{ type: "goproxy_server", host: "goproxy2.example.com", token: "token2" },
259+
{ type: "git_source", host: "github.com/github", token: "mno" },
260+
];
261+
262+
const credentials = startProxyExports.getCredentials(
263+
getRunnerLogger(true),
264+
undefined,
265+
toEncodedJSON(multipleGoproxyServers),
266+
KnownLanguage.go,
267+
);
268+
t.is(credentials.length, 3);
269+
270+
const goproxyServers = credentials.filter((c) => c.type === "goproxy_server");
271+
t.is(goproxyServers.length, 2);
272+
t.assert(goproxyServers.some((c) => c.host === "goproxy1.example.com"));
273+
t.assert(goproxyServers.some((c) => c.host === "goproxy2.example.com"));
274+
});
275+
276+
test("getCredentials returns all maven_repositories for Java when specified", async (t) => {
277+
const multipleMavenRepositories = [
278+
{
279+
type: "maven_repository",
280+
host: "maven1.pkg.github.com",
281+
token: "token1",
282+
},
283+
{
284+
type: "maven_repository",
285+
host: "maven2.pkg.github.com",
286+
token: "token2",
287+
},
288+
{ type: "git_source", host: "github.com/github", token: "mno" },
289+
];
290+
291+
const credentials = startProxyExports.getCredentials(
292+
getRunnerLogger(true),
293+
undefined,
294+
toEncodedJSON(multipleMavenRepositories),
295+
KnownLanguage.java,
296+
);
297+
t.is(credentials.length, 2);
298+
299+
const mavenRepositories = credentials.filter(
300+
(c) => c.type === "maven_repository",
301+
);
302+
t.assert(mavenRepositories.some((c) => c.host === "maven1.pkg.github.com"));
303+
t.assert(mavenRepositories.some((c) => c.host === "maven2.pkg.github.com"));
304+
});
305+
255306
test("getCredentials returns all credentials when no language specified", async (t) => {
256307
const credentialsInput = toEncodedJSON(mixedCredentials);
257308

0 commit comments

Comments
 (0)