Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Docker registry passwords that contain a colon #839

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/testcontainers/src/container-runtime/auth/auths.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,23 @@ describe("Auths", () => {
};
expect(await locator.getAuthConfig("https://registry.example.com", containerRuntimeConfig)).toEqual(authConfig);
});

it("should return credentials from encoded auth when the password contains a colon", async () => {
const containerRuntimeConfig: ContainerRuntimeConfig = {
auths: {
"https://registry.example.com": {
email: "[email protected]",
auth: "dXNlcjpwYXNzOjE=",
},
},
};
const authConfig: AuthConfig = {
username: "user",
password: "pass:1",
email: "[email protected]",
registryAddress: "https://registry.example.com",
};
expect(await locator.getAuthConfig("https://registry.example.com", containerRuntimeConfig)).toEqual(authConfig);
});
});
});
4 changes: 3 additions & 1 deletion packages/testcontainers/src/container-runtime/auth/auths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export class Auths implements RegistryAuthLocator {

if (auth.auth) {
const decodedAuth = Buffer.from(auth.auth, "base64").toString();
const [username, password] = decodedAuth.split(":");
const [username, ...passwordParts] = decodedAuth.split(":");
const password = passwordParts.join(":");

authConfig.username = username;
authConfig.password = password;
} else {
Expand Down
Loading