Skip to content

Commit

Permalink
xds: fix lint warnings (grpc#6289)
Browse files Browse the repository at this point in the history
  • Loading branch information
creamsoup authored Oct 16, 2019
1 parent 8d1ee9c commit 9a34cee
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private void createSdsX509TrustManager(
for (X509Certificate cert : certs) {
// note: alias lookup uses toLowerCase(Locale.ENGLISH)
// so our alias needs to be all lower-case and unique
ks.setCertificateEntry("alias" + Integer.toString(i), cert);
ks.setCertificateEntry("alias" + i, cert);
i++;
}
tmf.init(ks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void validateCertificateContext_nullAndNotOptional_throwsException() {
/* certContext= */ null, /* optional= */ false);
Assert.fail("no exception thrown");
} catch (IllegalArgumentException expected) {
assertThat(expected.getMessage()).isEqualTo("certContext is required");
assertThat(expected).hasMessageThat().isEqualTo("certContext is required");
}
}

Expand All @@ -66,7 +66,7 @@ public void validateCertificateContext_missingTrustCa_throwsException() {
certContext, /* optional= */ false);
Assert.fail("no exception thrown");
} catch (IllegalArgumentException expected) {
assertThat(expected.getMessage()).isEqualTo("certContext is required");
assertThat(expected).hasMessageThat().isEqualTo("certContext is required");
}
}

Expand Down Expand Up @@ -101,7 +101,7 @@ public void validateCertificateContext_inlineString_throwsException() {
certContext, /* optional= */ false);
Assert.fail("no exception thrown");
} catch (IllegalArgumentException expected) {
assertThat(expected.getMessage()).isEqualTo("filename expected");
assertThat(expected).hasMessageThat().isEqualTo("filename expected");
}
}

Expand All @@ -126,7 +126,7 @@ public void validateTlsCertificate_nullAndNotOptional_throwsException() {
/* tlsCertificate= */ null, /* optional= */ false);
Assert.fail("no exception thrown");
} catch (IllegalArgumentException expected) {
assertThat(expected.getMessage()).isEqualTo("tlsCertificate is required");
assertThat(expected).hasMessageThat().isEqualTo("tlsCertificate is required");
}
}

Expand Down Expand Up @@ -159,7 +159,7 @@ public void validateTlsCertificate_missingCertChainNotOptional_throwsException()
SslContextSecretVolumeSecretProvider.validateTlsCertificate(tlsCert, /* optional= */ false);
Assert.fail("no exception thrown");
} catch (IllegalArgumentException expected) {
assertThat(expected.getMessage()).isEqualTo("filename expected");
assertThat(expected).hasMessageThat().isEqualTo("filename expected");
}
}

Expand All @@ -174,7 +174,7 @@ public void validateTlsCertificate_missingCertChainOptional_throwsException() {
SslContextSecretVolumeSecretProvider.validateTlsCertificate(tlsCert, /* optional= */ true);
Assert.fail("no exception thrown");
} catch (IllegalArgumentException expected) {
assertThat(expected.getMessage()).isEqualTo("filename expected");
assertThat(expected).hasMessageThat().isEqualTo("filename expected");
}
}

Expand All @@ -189,7 +189,7 @@ public void validateTlsCertificate_missingPrivateKeyNotOptional_throwsException(
SslContextSecretVolumeSecretProvider.validateTlsCertificate(tlsCert, /* optional= */ false);
Assert.fail("no exception thrown");
} catch (IllegalArgumentException expected) {
assertThat(expected.getMessage()).isEqualTo("filename expected");
assertThat(expected).hasMessageThat().isEqualTo("filename expected");
}
}

Expand All @@ -204,7 +204,7 @@ public void validateTlsCertificate_missingPrivateKeyOptional_throwsException() {
SslContextSecretVolumeSecretProvider.validateTlsCertificate(tlsCert, /* optional= */ true);
Assert.fail("no exception thrown");
} catch (IllegalArgumentException expected) {
assertThat(expected.getMessage()).isEqualTo("filename expected");
assertThat(expected).hasMessageThat().isEqualTo("filename expected");
}
}

Expand Down Expand Up @@ -246,7 +246,7 @@ public void validateTlsCertificate_certChainInlineString_throwsException() {
SslContextSecretVolumeSecretProvider.validateTlsCertificate(tlsCert, /* optional= */ true);
Assert.fail("no exception thrown");
} catch (IllegalArgumentException expected) {
assertThat(expected.getMessage()).isEqualTo("filename expected");
assertThat(expected).hasMessageThat().isEqualTo("filename expected");
}
}

Expand All @@ -262,7 +262,7 @@ public void validateTlsCertificate_privateKeyInlineString_throwsException() {
SslContextSecretVolumeSecretProvider.validateTlsCertificate(tlsCert, /* optional= */ true);
Assert.fail("no exception thrown");
} catch (IllegalArgumentException expected) {
assertThat(expected.getMessage()).isEqualTo("filename expected");
assertThat(expected).hasMessageThat().isEqualTo("filename expected");
}
}

