Skip to content

Commit 445498c

Browse files
committed
Lint fix.
1 parent aa70b56 commit 445498c

File tree

1 file changed

+28
-53
lines changed

1 file changed

+28
-53
lines changed

oauth2_http/javatests/com/google/auth/oauth2/ComputeEngineCredentialsTest.java

Lines changed: 28 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,73 +1254,48 @@ public void refreshAccessToken_withAgentCert_optedOut_requestsNormalToken() thro
12541254
assertFalse(requestUrl.contains("bindCertificateFingerprint"));
12551255
}
12561256

1257-
@Test
1258-
1259-
public void refreshAccessToken_agentConfigMissingFile_throws() throws IOException {
1260-
1261-
// Point config to a non-existent file.
1262-
1263-
envProvider.setEnv(
1264-
1265-
AgentIdentityUtils.GOOGLE_API_CERTIFICATE_CONFIG,
1266-
1267-
tempDir.resolve("missing_config.json").toAbsolutePath().toString());
1268-
1269-
1270-
1271-
// Use a mock TimeService to avoid actual sleeping and control time flow.
1272-
1273-
final AtomicLong currentTime = new AtomicLong(0);
1274-
1275-
AgentIdentityUtils.setTimeService(
1276-
1277-
new AgentIdentityUtils.TimeService() {
1278-
1279-
@Override
1280-
1281-
public long currentTimeMillis() {
1282-
1283-
return currentTime.get();
1284-
1285-
}
1286-
1287-
1288-
1289-
@Override
1290-
1291-
public void sleep(long millis) {
1292-
1293-
currentTime.addAndGet(millis);
1294-
1295-
}
1257+
@Test
1258+
public void refreshAccessToken_agentConfigMissingFile_throws() throws IOException {
12961259

1297-
});
1260+
// Point config to a non-existent file.
12981261

1299-
1262+
envProvider.setEnv(
1263+
AgentIdentityUtils.GOOGLE_API_CERTIFICATE_CONFIG,
1264+
tempDir.resolve("missing_config.json").toAbsolutePath().toString());
13001265

1301-
MockMetadataServerTransportFactory transportFactory =
1266+
// Use a mock TimeService to avoid actual sleeping and control time flow.
13021267

1303-
new MockMetadataServerTransportFactory();
1268+
final AtomicLong currentTime = new AtomicLong(0);
13041269

1305-
transportFactory.transport.setServiceAccountEmail(SA_CLIENT_EMAIL);
1270+
AgentIdentityUtils.setTimeService(
1271+
new AgentIdentityUtils.TimeService() {
13061272

1307-
1273+
@Override
1274+
public long currentTimeMillis() {
13081275

1309-
ComputeEngineCredentials credentials =
1276+
return currentTime.get();
1277+
}
13101278

1311-
ComputeEngineCredentials.newBuilder().setHttpTransportFactory(transportFactory).build();
1279+
@Override
1280+
public void sleep(long millis) {
13121281

1313-
1282+
currentTime.addAndGet(millis);
1283+
}
1284+
});
13141285

1315-
IOException e = assertThrows(IOException.class, credentials::refreshAccessToken);
1286+
MockMetadataServerTransportFactory transportFactory = new MockMetadataServerTransportFactory();
13161287

1317-
assertTrue(
1288+
transportFactory.transport.setServiceAccountEmail(SA_CLIENT_EMAIL);
13181289

1319-
e.getMessage()
1290+
ComputeEngineCredentials credentials =
1291+
ComputeEngineCredentials.newBuilder().setHttpTransportFactory(transportFactory).build();
13201292

1321-
.contains("Certificate config or certificate file not found after multiple retries"));
1293+
IOException e = assertThrows(IOException.class, credentials::refreshAccessToken);
13221294

1323-
}
1295+
assertTrue(
1296+
e.getMessage()
1297+
.contains("Certificate config or certificate file not found after multiple retries"));
1298+
}
13241299

13251300
private void setupCertConfig(String certResourceName) throws IOException {
13261301
// Copy cert resource to temp file

0 commit comments

Comments
 (0)