Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeTrue;

import com.google.api.client.googleapis.json.GoogleJsonResponseException;
import com.google.api.gax.paging.Page;
import com.google.auth.ServiceAccountSigner;
import com.google.auth.oauth2.GoogleCredentials;
Expand Down Expand Up @@ -143,6 +142,8 @@ public class ITStorageTest {
private static final String KMS_KEY_RING_LOCATION = "us";
private static final String KMS_KEY_ONE_NAME = "gcs_kms_key_one";
private static final String KMS_KEY_TWO_NAME = "gcs_kms_key_two";
private static final boolean IS_VPC_TEST = System.getenv("GOOGLE_CLOUD_TESTS_IN_VPCSC") != null
&& System.getenv("GOOGLE_CLOUD_TESTS_IN_VPCSC").equalsIgnoreCase("true");

@BeforeClass
public static void beforeClass() throws IOException {
Expand Down Expand Up @@ -1661,20 +1662,16 @@ public void testGetBlobs() {

@Test
public void testDownloadPublicBlobWithoutAuthentication() {
assumeFalse(IS_VPC_TEST);
// create an unauthorized user
Storage unauthorizedStorage = StorageOptions.getUnauthenticatedInstance().getService();

// try to download blobs from a public bucket
String landsatBucket = "gcp-public-data-landsat";
String landsatPrefix = "LC08/PRE/044/034/LC80440342016259LGN00/";
String landsatBlob = landsatPrefix + "LC80440342016259LGN00_MTL.txt";
byte[] bytes;
try {
bytes = unauthorizedStorage.readAllBytes(landsatBucket, landsatBlob);
} catch (StorageException ex) {
assumeFalse(403 == ex.getCode());
return;
}
byte[] bytes = unauthorizedStorage.readAllBytes(landsatBucket, landsatBlob);

assertThat(bytes.length).isEqualTo(7903);
int numBlobs = 0;
Iterator<Blob> blobIterator = unauthorizedStorage
Expand Down