GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Replace AuthConfig toString implementation (#1506) · yahavi/docker-java@b09d820

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • docker-java-api/src/main/java/com/github/dockerjava/api/model
    • AuthConfig.java
  • docker-java/src/test/java/com/github/dockerjava/api/model
    • AuthConfigTest.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎docker-java-api/src/main/java/com/github/dockerjava/api/model/AuthConfig.java‎

Copy file name to clipboardExpand all lines: docker-java-api/src/main/java/com/github/dockerjava/api/model/AuthConfig.java
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import java.io.Serializable;
99

1010
@EqualsAndHashCode
11-
@ToString
11+
@ToString(onlyExplicitlyIncluded = true)
1212
public class AuthConfig implements Serializable {
1313
private static final long serialVersionUID = 1L;
1414

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

2222
@JsonProperty("username")
23+
@ToString.Include
2324
private String username;
2425

2526
@JsonProperty("password")
2627
private String password;
2728

2829
@JsonProperty("email")
30+
@ToString.Include
2931
private String email;
3032

3133
@JsonProperty("serveraddress")
34+
@ToString.Include
3235
private String registryAddress = DEFAULT_SERVER_ADDRESS;
3336

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

5559
public String getUsername() {
Collapse file

‎docker-java/src/test/java/com/github/dockerjava/api/model/AuthConfigTest.java‎

Copy file name to clipboardExpand all lines: docker-java/src/test/java/com/github/dockerjava/api/model/AuthConfigTest.java
+21-3Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
import java.io.IOException;
99

1010
import static com.github.dockerjava.test.serdes.JSONSamples.testRoundTrip;
11-
import static org.hamcrest.CoreMatchers.equalTo;
12-
import static org.hamcrest.CoreMatchers.is;
13-
import static org.hamcrest.CoreMatchers.nullValue;
11+
import static org.hamcrest.CoreMatchers.*;
1412
import static org.hamcrest.MatcherAssert.assertThat;
13+
import static org.hamcrest.Matchers.not;
1514
import static org.hamcrest.Matchers.notNullValue;
1615
import static org.junit.Assert.assertEquals;
1716

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

91+
@Test
92+
public void toStringDoesNotContainSensitiveStrings() {
93+
AuthConfig authConfig = new AuthConfig()
94+
.withAuth("authValue")
95+
.withEmail("emailValue")
96+
.withPassword("passwordValue")
97+
.withIdentityToken("identityTokenValue")
98+
.withRegistrytoken("registryTokenValue")
99+
.withRegistryAddress("registryAddressValue");
100+
String toStringValue = authConfig.toString();
101+
102+
assertThat(toStringValue, not(containsString("authValue")));
103+
assertThat(toStringValue, not(containsString("passwordValue")));
104+
assertThat(toStringValue, not(containsString("identityTokenValue")));
105+
assertThat(toStringValue, not(containsString("registryTokenValue")));
106+
107+
assertThat(toStringValue, containsString("emailValue"));
108+
assertThat(toStringValue, containsString("registryAddressValue"));
109+
}
92110
}

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.