Expand All @@ -273,7 +273,7 @@ public void getProviderForServer_nullTlsCertificate_throwsException() {
/* tlsCertificate= */ null, /* certContext= */ null);
Assert.fail("no exception thrown");
} catch (IllegalArgumentException expected) {
assertThat(expected.getMessage()).isEqualTo("tlsCertificate is required");
assertThat(expected).hasMessageThat().isEqualTo("tlsCertificate is required");
}
}

Expand All @@ -284,7 +284,7 @@ public void getProviderForServer_defaultTlsCertificate_throwsException() {
SslContextSecretVolumeSecretProvider.getProviderForServer(tlsCert, /* certContext= */ null);
Assert.fail("no exception thrown");
} catch (IllegalArgumentException expected) {
assertThat(expected.getMessage()).isEqualTo("filename expected");
assertThat(expected).hasMessageThat().isEqualTo("filename expected");
}
}

Expand Down Expand Up @@ -314,7 +314,7 @@ public void getProviderForClient_nullCertContext_throwsException() {
/* tlsCertificate= */ null, /* certContext= */ null);
Assert.fail("no exception thrown");
} catch (IllegalArgumentException expected) {
assertThat(expected.getMessage()).isEqualTo("certContext is required");
assertThat(expected).hasMessageThat().isEqualTo("certContext is required");
}
}

Expand All @@ -326,7 +326,7 @@ public void getProviderForClient_defaultCertContext_throwsException() {
/* tlsCertificate= */ null, certContext);
Assert.fail("no exception thrown");
} catch (IllegalArgumentException expected) {
assertThat(expected.getMessage()).isEqualTo("certContext is required");
assertThat(expected).hasMessageThat().isEqualTo("certContext is required");
}
}

Expand All @@ -345,7 +345,7 @@ public void getProviderForClient_certWithPrivateKeyInlineString_throwsException(
SslContextSecretVolumeSecretProvider.getProviderForClient(tlsCert, certContext);
Assert.fail("no exception thrown");
} catch (IllegalArgumentException expected) {
assertThat(expected.getMessage()).isEqualTo("filename expected");
assertThat(expected).hasMessageThat().isEqualTo("filename expected");
}
}

Expand All @@ -364,7 +364,7 @@ public void getProviderForClient_certWithCertChainInlineString_throwsException()
SslContextSecretVolumeSecretProvider.getProviderForClient(tlsCert, certContext);
Assert.fail("no exception thrown");
} catch (IllegalArgumentException expected) {
assertThat(expected.getMessage()).isEqualTo("filename expected");
assertThat(expected).hasMessageThat().isEqualTo("filename expected");
}
}

Expand Down Expand Up @@ -411,7 +411,7 @@ private static SslContextSecretVolumeSecretProvider getSslContextSecretVolumeSec
* Helper method to build SslContextSecretVolumeSecretProvider, call buildSslContext on it and
* check returned SslContext.
*/
private void sslContextForEitherWithBothCertAndTrust(
private static void sslContextForEitherWithBothCertAndTrust(
boolean server, String pemFile, String keyFile, String caFile) throws IOException {
SslContextSecretVolumeSecretProvider provider =
getSslContextSecretVolumeSecretProvider(server, pemFile, keyFile, caFile);
Expand All @@ -420,7 +420,7 @@ private void sslContextForEitherWithBothCertAndTrust(
doChecksOnSslContext(server, sslContext);
}

private void doChecksOnSslContext(boolean server, SslContext sslContext) {
private static void doChecksOnSslContext(boolean server, SslContext sslContext) {
if (server) {
assertThat(sslContext.isServer()).isTrue();
} else {
Expand Down Expand Up @@ -458,7 +458,7 @@ public void getProviderForServer_badFile_throwsException() throws IOException {
sslContextForEitherWithBothCertAndTrust(true, SERVER_1_PEM_FILE, SERVER_1_PEM_FILE, null);
Assert.fail("no exception thrown");
} catch (IllegalArgumentException expected) {
assertThat(expected.getMessage()).contains("File does not contain valid private key");
assertThat(expected).hasMessageThat().contains("File does not contain valid private key");
}
}

Expand Down Expand Up @@ -517,7 +517,7 @@ public void getProviderForClient_both_callsback_setException() throws IOExceptio
TestCallback<SslContext> testCallback = getValueThruCallback(provider);
assertThat(testCallback.updatedSecret).isNull();
assertThat(testCallback.updatedThrowable).isInstanceOf(IllegalArgumentException.class);
assertThat(testCallback.updatedThrowable.getMessage())
assertThat(testCallback.updatedThrowable).hasMessageThat()
.contains("File does not contain valid private key");
}
}

0 comments on commit 9a34cee

Please sign in to comment.