Skip to content

Commit 94ecfaf

Browse files
committed
get identity token from auths if it exists
1 parent 4d40593 commit 94ecfaf

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

packages/testcontainers/src/container-runtime/auth/auths.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,20 @@ describe("Auths", () => {
8282
};
8383
expect(await locator.getAuthConfig("https://registry.example.com", containerRuntimeConfig)).toEqual(authConfig);
8484
});
85+
86+
it("should return credentials from identity token", async () => {
87+
const containerRuntimeConfig: ContainerRuntimeConfig = {
88+
auths: {
89+
"https://registry.example.com": {
90+
identitytoken: "token-value",
91+
},
92+
},
93+
};
94+
const authConfig: AuthConfig = {
95+
identityToken: "token-value",
96+
registryAddress: "https://registry.example.com",
97+
};
98+
expect(await locator.getAuthConfig("https://registry.example.com", containerRuntimeConfig)).toEqual(authConfig);
99+
});
85100
});
86101
});

packages/testcontainers/src/container-runtime/auth/auths.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ export class Auths implements RegistryAuthLocator {
1313
return undefined;
1414
}
1515

16+
if (auth.identitytoken) {
17+
return {
18+
registryAddress: registry,
19+
identityToken: auth.identitytoken,
20+
};
21+
}
22+
1623
const authConfig: Partial<UsernamePasswordAuthConfig> = { registryAddress: registry };
1724

1825
if (auth.email) {

packages/testcontainers/src/container-runtime/auth/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export type Auth = {
99
email?: string;
1010
username?: string;
1111
password?: string;
12+
identitytoken?: string;
1213
};
1314

1415
export type AuthConfig = UsernamePasswordAuthConfig | IdentityTokenAuthConfig;

0 commit comments

Comments
 (0)