Ensuring that we don't print any credentials
This commit is contained in:
@@ -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) ? "****" : "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user