Add clientCertificate to TlsCredentials.toString() (#945)

* Add clientCertificate to TlsCredentials.toString()

FlowRunner.run() logs these credentials to the GAE logs by implicitly using the
toString() method, so we need to add it if we want it to appear in the logs.
This commit is contained in:
Ben McIlwain 2021-01-26 17:20:21 -05:00 committed by GitHub
parent 4e66fed497
commit a3537447ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View file

@ -223,6 +223,7 @@ public class TlsCredentials implements TransportCredentials {
@Override @Override
public String toString() { public String toString() {
return toStringHelper(getClass()) return toStringHelper(getClass())
.add("clientCertificate", clientCertificate.orElse(null))
.add("clientCertificateHash", clientCertificateHash.orElse(null)) .add("clientCertificateHash", clientCertificateHash.orElse(null))
.add("clientAddress", clientInetAddr.orElse(null)) .add("clientAddress", clientInetAddr.orElse(null))
.toString(); .toString();

View file

@ -155,12 +155,14 @@ class FlowRunnerTest {
new TlsCredentials( new TlsCredentials(
true, true,
Optional.of("abc123def"), Optional.of("abc123def"),
Optional.of("cert"), Optional.of("cert046F5A3"),
Optional.of("127.0.0.1"), Optional.of("127.0.0.1"),
certificateChecker); certificateChecker);
flowRunner.run(eppMetricBuilder); flowRunner.run(eppMetricBuilder);
assertThat(Splitter.on("\n\t").split(findFirstLogMessageByPrefix(handler, "EPP Command\n\t"))) assertThat(Splitter.on("\n\t").split(findFirstLogMessageByPrefix(handler, "EPP Command\n\t")))
.contains("TlsCredentials{clientCertificateHash=abc123def, clientAddress=/127.0.0.1}"); .contains(
"TlsCredentials{clientCertificate=cert046F5A3, clientCertificateHash=abc123def,"
+ " clientAddress=/127.0.0.1}");
} }
@Test @Test