Skip to content

Commit

Permalink
Adding Tests back for requester pays
Browse files Browse the repository at this point in the history
  • Loading branch information
sydney-munro committed Mar 4, 2022
1 parent 5149f01 commit d4638ce
Showing 1 changed file with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ private static void fillRequesterPaysFile(Storage storage, String fname, int siz

// Start of tests related to the "requester pays" feature
@Test
@Ignore("TODO: https://github.com/googleapis/java-storage-nio/issues/824")
public void testFileExistsRequesterPaysNoUserProject() throws IOException {
CloudStorageFileSystem testBucket = getRequesterPaysBucket(false, "");
Path path = testBucket.getPath(SML_FILE);
Expand All @@ -190,7 +189,6 @@ public void testFileExistsRequesterPaysNoUserProject() throws IOException {
}

@Test
@Ignore("TODO: https://github.com/googleapis/java-storage-nio/issues/824")
public void testFileExistsRequesterPays() throws IOException {
CloudStorageFileSystem testBucket = getRequesterPaysBucket(false, project);
Path path = testBucket.getPath(SML_FILE);
Expand All @@ -199,7 +197,6 @@ public void testFileExistsRequesterPays() throws IOException {
}

@Test
@Ignore("TODO: https://github.com/googleapis/java-storage-nio/issues/824")
public void testFileExistsRequesterPaysWithAutodetect() throws IOException {
CloudStorageFileSystem testBucket = getRequesterPaysBucket(true, project);
Path path = testBucket.getPath(SML_FILE);
Expand All @@ -208,7 +205,6 @@ public void testFileExistsRequesterPaysWithAutodetect() throws IOException {
}

@Test
@Ignore("TODO: https://github.com/googleapis/java-storage-nio/issues/824")
public void testCantCreateWithoutUserProject() throws IOException {
CloudStorageFileSystem testBucket = getRequesterPaysBucket(false, "");
Path path = testBucket.getPath(TMP_FILE);
Expand All @@ -230,7 +226,6 @@ public void testCanCreateWithUserProject() throws IOException {
}

@Test
@Ignore("TODO: https://github.com/googleapis/java-storage-nio/issues/824")
public void testCantReadWithoutUserProject() throws IOException {
CloudStorageFileSystem testBucket = getRequesterPaysBucket(false, "");
Path path = testBucket.getPath(SML_FILE);
Expand All @@ -252,7 +247,6 @@ public void testCanReadWithUserProject() throws IOException {
}

@Test
@Ignore("TODO: https://github.com/googleapis/java-storage-nio/issues/824")
public void testCantCopyWithoutUserProject() throws IOException {
CloudStorageFileSystem testRPBucket = getRequesterPaysBucket(false, "");
CloudStorageFileSystem testBucket = getTestBucket();
Expand Down Expand Up @@ -288,7 +282,7 @@ private void innerTestCantCopyWithoutUserProject(
Assert.assertTrue(
description,
hex.getMessage()
.contains("Bucket is requester pays bucket but no user project provided"));
.contains("requester pays"));
} catch (StorageException ex) {
assertIsRequesterPaysException(description, ex);
}
Expand All @@ -314,7 +308,6 @@ public void testCanCopyWithUserProject() throws IOException {
}

@Test
@Ignore("TODO: https://github.com/googleapis/java-storage-nio/issues/824")
public void testAutodetectWhenRequesterPays() throws IOException {
CloudStorageFileSystem testRPBucket = getRequesterPaysBucket(true, project);
Assert.assertEquals(
Expand All @@ -338,18 +331,24 @@ public void testAutodetectWhenNotRequesterPays() throws IOException {
"");
}

@Test
public void testAutoDetectNoUserProject() throws IOException {
CloudStorageFileSystem testBucket = getRequesterPaysBucket(true, "");
Assert.assertTrue(testBucket.provider().requesterPays(testBucket.bucket()));
}

private void assertIsRequesterPaysException(String message, StorageException ex) {
Assert.assertEquals(message, ex.getCode(), 400);
Assert.assertTrue(
message,
ex.getMessage().contains("Bucket is requester pays bucket but no user project provided"));
ex.getMessage().contains("requester pays"));
}

private void assertIsRequesterPaysException(String message, IOException ioex) {
Assert.assertTrue(message, ioex.getMessage().startsWith("400"));
Assert.assertTrue(
message,
ioex.getMessage().contains("Bucket is requester pays bucket but no user project provided"));
ioex.getMessage().contains("requester pays"));
}
// End of tests related to the "requester pays" feature

Expand Down

0 comments on commit d4638ce

Please sign in to comment.