spray/spray — Issue #55: Authorization in httpRequest
Author: jamosa
Created: 2011-11-04 18:35:17+00:00
State: open

Hello!

I'm trying to do a test in my project that uses a Rest Interface with authentication. To do the test, I define some interfaces and then I try to connect and it fails because I don't introduce user and password in httpRequest() .
My code is the next:

val mediaType =`text/javascript`

val expected =
"""
{
"message":"It contains the collection of identifiers of the corpus in the system"
}
"""

testService(HttpRequest(GET, "/corpus", headers = List(`Accept`(mediaType),`Authorization`(httpCredentials)))) {
mapService
}.response.content.as[String] must be(Right(pretty(render(parse(expected)))))

So, I know that I have to specify httpCredentials but I don't know how.
If anyone can explain me how can I do it, I would be so grateful.

Thank you!