简体   繁体   中英

How to automate Rest API which require authentication using Rest assured

I want to test a Rest API which require authentication, before getting the Json response. FOr exa. If i want to visit rest API: then if I am not already logged in , then this will redirect me to Login HTML page, and after login, this will show me the Json output.

Now I want to write a Rest assured code in java for same: I dont know , whether this is possible to do login using this or not.

Steps : Step 1: When you send a request to the API, This will redirect to the login html page. Step 2: Enter username and password in the page. Step 3: Then we will able to see the response.

if your ui is spa you must use JWT for auth. and therefore you must send TOKEN in every reuest to server.

otherwise if use mvc ForEx SessionBase Auth handle this problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM