Skip to content

Commit

Permalink
Adds test case for copy operations across buckets 🪣
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobvogel committed Jun 16, 2023
1 parent a0e2c34 commit 545ff35
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/test/java/BaseAWSSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -445,4 +445,38 @@ abstract class BaseAWSSpec extends BaseSpecification {
client.deleteObject(bucketName, keyTo)
client.deleteBucket(bucketName)
}

// reported in https://github.com/scireum/s3ninja/issues/230
def "Copying an object across buckets works as expected"() {
given:
def bucketNameFrom = DEFAULT_BUCKET_NAME
def bucketNameTo = DEFAULT_BUCKET_NAME + "-copy"
def key = "content"
def content = "I am pointless text content, but I deserve to exist twice and will thus be copied!"
def client = getClient()
when:
if (!client.doesBucketExist(bucketNameFrom)) {
client.createBucket(bucketNameFrom)
}
and:
if (!client.doesBucketExist(bucketNameTo)) {
client.createBucket(bucketNameTo)
}
and:
putObjectWithContent(bucketNameFrom, key, content)
and:
client.copyObject(bucketNameFrom, key, bucketNameTo, key);
and:
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucketNameTo, key)
URLConnection c = new URL(getClient().generatePresignedUrl(request).toString()).openConnection()
and:
String downloadedData = new String(ByteStreams.toByteArray(c.getInputStream()), StandardCharsets.UTF_8)
then:
downloadedData == content
and:
client.deleteObject(bucketNameFrom, key)
client.deleteBucket(bucketNameFrom)
client.deleteObject(bucketNameTo, key)
client.deleteBucket(bucketNameTo)
}
}

0 comments on commit 545ff35

Please sign in to comment.