|
41 | 41 | import com.google.api.gax.core.ExecutorProvider;
|
42 | 42 | import com.google.api.gax.core.FixedCredentialsProvider;
|
43 | 43 | import com.google.api.gax.core.FixedExecutorProvider;
|
| 44 | +import com.google.api.gax.core.NoCredentialsProvider; |
44 | 45 | import com.google.api.gax.rpc.mtls.MtlsProvider;
|
45 | 46 | import com.google.api.gax.rpc.mtls.MtlsProvider.MtlsEndpointUsagePolicy;
|
46 | 47 | import com.google.api.gax.rpc.testing.FakeChannel;
|
@@ -533,6 +534,26 @@ public Credentials getCredentials() throws IOException {
|
533 | 534 | assertThat(clientContext.getCredentials().getRequestMetadata(null)).isEqualTo(metaData);
|
534 | 535 | }
|
535 | 536 |
|
| 537 | + @Test |
| 538 | + public void testQuotaProjectId_worksWithNullCredentials() throws IOException { |
| 539 | + final String QUOTA_PROJECT_ID = "quota_project_id"; |
| 540 | + |
| 541 | + final InterceptingExecutor executor = new InterceptingExecutor(1); |
| 542 | + final FakeTransportChannel transportChannel = FakeTransportChannel.create(new FakeChannel()); |
| 543 | + final FakeTransportProvider transportProvider = |
| 544 | + new FakeTransportProvider( |
| 545 | + transportChannel, executor, true, null, Mockito.mock(Credentials.class)); |
| 546 | + |
| 547 | + final FakeClientSettings.Builder settingsBuilder = new FakeClientSettings.Builder(); |
| 548 | + |
| 549 | + settingsBuilder |
| 550 | + .setTransportChannelProvider(transportProvider) |
| 551 | + .setCredentialsProvider(NoCredentialsProvider.create()) |
| 552 | + .setQuotaProjectId(QUOTA_PROJECT_ID); |
| 553 | + |
| 554 | + assertThat(ClientContext.create(settingsBuilder.build()).getCredentials()).isNull(); |
| 555 | + } |
| 556 | + |
536 | 557 | @Test
|
537 | 558 | public void testUserAgentInternalOnly() throws Exception {
|
538 | 559 | TransportChannelProvider transportChannelProvider =
|
|
0 commit comments