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 @@ -8,7 +8,7 @@
import java.io.Serializable;

@EqualsAndHashCode
@ToString
@ToString(onlyExplicitlyIncluded = true)
public class AuthConfig implements Serializable {
private static final long serialVersionUID = 1L;

Expand All @@ -20,15 +20,18 @@ public class AuthConfig implements Serializable {
public static final String DEFAULT_SERVER_ADDRESS = "https://index.docker.io/v1/";

@JsonProperty("username")
@ToString.Include
private String username;

@JsonProperty("password")
private String password;

@JsonProperty("email")
@ToString.Include
private String email;

@JsonProperty("serveraddress")
@ToString.Include
private String registryAddress = DEFAULT_SERVER_ADDRESS;

@JsonProperty("auth")
Expand All @@ -50,6 +53,7 @@ public class AuthConfig implements Serializable {
* @since {@link com.github.dockerjava.core.RemoteApiVersion#VERSION_1_25}
*/
@JsonProperty("stackOrchestrator")
@ToString.Include
private String stackOrchestrator;

public String getUsername() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
import java.io.IOException;

import static com.github.dockerjava.test.serdes.JSONSamples.testRoundTrip;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertEquals;

Expand Down Expand Up @@ -89,4 +88,23 @@ public void shouldNotFailWithStackOrchestratorInConfig() throws IOException {
assertThat(authConfig.getStackOrchestrator(), is("kubernetes"));
}

@Test
public void toStringDoesNotContainSensitiveStrings() {
AuthConfig authConfig = new AuthConfig()
.withAuth("authValue")
.withEmail("emailValue")
.withPassword("passwordValue")
.withIdentityToken("identityTokenValue")
.withRegistrytoken("registryTokenValue")
.withRegistryAddress("registryAddressValue");
String toStringValue = authConfig.toString();

assertThat(toStringValue, not(containsString("authValue")));
assertThat(toStringValue, not(containsString("passwordValue")));
assertThat(toStringValue, not(containsString("identityTokenValue")));
assertThat(toStringValue, not(containsString("registryTokenValue")));

assertThat(toStringValue, containsString("emailValue"));
assertThat(toStringValue, containsString("registryAddressValue"));
}
}