I have kind of partially figured out the problem.
The lengthy URL that is generated dynamically is already encoded. Since REST Assured will again encode the URL, I was getting 400.
TRY1:
Solution for that is,
given().urlEncodingEnabled(false)
and I am also separating out the query parameters as follows,
queryParam("AWSAccessKeyId", awsAccessKeyId).
queryParam("x-amz-security-token", sToken).
queryParam("Signature", signature).
Now, I don't get 400, but I am getting 403(Signature provided does not match). When I see the response body, AWS is sending the encoded signature.
For eg. If I have specified ...?Signature=AQcItZeRBWsRWVwjsNNt2ftJUL8%3D in the URL, then in the response I get,
<SignatureProvided>AQcItZeRBWsRWVwjsNNt2ftJUL8=</SignatureProvided>
TRY2:
I realized that Rest Assured is decoding the query parameters that I am passing. So I encoded the actual signature query param so that it will be same when Rest Assured decodes it.
queryParam("AWSAccessKeyId", awsAccessKeyId).
queryParam("x-amz-security-token", sToken).
queryParam("Signature", URLEncoder.encode(signature)).
Still I get the same error. Surprisingly, in the error message it shows the same signature that I require, but still same error,
<SignatureProvided>AQcItZeRBWsRWVwjsNNt2ftJUL8%3D</SignatureProvided>
I am still stuck with this. Anyone else have faced the same issue?
Thanks,
Harisha Talanki