Skip to content

Commit

Permalink
Too many cleaning on scope. oups!
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumeblaquiere committed Sep 29, 2020
1 parent c94a0ce commit 9d1b142
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import com.google.auth.oauth2.GoogleCredentialsTest.MockTokenServerTransportFactory;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
Expand All @@ -70,6 +69,7 @@ public class UserCredentialsTest extends BaseSerializationTest {
private static final String REFRESH_TOKEN = "1/Tl6awhpFjkMkSJoj1xsli0H2eL5YsMgU_NKPY2TyGWY";
private static final String ACCESS_TOKEN = "1/MkSJoj1xsli0AccessToken_NKPY2";
private static final String QUOTA_PROJECT = "sample-quota-project-id";
private static final Collection<String> SCOPES = Collections.singletonList("dummy.scope");
private static final URI CALL_URI = URI.create("http://googleapis.com/testapi/v1/foo");

@Test(expected = IllegalStateException.class)
Expand All @@ -92,6 +92,28 @@ public void constructor() {
assertEquals(QUOTA_PROJECT, credentials.getQuotaProjectId());
}

@Test
public void createScoped_same() {
UserCredentials userCredentials =
UserCredentials.newBuilder()
.setClientId(CLIENT_ID)
.setClientSecret(CLIENT_SECRET)
.setRefreshToken(REFRESH_TOKEN)
.build();
assertSame(userCredentials, userCredentials.createScoped(SCOPES));
}

@Test
public void createScopedRequired_false() {
UserCredentials userCredentials =
UserCredentials.newBuilder()
.setClientId(CLIENT_ID)
.setClientSecret(CLIENT_SECRET)
.setRefreshToken(REFRESH_TOKEN)
.build();
assertFalse(userCredentials.createScopedRequired());
}

@Test
public void fromJson_hasAccessToken() throws IOException {
MockTokenServerTransportFactory transportFactory = new MockTokenServerTransportFactory();
Expand Down

0 comments on commit 9d1b142

Please sign in to comment.