Light, fluffy, and always free - The AWS Local Emulator alternative
test(s3): remove the buckets S3GetObjectPartIntegrationTest creates (#5601)
Priamo Germosenf3562af70f79
diff --git a/src/test/java/io/github/hectorvent/floci/services/s3/S3GetObjectPartIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/s3/S3GetObjectPartIntegrationTest.javaindex d101f0db63..d82e9ccf8e 100644--- a/src/test/java/io/github/hectorvent/floci/services/s3/S3GetObjectPartIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/s3/S3GetObjectPartIntegrationTest.java@@ -1,14 +1,20 @@package io.github.hectorvent.floci.services.s3;import io.github.hectorvent.floci.services.s3.model.S3Checksum;+import io.github.hectorvent.floci.testing.EnforcementFixtures;+import io.github.hectorvent.floci.testing.PartitionCleanup;+import io.quarkus.test.common.http.TestHTTPResource;import io.quarkus.test.junit.QuarkusTest;import io.restassured.specification.RequestSpecification;import org.junit.jupiter.api.Test;+import org.junit.jupiter.api.extension.RegisterExtension;+import java.net.URI;import java.nio.charset.StandardCharsets;import java.util.Arrays;import java.util.UUID;+import static io.github.hectorvent.floci.testing.EnforcementFixtures.auth;import static io.restassured.RestAssured.given;import static org.hamcrest.Matchers.containsString;import static org.hamcrest.Matchers.emptyString;@@ -29,6 +35,12 @@ class S3GetObjectPartIntegrationTest {private static final String SECOND_PART = "test content 123";private static final long OBJECT_SIZE = FIRST_PART.length + SECOND_PART.length();+ @TestHTTPResource("/")+ static URI baseUri;++ @RegisterExtension+ final PartitionCleanup cleanup = new PartitionCleanup();+@Testvoid getObject_partOfAMultipartObject_isServedLikeItsRange() {String bucket = createBucket("part-get");@@ -324,8 +336,9 @@ class S3GetObjectPartIntegrationTest {+ (crc32c != null ? "<ChecksumCRC32C>" + crc32c + "</ChecksumCRC32C>" : "") + "</Part>";}- private static String createBucket(String prefix) {+ private String createBucket(String prefix) {String bucket = prefix + "-" + UUID.randomUUID().toString().substring(0, 8);+ cleanup.register(() -> EnforcementFixtures.removeBucket(baseUri.getPort(), auth("test", "s3"), bucket));given().when().put("/" + bucket).then().statusCode(200);return bucket;}diff --git a/src/test/java/io/github/hectorvent/floci/testing/EnforcementFixtures.java b/src/test/java/io/github/hectorvent/floci/testing/EnforcementFixtures.javaindex c34c8b26e5..e3789e9043 100644--- a/src/test/java/io/github/hectorvent/floci/testing/EnforcementFixtures.java+++ b/src/test/java/io/github/hectorvent/floci/testing/EnforcementFixtures.java@@ -12,11 +12,12 @@ import java.util.List;import static io.restassured.RestAssured.given;/**- * Takes an IAM user or an S3 bucket that an enforcement test created back out of the shared- * application, and makes the users such a test signs as ({@link #createUser}, {@link #auth}),- * registering each one's removal as it goes. A {@code @QuarkusTest} shares one application with every other test class, so a- * fixture left behind outlives the class that made it and is visible to the next class that lists- * users or buckets unscoped. Registered with {@link PartitionCleanup} as each fixture is made.+ * Takes an IAM user or an S3 bucket that a test created back out of the shared application, and+ * makes the users an enforcement test signs as ({@link #createUser}, {@link #auth}), registering+ * each one's removal as it goes. A {@code @QuarkusTest} shares one application with every other+ * test class, so a fixture left behind outlives the class that made it and is visible to the next+ * class that lists users or buckets unscoped. Registered with {@link PartitionCleanup} as each+ * fixture is made.** <p>Both read back what is attached rather than taking it as an argument, and both return* quietly when the thing is not there. That is what makes them safe to register before the create