0

I want to use the RestAssured framework to test my Java Spring API. The way the API works is that you have to login using a POST to /session/login with a username and a password in JSON format, for example:

{"username":"testuser","password":"testpassword"}

If the username and password are correct, a session cookie is returned which can then be used to determine whether the user is logged in. I can't seem to find a way to use the RestAssured's auth() function to do this. How would I do this?

Gamer1120
  • 236
  • 1
  • 8

1 Answers1

0

Use extract() on response to get your session token, and then pass it to new request using auth() methods or just adding required header e.g. .header("Authorization", token).

RocketRaccoon
  • 2,559
  • 1
  • 21
  • 30