This repository has been archived by the owner on Mar 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 549
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RegistryAuth: handle case where password contains colon
Fixes #764. This now matches [how docker-cli parses this field][0] from ~/.docker/config.json. Updated a test in DockerConfigReaderTest that was implicitly expecting the auth value to be ignored and thus failing the test with this fix. [0]: https://github.com/docker/cli/blob/db5620026dda9b8f5da519e382cf40ed22775e6d/cli/config/configfile/file.go#L184-L189
- Loading branch information
Showing
3 changed files
with
56 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/test/java/com/spotify/docker/client/messages/RegistryAuthTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/*- | ||
* -\-\- | ||
* docker-client | ||
* -- | ||
* Copyright (C) 2016 - 2017 Spotify AB | ||
* -- | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* -/-/- | ||
*/ | ||
|
||
package com.spotify.docker.client.messages; | ||
|
||
import static org.hamcrest.Matchers.is; | ||
import static org.junit.Assert.assertThat; | ||
|
||
import com.google.common.io.BaseEncoding; | ||
import org.junit.Test; | ||
|
||
public class RegistryAuthTest { | ||
|
||
@Test | ||
public void testForAuth() { | ||
final String username = "johndoe"; | ||
final String password = "pass123"; | ||
final String encoded = BaseEncoding.base64().encode((username + ":" + password).getBytes()); | ||
|
||
final RegistryAuth registryAuth = RegistryAuth.forAuth(encoded).build(); | ||
assertThat(registryAuth.username(), is(username)); | ||
assertThat(registryAuth.password(), is(password)); | ||
} | ||
|
||
@Test | ||
public void testForAuth_PasswordContainsColon() { | ||
final String username = "johndoe"; | ||
final String password = "foo:bar"; | ||
final String encoded = BaseEncoding.base64().encode((username + ":" + password).getBytes()); | ||
|
||
final RegistryAuth registryAuth = RegistryAuth.forAuth(encoded).build(); | ||
assertThat(registryAuth.username(), is(username)); | ||
assertThat(registryAuth.password(), is(password)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
{ | ||
"auths": { | ||
"docker.customdomain.com": { | ||
"auth": "ZG9ja2VybWFuOg==", | ||
"email": "[email protected]", | ||
"identityToken": "52ce5fd5-eb60-42bf-931f-5eeec128211a" | ||
} | ||
} | ||
} | ||
} |