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?

4

1 回答 1

0

使用extract()响应来获取您的会话令牌,然后使用auth()方法将其传递给新请求或仅添加所需的标头,例如.header("Authorization", token).

于 2017-05-04T08:27:32.777 回答