Skip to content

Commit

Permalink
improve test coverage rate
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhenLian committed Apr 29, 2020
1 parent 1bb3e43 commit 82781db
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion netty/src/test/java/io/grpc/netty/AdvancedTlsTest.java
Expand Up @@ -225,6 +225,20 @@ public void basicConfigurableX509TrustManagerTest() throws Exception {
assertEquals(
"Failed loading trusted certs", e.getMessage());
}
// Expect to succeed if choosing to not verify anything.
TlsOptions goodOptions = new SimpleTlsOptions(
VerificationAuthType.SkipAllVerification, null, true, true);
ConfigurableX509TrustManager goodManager = new ConfigurableX509TrustManager(
goodOptions);
try {
goodManager.checkServerTrusted(new X509Certificate[1], "");
goodManager.checkClientTrusted(new X509Certificate[1], "");
Socket socket = new Socket();
goodManager.checkServerTrusted(new X509Certificate[1], "", socket);
goodManager.checkClientTrusted(new X509Certificate[1], "", socket);
} catch (CertificateException e) {
fail(e.getMessage());
}
}

/**
Expand Down Expand Up @@ -374,7 +388,7 @@ private void makeRpcCall(TlsOptions options, File clientCertChainFile, File clie
client.unaryRpc(SimpleRequest.getDefaultInstance());
} catch (StatusRuntimeException e) {
if (!expectError) {
fail("Didn't expect error but find error.");
fail("Didn't expect error but find error: " + e.getMessage());
}
assertEquals(
Throwables.getStackTraceAsString(e),
Expand Down

0 comments on commit 82781db

Please sign in to comment.