_From [email protected] on November 04, 2012 09:45:53_
What steps will reproduce the problem? 1. I use auth().basic() to send a basic Authorization header
String httpResponse =
given()
.auth().basic("dave", "password")
.param("folderName", "myFolder")
.param("unpublished", true)
.expect()
.statusCode(200)
.when()
.post("http://localhost:8080/test"
.getBody().asString();
and on the server side, I never receive the Authorization header.
My work around is to roll my own header and that does show up in the request on the server:
String authCookie = ("dave" + ":" + "password");
String authCookieEncoded =
new String(Base64.encodeBase64(authCookie.getBytes()));
String httpResponse =
given()
.header("Authorization", "Basic " + authCookieEncoded)
.param("folderName", "myFolder")
.param("unpublished", true)
.expect()
.statusCode(200)
.when()
.post("http://localhost:8080/test"
.getBody().asString();
_Original issue: http://code.google.com/p/rest-assured/issues/detail?id=202_
_From [email protected] on November 04, 2012 21:38:25_
Hi,
auth().basic() expects the server to challenge with a basic auth request. What you're looking for is probably preemptive basic auth which adds the header without being challenged. So use
auth(). preemptive().basic("username", "password") instead.
Status: Invalid
_From [email protected] on November 10, 2012 16:15:36_
Ah, I see. I never knew there was a challenge version of basic authentication, you learn something new every day.
Thanks, web services (and testing them) has never been so easy because of you.
Cheers,
Dave Woldrich
_From [email protected] on November 11, 2012 02:37:14_
Thanks :)
Thanks @johanhaleby
@johanhaleby #951 Seeing multiple HTTP packet in post request.. I have raised this issue.
I am attaching the snapshot of the postman request packet capture

shout out to @johanhaleby. I was having issues with Spring Rest Docs not being able to find the Authorization header, adding preemptive() did the trick!
Most helpful comment
_From [email protected] on November 04, 2012 21:38:25_
Hi,
auth().basic() expects the server to challenge with a basic auth request. What you're looking for is probably preemptive basic auth which adds the header without being challenged. So use
auth(). preemptive().basic("username", "password") instead.
Status: Invalid