File tree Expand file tree Collapse file tree 3 files changed +40
-0
lines changed
packages/testcontainers/src/container-runtime/auth Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -82,5 +82,37 @@ 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+ } ) ;
100+
101+ it ( "should use identity token when token and user and pass are provided" , async ( ) => {
102+ const containerRuntimeConfig : ContainerRuntimeConfig = {
103+ auths : {
104+ "https://registry.example.com" : {
105+ identitytoken : "token-value" ,
106+ username : "user" ,
107+ password : "pass" ,
108+ } ,
109+ } ,
110+ } ;
111+ const authConfig : AuthConfig = {
112+ identityToken : "token-value" ,
113+ registryAddress : "https://registry.example.com" ,
114+ } ;
115+ expect ( await locator . getAuthConfig ( "https://registry.example.com" , containerRuntimeConfig ) ) . toEqual ( authConfig ) ;
116+ } ) ;
85117 } ) ;
86118} ) ;
Original file line number Diff line number Diff 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 ) {
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ export type Auth = {
99 email ?: string ;
1010 username ?: string ;
1111 password ?: string ;
12+ identitytoken ?: string ;
1213} ;
1314
1415export type AuthConfig = UsernamePasswordAuthConfig | IdentityTokenAuthConfig ;
You can’t perform that action at this time.
0 commit comments