Skip to content

Commit

Permalink
Fixes for ITComputeTest (googleapis#3667)
Browse files Browse the repository at this point in the history
- add scopes
  • Loading branch information
andreamlin authored Sep 12, 2018
1 parent 509b079 commit 80c9675
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.google.cloud.compute.v1.DiskTypesScopedList;
import com.google.cloud.compute.v1.ListDiskTypesHttpRequest;
import com.google.cloud.compute.v1.ProjectName;
import com.google.cloud.compute.v1.ProjectRegionDiskTypeName;
import com.google.cloud.compute.v1.ProjectZoneDiskTypeName;
import com.google.cloud.compute.v1.ProjectZoneName;
import com.google.common.collect.Lists;
Expand Down Expand Up @@ -57,7 +58,8 @@ public class ITComputeTest {

@BeforeClass
public static void beforeClass() throws IOException{
Credentials credentials = GoogleCredentials.getApplicationDefault();
Credentials credentials = GoogleCredentials.getApplicationDefault().createScoped(
DiskTypeSettings.getDefaultServiceScopes());

diskTypeSettings =
DiskTypeSettings.newBuilder().setCredentialsProvider(FixedCredentialsProvider.create(credentials)).build();
Expand Down Expand Up @@ -131,10 +133,18 @@ public void testAggregatedListDiskTypes() {
}
assertThat(diskTypeIterator.size()).isGreaterThan(0);
for (DiskType diskType : diskTypeIterator) {
assertThat(diskType.getZone()).isNotNull();
ProjectZoneDiskTypeName zoneName = ProjectZoneDiskTypeName.parse(trimUrl(diskType.getSelfLink()));
assertThat(zoneName.getDiskType()).isNotNull();
assertThat(zoneName.getZone()).isNotNull();
assertThat(diskType.getRegion() != null || diskType.getZone() != null).isTrue();
if (diskType.getRegion() != null) {
ProjectRegionDiskTypeName zoneName = ProjectRegionDiskTypeName
.parse(trimUrl(diskType.getSelfLink()));
assertThat(zoneName.getDiskType()).isNotNull();
assertThat(zoneName.getRegion()).isNotNull();
} else {
ProjectZoneDiskTypeName zoneName = ProjectZoneDiskTypeName
.parse(trimUrl(diskType.getSelfLink()));
assertThat(zoneName.getDiskType()).isNotNull();
assertThat(zoneName.getZone()).isNotNull();
}
assertThat(diskType.getCreationTimestamp()).isNotNull();
assertThat(diskType.getDescription()).isNotNull();
assertThat(diskType.getValidDiskSize()).isNotNull();
Expand Down

0 comments on commit 80c9675

Please sign in to comment.