Ensuring that we don't print any credentials

This commit is contained in:
Marcin Grzejszczak
2017-11-23 11:59:31 +01:00
parent 4c073c8a52
commit 470ea54fff
2 changed files with 20 additions and 2 deletions

View File

@@ -244,10 +244,14 @@ public class StubRunnerOptions {
+ this.maxPortValue + ", stubRepositoryRoot='" + this.stubRepositoryRoot + '\''
+ ", workOffline=" + this.workOffline + ", stubsClassifier='" + this.stubsClassifier
+ '\'' + ", dependencies=" + this.dependencies + ", stubIdsToPortMapping="
+ this.stubIdsToPortMapping + ", username='" + this.username + '\'' + ", password='"
+ this.password + '\'' + ", stubRunnerProxyOptions='" + this.stubRunnerProxyOptions + "', stubsPerConsumer='"
+ this.stubIdsToPortMapping + ", username='" + obfuscate(this.username) + '\'' + ", password='"
+ obfuscate(this.password) + '\'' + ", stubRunnerProxyOptions='" + this.stubRunnerProxyOptions + "', stubsPerConsumer='"
+ this.stubsPerConsumer
+ '\'' + ", stubsPerConsumer='" + this.stubsPerConsumer + '\''
+ '}';
}
private String obfuscate(String string) {
return StringUtils.hasText(string) ? "****" : "";
}
}

View File

@@ -162,6 +162,20 @@ class StubRunnerOptionsBuilderSpec extends Specification {
options.mappingsOutputFolder == "folder"
}
def shouldNotPrintUsernameAndPassword() {
given:
StubRunnerOptionsBuilder builder = builder.withOptions(new StubRunnerOptions(1, 2, "root", true, "classifier",
[new StubConfiguration("a:b:c")], [(new StubConfiguration("a:b:c")): 3], "username123", "password123",
new StubRunnerOptions.StubRunnerProxyOptions("host", 4), true, "consumer", "folder"))
builder.withStubs("foo:bar:baz")
when:
String options = builder.build().toString()
then:
!options.contains("username123")
!options.contains("password123")
options.contains("****")
}
@Issue("#462")
@RestoreSystemProperties
def shouldSetAllPropsFromSystemProps() {