Skip to content

Commit

Permalink
Merge pull request #1 from HiranmayaGundu/hiran/fixes
Browse files Browse the repository at this point in the history
fix: only use the default registry if the server url is undefined
  • Loading branch information
HiranmayaGundu authored Jul 12, 2024
2 parents 7e2ebc9 + eb73d66 commit 4810713
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,23 @@ describe("CredentialProvider", () => {
).toBeUndefined();
});

it("should default to the registry url when the server url is not returned", async () => {
mockExecReturns(JSON.stringify({ "https://registry.example.com": "username" }));
mockSpawnReturns(
0,
JSON.stringify({
Username: "username",
Secret: "secret",
})
);

expect(await credentialProvider.getAuthConfig("https://registry.example.com", containerRuntimeConfig)).toEqual({
registryAddress: "https://registry.example.com",
username: "username",
password: "secret",
});
});

it("should return undefined when no auth config found for registry", async () => {
mockExecReturns(JSON.stringify({ registry2: "username" }));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export abstract class CredentialProvider implements RegistryAuthLocator {
return {
username: response.Username,
password: response.Secret,
registryAddress: credentialForRegistry,
registryAddress: response.ServerURL || credentialForRegistry,
};
}

Expand Down

0 comments on commit 4810713

Please sign in to comment.