Skip to content

Commit

Permalink
Adds test case checking the content-length when responding to HEAD 馃
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 a017e98 commit f45baa6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/test/java/BaseAWSSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -404,4 +404,26 @@ abstract class BaseAWSSpec extends BaseSpecification {
client.deleteObject(bucketName, key2)
client.deleteObject(bucketName, key3)
}

// reported in https://github.com/scireum/s3ninja/issues/209
def "HEAD reports content length correctly"() {
given:
def bucketName = "public-bucket"
def key = "simple_test"
def content = "I am pointless text content"
def client = getClient()
when:
createPubliclyAccessibleBucket(bucketName)
putObjectWithContent(bucketName, key, content)
then:
def url = new URL("http://localhost:9999/" + bucketName + "/" + key)
HttpURLConnection connection = (HttpURLConnection) url.openConnection()
connection.setRequestMethod("HEAD")
connection.getResponseCode() == 200
connection.getContentLengthLong() == content.getBytes(StandardCharsets.UTF_8).length
connection.disconnect()
and:
client.deleteObject(bucketName, key)
client.deleteBucket(bucketName)
}
}

0 comments on commit f45baa6

Please sign in to comment.