|
8 | 8 | import java.io.IOException; |
9 | 9 |
|
10 | 10 | 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.*; |
14 | 12 | import static org.hamcrest.MatcherAssert.assertThat; |
| 13 | +import static org.hamcrest.Matchers.not; |
15 | 14 | import static org.hamcrest.Matchers.notNullValue; |
16 | 15 | import static org.junit.Assert.assertEquals; |
17 | 16 |
|
@@ -89,4 +88,23 @@ public void shouldNotFailWithStackOrchestratorInConfig() throws IOException { |
89 | 88 | assertThat(authConfig.getStackOrchestrator(), is("kubernetes")); |
90 | 89 | } |
91 | 90 |
|
| 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 | + } |
92 | 110 | } |
0 commit comments