@@ -1278,47 +1278,7 @@ private void waitForRegionalAccessBoundary(GoogleCredentials credentials)
12781278 }
12791279 }
12801280
1281- @ org .junit .jupiter .api .Test
1282- void testRefresh_regionalAccessBoundarySuccess () throws IOException , InterruptedException {
1283- TestEnvironmentProvider environmentProvider = new TestEnvironmentProvider ();
1284- RegionalAccessBoundary .setEnvironmentProviderForTest (environmentProvider );
1285- environmentProvider .setEnv (RegionalAccessBoundary .ENABLE_EXPERIMENT_ENV_VAR , "1" );
1286-
1287- ExternalAccountAuthorizedUserCredentials credentials =
1288- ExternalAccountAuthorizedUserCredentials .newBuilder ()
1289- .setClientId (CLIENT_ID )
1290- .setClientSecret (CLIENT_SECRET )
1291- .setRefreshToken (REFRESH_TOKEN )
1292- .setTokenUrl (TOKEN_URL )
1293- .setAudience (
1294- "//iam.googleapis.com/locations/global/workforcePools/pool/providers/provider" )
1295- .setHttpTransportFactory (transportFactory )
1296- .build ();
1297-
1298- // First call: initiates async refresh.
1299- Map <String , List <String >> headers = credentials .getRequestMetadata ();
1300- assertNull (headers .get (RegionalAccessBoundary .X_ALLOWED_LOCATIONS_HEADER_KEY ));
1301-
1302- waitForRegionalAccessBoundary (credentials );
13031281
1304- // Second call: should have header.
1305- headers = credentials .getRequestMetadata ();
1306- assertEquals (
1307- headers .get (RegionalAccessBoundary .X_ALLOWED_LOCATIONS_HEADER_KEY ),
1308- Arrays .asList (TestUtils .REGIONAL_ACCESS_BOUNDARY_ENCODED_LOCATION ));
1309- }
1310-
1311- private void waitForRegionalAccessBoundary (GoogleCredentials credentials )
1312- throws InterruptedException {
1313- long deadline = System .currentTimeMillis () + 5000 ;
1314- while (credentials .getRegionalAccessBoundary () == null
1315- && System .currentTimeMillis () < deadline ) {
1316- Thread .sleep (100 );
1317- }
1318- if (credentials .getRegionalAccessBoundary () == null ) {
1319- Assertions .fail ("Timed out waiting for regional access boundary refresh" );
1320- }
1321- }
13221282
13231283 static GenericJson buildJsonCredentials () {
13241284 GenericJson json = new GenericJson ();
0 commit comments