@@ -129,7 +129,10 @@ void presignedPostRejectsExceedingContentLength() {
129129 .post ("/" + BUCKET )
130130 .then ()
131131 .statusCode (400 )
132- .body (containsString ("EntityTooLarge" ));
132+ .contentType ("application/xml" )
133+ .body (hasXPath ("/Error/Code" , equalTo ("EntityTooLarge" )))
134+ .body (hasXPath ("/Error/Message" , equalTo (
135+ "Your proposed upload exceeds the maximum allowed size." )));
133136 }
134137
135138 @ Test
@@ -143,7 +146,10 @@ void presignedPostRequiresKeyField() {
143146 .post ("/" + BUCKET )
144147 .then ()
145148 .statusCode (400 )
146- .body (containsString ("InvalidArgument" ));
149+ .contentType ("application/xml" )
150+ .body (hasXPath ("/Error/Code" , equalTo ("InvalidArgument" )))
151+ .body (hasXPath ("/Error/Message" , equalTo (
152+ "Bucket POST must contain a field named 'key'." )));
147153 }
148154
149155 @ Test
@@ -157,7 +163,10 @@ void presignedPostRequiresFileField() {
157163 .post ("/" + BUCKET )
158164 .then ()
159165 .statusCode (400 )
160- .body (containsString ("InvalidArgument" ));
166+ .contentType ("application/xml" )
167+ .body (hasXPath ("/Error/Code" , equalTo ("InvalidArgument" )))
168+ .body (hasXPath ("/Error/Message" , equalTo (
169+ "Bucket POST must contain a file field." )));
161170 }
162171
163172 @ Test
@@ -227,7 +236,8 @@ void presignedPostToNonExistentBucketFails() {
227236 .post ("/nonexistent-presigned-bucket" )
228237 .then ()
229238 .statusCode (404 )
230- .body (containsString ("NoSuchBucket" ));
239+ .contentType ("application/xml" )
240+ .body (hasXPath ("/Error/Code" , equalTo ("NoSuchBucket" )));
231241 }
232242
233243 @ Test
@@ -277,7 +287,11 @@ void presignedPostRejectsContentTypeMismatch() {
277287 .post ("/" + BUCKET )
278288 .then ()
279289 .statusCode (403 )
280- .body (containsString ("Policy Condition failed" ));
290+ .contentType ("application/xml" )
291+ .body (hasXPath ("/Error/Code" , equalTo ("AccessDenied" )))
292+ .body (hasXPath ("/Error/Message" , equalTo (
293+ "Invalid according to Policy: Policy Condition failed: "
294+ + "[\" eq\" , \" $Content-Type\" , \" image/png\" ]" )));
281295 }
282296
283297 @ Test
@@ -302,7 +316,11 @@ void presignedPostRejectsKeyMismatch() {
302316 .post ("/" + BUCKET )
303317 .then ()
304318 .statusCode (403 )
305- .body (containsString ("Policy Condition failed" ));
319+ .contentType ("application/xml" )
320+ .body (hasXPath ("/Error/Code" , equalTo ("AccessDenied" )))
321+ .body (hasXPath ("/Error/Message" , equalTo (
322+ "Invalid according to Policy: Policy Condition failed: "
323+ + "[\" eq\" , \" $key\" , \" uploads/expected-key.txt\" ]" )));
306324 }
307325
308326 @ Test
@@ -351,7 +369,11 @@ void presignedPostRejectsStartsWithMismatch() {
351369 .post ("/" + BUCKET )
352370 .then ()
353371 .statusCode (403 )
354- .body (containsString ("Policy Condition failed" ));
372+ .contentType ("application/xml" )
373+ .body (hasXPath ("/Error/Code" , equalTo ("AccessDenied" )))
374+ .body (hasXPath ("/Error/Message" , equalTo (
375+ "Invalid according to Policy: Policy Condition failed: "
376+ + "[\" starts-with\" , \" $key\" , \" uploads/\" ]" )));
355377 }
356378
357379 @ Test
0 commit comments