API Testing
API Testing
1. API Basics: API kya hota hai, REST, SOAP, aur GraphQL ke concepts samjhe.
2. HTTP Methods: GET, POST, PUT, DELETE jaise HTTP methods ka istemal kaise hota
hai.
3. Request aur Response Structure: JSON, XML jaise data formats ko samjhein aur kaise
API requests aur responses ka structure hota hai.
4. Tools: Postman, SoapUI, ya curl jaise tools ka istemal karna seekhein.
5. Authentication: API ke security mechanisms jaise OAuth, API keys, aur JWT ko
samjhein.
6. Testing Strategies: Functional testing, performance testing, aur security testing ki
strategies seekhein.
7. Automation: Automation frameworks jaise RestAssured, JMeter, ya Selenium ke sath
API testing kaise karna hota hai.
8. Error Handling: API errors aur response codes (jese 200, 404, 500) ko samjhein.
In topics par acchi command hasil karke aap API testing mein proficient ho sakte hain.
4o mini
You said:
ChatGPT
HTTP methods web applications aur APIs ke sath communication ke liye use hote hain. Yeh
kuch common HTTP methods hain:
In methods ka istemal karte waqt, yeh dhyaan rakhna zaroori hai ke kaunsa method kaise aur kis
context mein use hota hai.
4o mini
You said:
ChatGPT
JSON (JavaScript Object Notation) aur XML (eXtensible Markup Language) dono data
interchange formats hain.
JSON:
Simple aur lightweight hota hai, human-readable format mein data ko key-value pairs
mein represent karta hai.
Example:
json
Copy code
{
"name": "Alice",
"age": 30,
"isStudent": false
}
XML:
More verbose aur flexible hota hai, tags ke sath structured data ko represent karta hai.
Example:
xml
Copy code
<person>
<name>Alice</name>
<age>30</age>
<isStudent>false</isStudent>
</person>
JSON zyada popular hai web APIs ke liye kyunki yeh concise aur easy to parse hai, jabki XML
ka istemal complex documents ke liye hota hai.
4o mini
You said:
ChatGPT
Functional testing, performance testing, aur security testing ke liye alag-alag strategies hoti hain.
Yahan inka summary diya gaya hai:
1. Functional Testing:
2. Performance Testing:
Objective: Application ki speed, scalability, aur stability ko test karein under varying
loads.
Strategies:
o Load Testing: Normal aur peak load conditions par application ka performance
measure karein.
o Stress Testing: Application ko usse zyada load dene ki koshish karein jisse wo
crash ho sakta hai.
o Endurance Testing: Long duration ke liye application ki performance check
karein.
o Spike Testing: Sudden load increase par application ka reaction check karein.
o Benchmark Testing: Application ki performance ko industry standards ya
previous versions ke sath compare karein.
3. Security Testing:
Objective: Application ko vulnerabilities se protect karne ke liye security measures ki
effectiveness test karein.
Strategies:
o Static Application Security Testing (SAST): Source code ke analysis se
vulnerabilities identify karein.
o Dynamic Application Security Testing (DAST): Running application par attack
vectors ko test karein.
o Penetration Testing: Ethical hackers ki madad se application ke security
measures ko test karein.
o Threat Modeling: Potential threats aur vulnerabilities ko identify karein aur unke
against defenses develop karein.
o Security Scanning: Automated tools se application ko scan karein taake known
vulnerabilities identify ho sakein.
In strategies ka istemal karke aap ek comprehensive testing approach develop kar sakte hain jo
application ki quality aur security ko ensure karegi.
Successful Responses
200 OK: The request was successful, and the server returned the requested data.
201 Created: The request was successful, and a new resource was created (often used in
POST requests).
204 No Content: The request was successful, but there is no content to return (commonly
used for DELETE requests).
Client Errors
400 Bad Request: The server could not understand the request due to invalid syntax.
401 Unauthorized: The request requires user authentication. The user must log in to
access the resource.
403 Forbidden: The server understood the request, but it refuses to authorize it (the user
does not have permission).
404 Not Found: The server could not find the requested resource. This often indicates
that the endpoint is incorrect or the resource does not exist.
409 Conflict: The request could not be completed due to a conflict with the current state
of the resource.
Server Errors
500 Internal Server Error: The server encountered an unexpected condition that
prevented it from fulfilling the request.
502 Bad Gateway: The server received an invalid response from an upstream server it
accessed while trying to fulfill the request.
503 Service Unavailable: The server is currently unable to handle the request due to
temporary overloading or maintenance of the server.
Additional Codes
301 Moved Permanently: The requested resource has been permanently moved to a new
URL.
302 Found: The requested resource is temporarily located at a different URL.
These response codes help developers diagnose issues with API calls and understand the status
of their requests. If you have specific questions about any codes or need further clarification, feel
free to ask!
Objective: Validate ke user correct aur incorrect credentials ke sath login kar sakta
hai ya nahi.
json
Copy code
{
"username": "testuser",
"password": "password123"
}
o Expected Response:
Status Code: 200 OK
Response Body:
json
Copy code
{
"message": "Login successful",
"user": {
"id": "123",
"name": "testuser"
}
}
o Validation: Status code 200 ho, aur "Login successful" message aaye.
json
Copy code
{
"username": "testuser",
"password": "wrongpass"
}
o Expected Response:
Status Code: 401 Unauthorized
Response Body:
json
Copy code
{
"error": "Invalid credentials"
}
o Validation: Status code 401 aur "Invalid credentials" ka error message aaye.
json
Copy code
{
"username": "",
"password": ""
}
o Expected Response:
Status Code: 400 Bad Request
Response Body:
json
Copy code
{
"error": "Username and password required"
}
o Validation: Status code 400 aur error message aaye "Username and password
required".
json
Copy code
{
"username": "' OR 1=1 --",
"password": "anyPassword"
}
o Expected Response:
Status Code: 400 Bad Request or 401 Unauthorized
Response Body:
json
Copy code
{
"error": "Invalid input"
}
o Validation: Status code 400 or 401 aur error message aaye jo SQL injection attempt ko
handle kare.
json
Copy code
{
"message": "Logout successful"
}
1. Create Requests: Har scenario ke liye ek request create karein aur expected inputs aur
responses ko configure karein.
2. Add Tests: Har request ke Tests tab me JavaScript code likhein jo status code aur response
body ko validate kare.
3. Run Collection: Sab requests ko ek collection me save karein aur Runner me open kar ke Run
karein.
4. View Results: Runner me detailed pass/fail results aur response times dekhein.
Is tarah ye Postman collection different login scenarios ko test karega aur expected outputs ko
validate karega.
4o
You said:
ChatGPT said:
ChatGPT
Postman me JSON file export krne ka primary purpose ye hai ke aap apne API requests aur
collections ko share, backup, aur automate kar saken. JSON file export karke aap ye actions le
sakte hain:
1. Share with Team: JSON file ko apne team ke members ke sath share kar sakte hain, jo
ise import karke same collection aur tests apne Postman pe use kar sakte hain.
2. Version Control: JSON file ko version control system (e.g., Git) me store kar sakte hain.
Is tarah, aap kisi bhi update ka track rakh sakte hain aur changes ko easily manage kar
sakte hain.
3. Automate Testing with Newman: JSON file ko Newman ke sath use karke command-line
se automated testing run ki ja sakti hai. Ye CI/CD pipelines me bhi helpful hai, jisme aap
collection ko Jenkins, GitLab, ya kisi aur CI tool se integrate kar sakte hain.
4. Backup and Restore: Exported JSON file ko backup ke tor pe rakh sakte hain aur agar
kisi bhi reason se Postman me collection delete ho jaye to ise easily import karke restore
kiya ja sakta hai.
Ye exported JSON file APIs ki documentation aur testing ko shareable aur maintainable banati
hai.
4o
You said:
ChatGPT said:
ChatGPT
Postman me in methods ko select kar ke aap API endpoints pe different actions perform aur test
kar sakte hain.
4o
You said: