Skip to content

Commit f6a2d49

Browse files
authored
Merge pull request #1207 from tobiasstadler/master
Relax email requirement in auth config
2 parents 97b7dfa + 14ead2c commit f6a2d49

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/main/java/com/github/dockerjava/core/DefaultDockerClientConfig.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,7 @@ public DockerConfigFile getDockerConfig() {
252252

253253
private AuthConfig getAuthConfig() {
254254
AuthConfig authConfig = null;
255-
if (getRegistryUsername() != null && getRegistryPassword() != null && getRegistryEmail() != null
256-
&& getRegistryUrl() != null) {
255+
if (getRegistryUsername() != null && getRegistryPassword() != null && getRegistryUrl() != null) {
257256
authConfig = new AuthConfig()
258257
.withUsername(getRegistryUsername())
259258
.withPassword(getRegistryPassword())

src/test/java/com/github/dockerjava/cmd/PullImageCmdIT.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,20 @@ public void testPullImageWithValidAuth() throws Exception {
111111
.awaitCompletion(30, TimeUnit.SECONDS);
112112
}
113113

114+
@Test
115+
public void testPullImageWithValidAuthAndEmail() throws Exception {
116+
AuthConfig authConfig = RegistryUtils.runPrivateRegistry(dockerRule.getClient())
117+
.withEmail("foo@bar.de");
118+
119+
String imgName = RegistryUtils.createPrivateImage(dockerRule, "pull-image-with-valid-auth");
120+
121+
// stream needs to be fully read in order to close the underlying connection
122+
dockerRule.getClient().pullImageCmd(imgName)
123+
.withAuthConfig(authConfig)
124+
.exec(new PullImageResultCallback())
125+
.awaitCompletion(30, TimeUnit.SECONDS);
126+
}
127+
114128
@Test
115129
public void testPullImageWithNoAuth() throws Exception {
116130
RegistryUtils.runPrivateRegistry(dockerRule.getClient());
@@ -130,6 +144,7 @@ public void testPullImageWithNoAuth() throws Exception {
130144
.awaitCompletion(30, TimeUnit.SECONDS);
131145
}
132146

147+
133148
@Test
134149
public void testPullImageWithInvalidAuth() throws Exception {
135150
AuthConfig validAuthConfig = RegistryUtils.runPrivateRegistry(dockerRule.getClient());

src/test/java/com/github/dockerjava/utils/RegistryUtils.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ public static synchronized AuthConfig runPrivateRegistry(DockerClient dockerClie
8181
privateRegistryAuthConfig = new AuthConfig()
8282
.withUsername("testuser")
8383
.withPassword("testpassword")
84-
.withEmail("foo@bar.de")
8584
.withRegistryAddress("localhost:" + port);
8685
}
8786

0 commit comments

Comments
 (0)