mirror of https://github.com/grpc/grpc-java.git
auth: Small improvement to test coverage
This removes an impossible condition and adds a test for another condition.
This commit is contained in:
parent
5878b6ddca
commit
696082f52e
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -311,6 +311,26 @@ public class GoogleAuthLibraryCallCredentialsTest {
|
|||
assertEquals(Status.Code.UNAUTHENTICATED, status.getCode());
|
||||
}
|
||||
|
||||
@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 =
|
||||
|
|
|
|||
Loading…
Reference in New Issue