Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ private Map.Entry<String, JsonNode> findAuthNode(final JsonNode config, final St
final Iterator<Map.Entry<String, JsonNode>> fields = auths.fields();
while (fields.hasNext()) {
final Map.Entry<String, JsonNode> entry = fields.next();
if (entry.getKey().contains("://" + reposName) || entry.getKey().equals(reposName)) {
if (entry.getKey().endsWith("://" + reposName) || entry.getKey().equals(reposName)) {
return entry;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ public void lookupAuthConfigWithJsonKeyCredentials() throws URISyntaxException {
assertThat(authConfig.getPassword()).as("Password is set").isNotNull();
}

@Test
public void lookupAuthConfigWithJsonKeyCredentialsPartialMatchShouldGiveNoResult() throws URISyntaxException {
// contains entry for registry.example.com
final RegistryAuthLocator authLocator = createTestAuthLocator("config-with-json-key.json");

final AuthConfig authConfig = authLocator.lookupAuthConfig(
DockerImageName.parse("registry.example.co/org/repo"), // partial match of registry name
new AuthConfig()
);

assertThat(authConfig.getUsername()).as("auth config username").isNull();
assertThat(authConfig.getPassword()).as("auth config password").isNull();
}

@Test
public void lookupAuthConfigUsingStore() throws URISyntaxException {
final RegistryAuthLocator authLocator = createTestAuthLocator("config-with-store.json");
Expand Down