mrdhwnkml
(M Ridhwan K)
August 11, 2020, 8:01am
1
Hi, I’m Ridhwan
I just learned API testing with postman. and I want to make a test script to validate endpoint is correct. For example:
I have an endpoint: http://qa-interview.srcli.xyz/ and there’s 2 request: POST and GET
how I made a test script to validate the request is correct?
Best Regards
Thank you
Hey @mrdhwnkml
Welcome to the Postman community!
Could you include an example of the response body, please? This will help to narrow down what type of things you’re looking to test/check.
What does correct mean to you?
Is it the response code?
The response timings?
Certain headers?
Ensuring that specific data is in the request body?
The whole response body?
Parts of the response body?
mrdhwnkml
(M Ridhwan K)
August 11, 2020, 8:48am
3
Hi @danny-dainton ,
thank you for the welcome.
ok, for example I have endpoint like this : https://qa-interview.srcli.xyz/login
and response body is:
<html>
<head>
<title></title>
</head>
<body>
<form action="/login" method="post">
Username:<input type="text" name="username">
Password:<input type="password" name="password">
<input type="submit" value="Login">
</form>
</body>
</html>
and I want to make a script test for:
GET: if:
* already logged in: Returns the 3XX redirect to /
* not logged in: Displays a login form with a username & password
POST: if:
* already logged in: Returns the 3XX redirect to /
* not logged in: - Returns a 3XX redirect to / if the username & password combination is valid user data and the session_id cookie is set
username and password : (root:root123)
Thank You.