@@ -340,6 +340,41 @@ public void endpointContextBuild_gdchFlow_noUniverseDomain_customEndpoint() thro
340
340
.isEqualTo (Credentials .GOOGLE_DEFAULT_UNIVERSE );
341
341
}
342
342
343
+ // This Universe Domain should match the `GOOGLE_CLOUD_UNIVERSE_DOMAIN` Env Var
344
+ // For this test running locally or in CI, check that the Env Var is set properly.
345
+ // This test should only run when the maven profile `EnvVarTest` is enabled.
346
+ @ Test
347
+ public void endpointContextBuild_universeDomainEnvVarSet () throws IOException {
348
+ String envVarUniverseDomain = "random.com" ;
349
+ EndpointContext endpointContext =
350
+ defaultEndpointContextBuilder
351
+ .setUniverseDomain (null )
352
+ .setClientSettingsEndpoint (null )
353
+ .build ();
354
+ Truth .assertThat (endpointContext .resolvedEndpoint ()).isEqualTo ("test.random.com:443" );
355
+ Truth .assertThat (endpointContext .resolvedUniverseDomain ()).isEqualTo (envVarUniverseDomain );
356
+ }
357
+
358
+ // This Universe Domain should match the `GOOGLE_CLOUD_UNIVERSE_DOMAIN` Env Var
359
+ // For this test running locally or in CI, check that the Env Var is set properly.
360
+ // This test should only run when the maven profile `EnvVarTest` is enabled.
361
+ @ Test
362
+ public void endpointContextBuild_multipleUniverseDomainConfigurations_clientSettingsHasPriority ()
363
+ throws IOException {
364
+ // This test has `GOOGLE_CLOUD_UNIVERSE_DOMAIN` = `random.com`
365
+ String clientSettingsUniverseDomain = "clientSettingsUniverseDomain.com" ;
366
+ EndpointContext endpointContext =
367
+ defaultEndpointContextBuilder
368
+ .setUniverseDomain (clientSettingsUniverseDomain )
369
+ .setClientSettingsEndpoint (null )
370
+ .build ();
371
+ Truth .assertThat (endpointContext .resolvedEndpoint ())
372
+ .isEqualTo ("test.clientSettingsUniverseDomain.com:443" );
373
+ // Client Settings Universe Domain (if set) takes priority
374
+ Truth .assertThat (endpointContext .resolvedUniverseDomain ())
375
+ .isEqualTo (clientSettingsUniverseDomain );
376
+ }
377
+
343
378
@ Test
344
379
public void hasValidUniverseDomain_gdchFlow_anyCredentials () throws IOException {
345
380
Credentials noCredentials = NoCredentialsProvider .create ().getCredentials ();
0 commit comments