Skip to content

Commit

Permalink
Merge pull request #1196 from tkrah/ISSUE-1179
Browse files Browse the repository at this point in the history
Fixes regression #1179
  • Loading branch information
bmuschko committed Oct 2, 2023
2 parents 1ee4778 + 3d4c5aa commit eb63885
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public AuthConfigurations lookupAllAuthConfigs(DockerRegistryCredentials registr
*/
public AuthConfigurations lookupAllAuthConfigs(AuthConfig additionalAuthConfig) {
AuthConfigurations allAuthConfigs = lookupAllAuthConfigs();
if (allAuthConfigs.getConfigs().isEmpty()) {
if (isProvidedByBuild(additionalAuthConfig)) {
allAuthConfigs.addConfig(additionalAuthConfig);
}
return allAuthConfigs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class RegistryAuthLocatorTest extends Specification {
}

@Issue('https://github.com/bmuschko/gradle-docker-plugin/issues/985')
def "AuthLocator returns auth from file over default"() {
def "AuthLocator returns empty auth from file over default"() {
given:
RegistryAuthLocator locator =
createAuthLocatorForExistingConfigFile('config-docker-hub-user-pass.json', false)
Expand All @@ -154,6 +154,33 @@ class RegistryAuthLocatorTest extends Specification {
0 * logger.error(*_)
}

@Issue('https://github.com/bmuschko/gradle-docker-plugin/issues/1179')
def "AuthLocator returns valid auth from file and default"() {
given:
RegistryAuthLocator locator =
createAuthLocatorForExistingConfigFile('config-docker-hub-user-pass.json', false)

when:
AuthConfigurations allConfigs = locator.lookupAllAuthConfigs(new AuthConfig()
.withRegistryAddress("https://index.docker.io/v2/")
.withUsername("username2")
.withPassword("secret2"))

then:
AuthConfig config = new AuthConfig()
.withUsername('username')
.withPassword('secret')
AuthConfig configAddon = new AuthConfig()
.withRegistryAddress("https://index.docker.io/v2/")
.withUsername('username2')
.withPassword('secret2')
allConfigs.configs.size() == 2
allConfigs.configs.get(config.registryAddress) == config
allConfigs.configs.get(configAddon.registryAddress) == configAddon

0 * logger.error(*_)
}

def "AuthLocator returns correct default registry"() {
given:
String image = 'ubuntu'
Expand Down

0 comments on commit eb63885

Please sign in to comment.