Skip to content

Commit

Permalink
improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
arithmetic1728 committed Dec 9, 2020
1 parent 5ba1176 commit fb1311f
Showing 1 changed file with 16 additions and 2 deletions.
Expand Up @@ -131,13 +131,15 @@ public void createTokenUrlWithScopes_null_scopes() {

@Test
public void createTokenUrlWithScopes_empty_scopes() {
ComputeEngineCredentials credentials =
ComputeEngineCredentials.newBuilder().setScopes(Collections.<String>emptyList()).build();
ComputeEngineCredentials.Builder builder =
ComputeEngineCredentials.newBuilder().setScopes(Collections.<String>emptyList());
ComputeEngineCredentials credentials = builder.build();
Collection<String> scopes = credentials.getScopes();
String tokenUrlWithScopes = credentials.createTokenUrlWithScopes();

assertEquals(TOKEN_URL, tokenUrlWithScopes);
assertTrue(scopes.isEmpty());
assertTrue(builder.getScopes().isEmpty());
}

@Test
Expand Down Expand Up @@ -165,6 +167,18 @@ public void createTokenUrlWithScopes_multiple_scopes() {
assertEquals("bar", scopes.toArray()[1]);
}

@Test
public void createScoped() {
ComputeEngineCredentials credentials =
ComputeEngineCredentials.newBuilder().setScopes(null).build();
ComputeEngineCredentials credentialsWithScopes =
(ComputeEngineCredentials) credentials.createScoped(Arrays.asList("foo"));
Collection<String> scopes = credentialsWithScopes.getScopes();

assertEquals(1, scopes.size());
assertEquals("foo", scopes.toArray()[0]);
}

@Test
public void getRequestMetadata_hasAccessToken() throws IOException {
String accessToken = "1/MkSJoj1xsli0AccessToken_NKPY2";
Expand Down

0 comments on commit fb1311f

Please sign in to comment.