/**
* Test Amazon S3 authentication.
*/
public void testAwsS3() {
AwsHelper helper = new AwsHelper();
// Example Object GET
ChallengeWriter cw = new ChallengeWriter();
ChallengeResponse challenge = new ChallengeResponse(
ChallengeScheme.HTTP_AWS_S3, "0PN5J17HBGZHT7JJ3X82",
"uV3F3YluFJax1cknvbcGwgjvx4QpvB+leU8dUj2o");
Request request = new Request(Method.GET,
"http://johnsmith.s3.amazonaws.com/photos/puppy.jpg");
Form httpHeaders = new Form();
httpHeaders.add(HeaderConstants.HEADER_DATE,
"Tue, 27 Mar 2007 19:36:42 +0000");
helper.formatRawResponse(cw, challenge, request, httpHeaders);
assertEquals("0PN5J17HBGZHT7JJ3X82:xXjDGYUmKxnwqr5KXNPGldn5LbA=",
cw.toString());
// Example Object PUT
cw = new ChallengeWriter();
request.setMethod(Method.PUT);
httpHeaders.set(HeaderConstants.HEADER_DATE,
"Tue, 27 Mar 2007 21:15:45 +0000", true);
httpHeaders.add(HeaderConstants.HEADER_CONTENT_LENGTH, "94328");
httpHeaders.add(HeaderConstants.HEADER_CONTENT_TYPE, "image/jpeg");
helper.formatRawResponse(cw, challenge, request, httpHeaders);
assertEquals("0PN5J17HBGZHT7JJ3X82:hcicpDDvL9SsO6AkvxqmIWkmOuQ=",
cw.toString());
}