aboutsummaryrefslogtreecommitdiff
path: root/auth
diff options
context:
space:
mode:
authorEric Anderson <ejona@google.com>2018-07-31 14:04:51 -0700
committerEric Anderson <ejona@google.com>2018-07-31 15:13:21 -0700
commit696082f52ebad64bcc89dee5dc1d02b10965cfcf (patch)
tree828e77d258d1223f490796ecb3f3f5f7a0115fbb /auth
parent5878b6ddcacc7e11a31aa2caef1021f071fec6e8 (diff)
downloadgrpc-grpc-java-696082f52ebad64bcc89dee5dc1d02b10965cfcf.tar.gz
auth: Small improvement to test coverage
This removes an impossible condition and adds a test for another condition.
Diffstat (limited to 'auth')
-rw-r--r--auth/src/main/java/io/grpc/auth/GoogleAuthLibraryCallCredentials.java3
-rw-r--r--auth/src/test/java/io/grpc/auth/GoogleAuthLibraryCallCredentialsTest.java20
2 files changed, 20 insertions, 3 deletions
diff --git a/auth/src/main/java/io/grpc/auth/GoogleAuthLibraryCallCredentials.java b/auth/src/main/java/io/grpc/auth/GoogleAuthLibraryCallCredentials.java
index 668db152b..c258db1bc 100644
--- a/auth/src/main/java/io/grpc/auth/GoogleAuthLibraryCallCredentials.java
+++ b/auth/src/main/java/io/grpc/auth/GoogleAuthLibraryCallCredentials.java
@@ -163,9 +163,6 @@ final class GoogleAuthLibraryCallCredentials implements CallCredentials {
*/
private static URI serviceUri(String authority, MethodDescriptor<?, ?> method)
throws StatusException {
- if (authority == null) {
- throw Status.UNAUTHENTICATED.withDescription("Channel has no authority").asException();
- }
// Always use HTTPS, by definition.
final String scheme = "https";
final int defaultPort = 443;
diff --git a/auth/src/test/java/io/grpc/auth/GoogleAuthLibraryCallCredentialsTest.java b/auth/src/test/java/io/grpc/auth/GoogleAuthLibraryCallCredentialsTest.java
index 5104ceaa2..1b6056731 100644
--- a/auth/src/test/java/io/grpc/auth/GoogleAuthLibraryCallCredentialsTest.java
+++ b/auth/src/test/java/io/grpc/auth/GoogleAuthLibraryCallCredentialsTest.java
@@ -312,6 +312,26 @@ public class GoogleAuthLibraryCallCredentialsTest {
}
@Test
+ public void googleCredential_nullSecurityDenied() {
+ final AccessToken token = new AccessToken("allyourbase", new Date(Long.MAX_VALUE));
+ final Credentials credentials = GoogleCredentials.create(token);
+ // Null should not (for the moment) crash in horrible ways. In the future this could be changed,
+ // since it technically isn't allowed per the API.
+ Attributes integrity = attrs.toBuilder()
+ .set(CallCredentials.ATTR_SECURITY_LEVEL, null)
+ .build();
+
+ GoogleAuthLibraryCallCredentials callCredentials =
+ new GoogleAuthLibraryCallCredentials(credentials);
+ callCredentials.applyRequestMetadata(method, integrity, executor, applier);
+ runPendingRunnables();
+
+ verify(applier).fail(statusCaptor.capture());
+ Status status = statusCaptor.getValue();
+ assertEquals(Status.Code.UNAUTHENTICATED, status.getCode());
+ }
+
+ @Test
public void serviceUri() throws Exception {
GoogleAuthLibraryCallCredentials callCredentials =
new GoogleAuthLibraryCallCredentials(credentials);