Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ static GdchCredentials getGdchCredentials(
} catch (IllegalArgumentException ex) { // thrown when passing a malformed uri string
throw new IllegalArgumentException("The GDC-H API audience string is not a valid URI", ex);
}
return ((GdchCredentials) credentials).createWithGdchAudience(gdchAudienceUri);
return ((GdchCredentials) credentials).createWithGdchAudience(audienceString);
Comment thread
lqiu96 marked this conversation as resolved.
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -890,16 +890,16 @@ void testExecutorSettings() throws Exception {
assertThat(transportChannel.getExecutor()).isSameInstanceAs(executorProvider.getExecutor());
}

private GdchCredentials getMockGdchCredentials() throws IOException {
private GdchCredentials getMockGdchCredentials() {
GdchCredentials creds = Mockito.mock(GdchCredentials.class);

// GdchCredentials builder is mocked to accept a well-formed uri
GdchCredentials.Builder gdchCredsBuilder = Mockito.mock(GdchCredentials.Builder.class);
Mockito.when(gdchCredsBuilder.setGdchAudience(Mockito.any(URI.class)))
Mockito.when(gdchCredsBuilder.setGdchAudience(Mockito.anyString()))
.thenReturn(gdchCredsBuilder);
Mockito.when(gdchCredsBuilder.build()).thenReturn(creds);
Mockito.when(creds.toBuilder()).thenReturn(gdchCredsBuilder);
Mockito.when(creds.createWithGdchAudience(Mockito.any()))
Mockito.when(creds.createWithGdchAudience(Mockito.anyString()))
.thenAnswer((uri) -> getMockGdchCredentials());
return creds;
}
Expand Down Expand Up @@ -939,7 +939,7 @@ void testCreateClientContext_withGdchCredentialNoAudienceNoEndpoint() throws IOE
assertThat(fromProvider).isInstanceOf(GdchCredentials.class);
assertNotSame(fromContext, fromProvider);
verify((GdchCredentials) fromProvider, times(1))
.createWithGdchAudience(URI.create("test.googleapis.com:443"));
.createWithGdchAudience("test.googleapis.com:443");
}

@Test
Expand Down Expand Up @@ -995,7 +995,7 @@ void testCreateClientContext_withGdchCredentialWithoutAudienceWithEndpoint_corre
assertThat(fromProvider).isInstanceOf(GdchCredentials.class);
assertNotSame(fromContext, fromProvider);
verify((GdchCredentials) fromProvider, times(1))
.createWithGdchAudience(URI.create("test-endpoint"));
.createWithGdchAudience("test-endpoint");
}

@Test
Expand All @@ -1022,9 +1022,9 @@ void testCreateClientContext_withGdchCredentialAndValidAudience() throws IOExcep
// using an audience should have made the context to recreate the credentials
assertNotSame(fromContext, fromProvider);
verify((GdchCredentials) fromProvider, times(1))
.createWithGdchAudience(URI.create("valid-uri"));
.createWithGdchAudience("valid-uri");
verify((GdchCredentials) fromProvider, times(0))
.createWithGdchAudience(URI.create("test-endpoint"));
.createWithGdchAudience("test-endpoint");
}

@Test
Expand Down
Loading