Skip to content

Commit

Permalink
Adds helper for creating publicly accessible buckets while testing 🔬
Browse files Browse the repository at this point in the history
#209
SIRI-721

Signed-off-by: Jakob Vogel <jvo@scireum.de>
  • Loading branch information
jakobvogel committed Feb 24, 2023
1 parent 3b5ad70 commit a017e98
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/test/java/BaseAWSSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ abstract class BaseAWSSpec extends BaseSpecification {

abstract AmazonS3Client getClient()

private void createPubliclyAccessibleBucket(String bucketName) {
def client = getClient()
client.createBucket(bucketName)

// we make the bucket now public via our own endpoint; note that this is not proper S3 code
// where you would use ACLs that we do not support in S3 Ninja
def url = new URL("http://localhost:9999/ui/" + bucketName + "/?make-public")
HttpURLConnection connection = (HttpURLConnection) url.openConnection()
connection.getResponseCode() == 200
connection.disconnect();
}

private void putObjectWithContent(String bucketName, String key, String content) {
def client = getClient()
def data = content.getBytes(StandardCharsets.UTF_8)
Expand Down

0 comments on commit a017e98

Please sign in to comment.