Thanks to visit codestin.com
Credit goes to github.com

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 @@ -25,8 +25,12 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
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;
import com.google.cloud.kms.v1.CreateCryptoKeyRequest;
import com.google.cloud.kms.v1.CreateKeyRingRequest;
Expand Down Expand Up @@ -1604,6 +1608,10 @@ public void testWriteChannelExistingBlob() throws IOException {

@Test
public void testGetSignedUrl() throws IOException {
if(storage.getOptions().getCredentials() != null) {
assumeTrue(storage.getOptions().getCredentials() instanceof ServiceAccountSigner);
}

String blobName = "test-get-signed-url-blob/with/slashes/and?special=!#$&'()*+,:;=?@[]";
BlobInfo blob = BlobInfo.newBuilder(BUCKET, blobName).build();
Blob remoteBlob = storage.create(blob, BLOB_BYTE_CONTENT);
Expand All @@ -1619,6 +1627,9 @@ public void testGetSignedUrl() throws IOException {

@Test
public void testPostSignedUrl() throws IOException {
if (storage.getOptions().getCredentials() != null) {
assumeTrue(storage.getOptions().getCredentials() instanceof ServiceAccountSigner);
}
String blobName = "test-post-signed-url-blob";
BlobInfo blob = BlobInfo.newBuilder(BUCKET, blobName).build();
assertNotNull(storage.create(blob));
Expand Down Expand Up @@ -1657,7 +1668,13 @@ public void testDownloadPublicBlobWithoutAuthentication() {
String landsatBucket = "gcp-public-data-landsat";
String landsatPrefix = "LC08/PRE/044/034/LC80440342016259LGN00/";
String landsatBlob = landsatPrefix + "LC80440342016259LGN00_MTL.txt";
byte[] bytes = unauthorizedStorage.readAllBytes(landsatBucket, landsatBlob);
byte[] bytes;
try {
bytes = unauthorizedStorage.readAllBytes(landsatBucket, landsatBlob);
} catch (StorageException ex) {
assumeFalse(403 == ex.getCode());
return;
}
assertThat(bytes.length).isEqualTo(7903);
int numBlobs = 0;
Iterator<Blob> blobIterator = unauthorizedStorage
Expand Down