SlideShare a Scribd company logo
1 of 36
99x.io
Web API testing
with Postman
By : Tharinda Liyanage
Agenda
• Software Testing and Test pyramid
• About APIs- classifications of APIs
• RESTful Web APIs
• Execute APIs using Postman
• Testing APIs with Postman
• Other features available with Postman
• Q&A
Software Testing
• The primary goal of software testing is to ensure that the software functions correctly, meets its
intended requirements, and delivers a satisfactory user experience.
• Quality Assurance/ quality control activities
• Functional and nonfunctional testing through manual and automated means
• Unit tests, API integration testing, Automated end to end testing, Exploratory testing
• API testing- GUI less . Tests are based on Request-Response and mainly focus on testing the
business logic
Software Test Pyramid
What is an API
• Application Programming Interface: Is a set of rules, protocols, and tools that allows
different software applications to communicate with each other
• It works as a bridge that enables one piece of software to use the functionality of another
piece of software, without needing to understand all the internal details of how that
software works (based on Specification)
• APIs specify the functions or methods that can be called by developers to perform specific
actions or operations.
• Different types of API
• OS APIs (Windows, Android)
• DB APIs
• Cloud APIs
• Social media APIs
• Web APIs
• are exposed over the internet (HTTP/HTTPS)
for remote access by other applications or developers.
Types of Web API
RESTful Web API
• REST API= “REpresentational State Transfer” Application Programming Interface
• Resources: Are the fundamental units of data that the API exposes. In REST, everything
is treated as a resource, and each resource is identified by a unique URL
• https://example.com/api/books/
• https://example.com/api/authors/
• https://example.com/api/categories/fiction
HTTP Methods
• REST APIs use standard HTTP methods (GET, POST, PUT, PATCH, DELETE) to perform CRUD
(Create, Read, Update, Delete) operations on resources.
REST API & JSON
• JSON= JavaScript Object Notation
• REST uses JSON as the format for exchanging data between the client and server
• JSON data is represented as a collection of key-value pairs. The keys are strings (enclosed
in double quotes)
{
"title": "The Catcher in the Rye",
"author": "J.D. Salinger",
"publicationyear": 1951,
"isbn": "978-0-316-76948-0",
"genre": "Coming-of-Age Fiction",
"language": "English",
"publisher": "Little, Brown and Company",
"pagecount": 277,
"rating": 4.0
}
What we test in API
• Functionality Testing:
• Test the functionality of different API endpoints or methods, including both positive and negative test cases.
• Verify that the API performs the intended operations, such as creating, reading, updating, and deleting data.
• Request and Response Validation:
• Verify that API requests are processed correctly and return the expected responses.
• Check the correctness of HTTP status codes (e.g., 200 OK, 404 Not Found, 500 Internal Server Error) in response to different requests.
• Headers verification (Content-Type, Content-length))
• Data Accuracy:
• Ensure that the data returned by the API is accurate and matches the expected values. This includes checking response payloads, data
formats (e.g., JSON, XML), and data types (e.g., strings, numbers, dates).
• Security Testing:
• Conduct security testing to identify vulnerabilities such as SQL injection, cross-site scripting (XSS), and other security risks.
• Ensure that sensitive data is protected, and access controls are properly implemented.
• Performance and Load Testing:
• Evaluate the API's performance by measuring response times, throughput, and scalability.
• Conduct load testing to determine how the API performs under heavy loads and concurrent requests.
The goal is to ensure that the API functions correctly and meets its intended requirements
1.Functionality verification
2.Status code verification
3.JSON schema verification
4.Response body verification
5.Header verification
6.Performance (response time, error rate)
7.Security (sec headers, auth etc.)
We can perform test manually and using test scripts in
Postman
What we test in API
Postman
• https://www.postman.com/
• Current version 10
• Postman is an API platform for building and Testing APIs
• Create an Postman account to access all the features and Postman cloud
• VS code plugin and browser extensions also available
• Free and paid license
• Features available for scheduling, performance testing
Demo use case
• Part of “Book management” Restful web service has been developed (the backend), but
there is no front-end UI is created yet, But still we need to verify that backend methods
are working as expected.
• Search/Read all books
• Search/Read a book based on ID or ISBN
• Create a book
• Update book
• Delete book
Demo scenarios
• Create a workspace
• Create a collection
• Add requests
• Create Environment
• Parameterization through variables stored in Environment and collection
• Write and execute Tests scripts (expected vs actual)
Environment details
http://52.230.26.246:3000/
API Endpoints
GET http://52.230.26.246:3000/api/books
GET http://52.230.26.246:3000/books?isbn=978-0-544-
27349-9&id=64ec4940ef68ef5a1e9b0d69
1. GET All Books
2. GET a book by ID OR/AND ISBN
API Endpoints
GET
http://52.230.26.246:3000/api/books/6502de862a9942dab57de107
POST http://52.230.26.246:3000/api/books
3. GET book by ID
4. Create a new book
{
"title": "The Catcher in the Rye",
"author": "J.D. Salinger",
"publicationyear": 1951,
"isbn": "978-0-316-76948-0",
"genre": "Coming-of-Age Fiction",
"language": "English",
"publisher": "Little, Brown and Company",
"pagecount": 277,
"rating": 4
}
API Endpoints
PUT
http://52.230.26.246:3000/api/books/6502de862a9942dab57de107
PATCH
http://52.230.26.246:3000/api/books/6502de862a9942dab57de107
5. Update book
6. Partially Update book
{
"title": "The Catcher in the Rye",
"author": "J.D. Salinger",
"publicationyear": 1966,
"isbn": "978-0-316-76948-0",
"genre": "Coming-of-Age Fiction",
"language": "English",
"publisher": "Little, Brown and Company",
"pagecount": 277,
"rating": 4
}
{
"language": "English"
}
API Endpoints
DELETE
http://52.230.26.246:3000/api/books/6502de862a9942dab57de107
5. Delete book
Variables
• Scope:
• Global
• Environment
• Collection
• Creation:
• Manually
• Programmatically
• Usage: {{variable name}}
Writing Test scripts in Postman
• Write tests manually
• Use code snippets
• Ask AI bot to create tests
Write tests using "pm" object
pm.test
pm.expect
pm.response
pm.environment
pm.test(“name of the test", function ()
{
//code and test assertions
});
Test to verify response status code
• 3-digit codes that indicates outcome of an API request
• They are included in the API response
Test to verify response status code
Test to verify properties of the response
Test to verify headers
Headers are metadata components of an HTTP request or response that
provide information about the data being sent or received
Request Headers:
•Host: Specifies the domain name of the target server.
•User-Agent: Provides information about the client making the request (e.g., the browser and its
version).
•Accept: Indicates the media types (e.g., HTML, XML, JSON) that the client can process.
•Authorization: Contains credentials to authenticate the client with the server.
•Cookie: Carries client-specific data for server sessions.
Response Headers:
•Status Code: Informs the client about the result of the request
(e.g., 200 for success, 404 for not found, 500 for server error).
•Content-Type: Specifies the format of the content (e.g.,
text/html, application/json).
•Content-Length: Indicates the size of the response content in
bytes.
Test to verify headers
Test to verify Performance
Performance testing for APIs is essential to ensure that APIs can handle the expected load and perform
efficiently under various conditions
Response Time Measurement:
Measure the response times for API requests under different load conditions and compare them to
performance objectives.
Load Testing:
Conduct load testing to determine how the API behaves under expected load conditions. Gradually
increase the load until performance degrades or fails to meet your defined criteria.
Stress Testing:
Perform stress testing by increasing the load beyond the system's expected capacity. This helps
identify the system's breaking point and any potential bottlenecks or performance issues under
extreme conditions.
Scalability Testing:
Evaluate the API's scalability by adding more resources, such as servers, and measuring how it
responds to increased demand
Test to verify response time
Test to verify API security
Authentication and Authorization Testing
Input Validation and Parameter Tampering Testing:
Rate Limiting and Resource Throttling
Security Scanning and Penetration Testing
Security Headers and CORS Policies
Security testing for APIs (Application Programming Interfaces) is crucial to ensure the security of data and
resources in your application
Test to verify security headers
HTTP security headers are a set of HTTP response headers that web servers can use to enhance the
security of web applications and protect against various web-related attacks.
X-Powered-By header describes the technologies used by the webserver. This information exposes the
server to attackers
Strict-Transport-Security (HSTS): HSTS ensures that a web application communicates over HTTPS only,
even if the user tries to access it via HTTP. This helps prevent man-in-the-middle attacks and SSL-stripping.
X-Frame-Options: This header helps prevent clickjacking attacks by specifying whether a web page can be
displayed in an iframe. It can be set to "DENY" to disallow framing, or "SAMEORIGIN" to allow framing only
from the same origin.
Test to verify security headers
Other features
• Collection runs –manually, scheduled, CI pipeline​
• Performance testing
Q&A
99x.io
Thank You!

More Related Content

What's hot

API Test Automation
API Test Automation API Test Automation
API Test Automation SQALab
 
Postman Introduction
Postman IntroductionPostman Introduction
Postman IntroductionRahul Agarwal
 
How to Automate API Testing
How to Automate API TestingHow to Automate API Testing
How to Automate API TestingBruno Pedro
 
Test Design and Automation for REST API
Test Design and Automation for REST APITest Design and Automation for REST API
Test Design and Automation for REST APIIvan Katunou
 
API Automation Testing Using RestAssured+Cucumber
API Automation Testing Using RestAssured+CucumberAPI Automation Testing Using RestAssured+Cucumber
API Automation Testing Using RestAssured+CucumberKnoldus Inc.
 
Postman Webinar: “Continuous Testing with Postman”
Postman Webinar: “Continuous Testing with Postman”Postman Webinar: “Continuous Testing with Postman”
Postman Webinar: “Continuous Testing with Postman”Postman
 
Postman. From simple API test to end to end scenario
Postman. From simple API test to end to end scenarioPostman. From simple API test to end to end scenario
Postman. From simple API test to end to end scenarioHYS Enterprise
 
Postman: An Introduction for Testers
Postman: An Introduction for TestersPostman: An Introduction for Testers
Postman: An Introduction for TestersPostman
 
API Test Automation Tips and Tricks
API Test Automation Tips and TricksAPI Test Automation Tips and Tricks
API Test Automation Tips and Trickstesthive
 
API Testing Presentations.pptx
API Testing Presentations.pptxAPI Testing Presentations.pptx
API Testing Presentations.pptxManmitSalunke
 
Postman 101 & Office Hours
Postman 101 & Office HoursPostman 101 & Office Hours
Postman 101 & Office HoursPostman
 
Postman & API Testing by Amber Race
Postman & API Testing by Amber RacePostman & API Testing by Amber Race
Postman & API Testing by Amber RacePostman
 
Codemotion Madrid 2023 - Testcontainers y Spring Boot
Codemotion Madrid 2023 - Testcontainers y Spring BootCodemotion Madrid 2023 - Testcontainers y Spring Boot
Codemotion Madrid 2023 - Testcontainers y Spring BootIván López Martín
 

What's hot (20)

API Test Automation
API Test Automation API Test Automation
API Test Automation
 
API Testing for everyone.pptx
API Testing for everyone.pptxAPI Testing for everyone.pptx
API Testing for everyone.pptx
 
Postman Introduction
Postman IntroductionPostman Introduction
Postman Introduction
 
API TESTING
API TESTINGAPI TESTING
API TESTING
 
Cucumber ppt
Cucumber pptCucumber ppt
Cucumber ppt
 
Api testing
Api testingApi testing
Api testing
 
How to Automate API Testing
How to Automate API TestingHow to Automate API Testing
How to Automate API Testing
 
Test Design and Automation for REST API
Test Design and Automation for REST APITest Design and Automation for REST API
Test Design and Automation for REST API
 
API Automation Testing Using RestAssured+Cucumber
API Automation Testing Using RestAssured+CucumberAPI Automation Testing Using RestAssured+Cucumber
API Automation Testing Using RestAssured+Cucumber
 
Postman Webinar: “Continuous Testing with Postman”
Postman Webinar: “Continuous Testing with Postman”Postman Webinar: “Continuous Testing with Postman”
Postman Webinar: “Continuous Testing with Postman”
 
Postman. From simple API test to end to end scenario
Postman. From simple API test to end to end scenarioPostman. From simple API test to end to end scenario
Postman. From simple API test to end to end scenario
 
Postman
PostmanPostman
Postman
 
Postman: An Introduction for Testers
Postman: An Introduction for TestersPostman: An Introduction for Testers
Postman: An Introduction for Testers
 
API Test Automation Tips and Tricks
API Test Automation Tips and TricksAPI Test Automation Tips and Tricks
API Test Automation Tips and Tricks
 
API Testing Presentations.pptx
API Testing Presentations.pptxAPI Testing Presentations.pptx
API Testing Presentations.pptx
 
Api Testing
Api TestingApi Testing
Api Testing
 
Postman 101 & Office Hours
Postman 101 & Office HoursPostman 101 & Office Hours
Postman 101 & Office Hours
 
Postman & API Testing by Amber Race
Postman & API Testing by Amber RacePostman & API Testing by Amber Race
Postman & API Testing by Amber Race
 
Codemotion Madrid 2023 - Testcontainers y Spring Boot
Codemotion Madrid 2023 - Testcontainers y Spring BootCodemotion Madrid 2023 - Testcontainers y Spring Boot
Codemotion Madrid 2023 - Testcontainers y Spring Boot
 
Soap ui
Soap uiSoap ui
Soap ui
 

Similar to API testing - Japura.pptx

B4USolution_API-Testing
B4USolution_API-TestingB4USolution_API-Testing
B4USolution_API-Testingb4usolution .
 
API Testing with Open Source Code and Cucumber
API Testing with Open Source Code and CucumberAPI Testing with Open Source Code and Cucumber
API Testing with Open Source Code and CucumberSmartBear
 
Do not automate GUI testing
Do not automate GUI testingDo not automate GUI testing
Do not automate GUI testingAtila Inovecký
 
What is API test automation
What is API test automation What is API test automation
What is API test automation Aparna Sharma
 
An introduction to the API for OnTime for IBM
An introduction to the API for OnTime for IBMAn introduction to the API for OnTime for IBM
An introduction to the API for OnTime for IBMontimesuite
 
apidays LIVE Paris 2021 - Inside API delivery Pipeline, the checklist! - Fran...
apidays LIVE Paris 2021 - Inside API delivery Pipeline, the checklist! - Fran...apidays LIVE Paris 2021 - Inside API delivery Pipeline, the checklist! - Fran...
apidays LIVE Paris 2021 - Inside API delivery Pipeline, the checklist! - Fran...apidays
 
Building Better Web APIs with Rails
Building Better Web APIs with RailsBuilding Better Web APIs with Rails
Building Better Web APIs with RailsAll Things Open
 
API Check Overview - Rigor Monitoring
API Check Overview - Rigor MonitoringAPI Check Overview - Rigor Monitoring
API Check Overview - Rigor MonitoringAnthony Ferrari
 
automated-automation-of-rest-apis.pptx
automated-automation-of-rest-apis.pptxautomated-automation-of-rest-apis.pptx
automated-automation-of-rest-apis.pptxAditya274010
 
GraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer toolsGraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer toolsSashko Stubailo
 
Practices and tools for building better APIs
Practices and tools for building better APIsPractices and tools for building better APIs
Practices and tools for building better APIsNLJUG
 
Practices and tools for building better API (JFall 2013)
Practices and tools for building better API (JFall 2013)Practices and tools for building better API (JFall 2013)
Practices and tools for building better API (JFall 2013)Peter Hendriks
 
Practices and Tools for Building Better APIs
Practices and Tools for Building Better APIsPractices and Tools for Building Better APIs
Practices and Tools for Building Better APIsPeter Hendriks
 
AWS Summit Barcelona 2015 - Introducing Amazon API Gateway
AWS Summit Barcelona 2015 - Introducing Amazon API GatewayAWS Summit Barcelona 2015 - Introducing Amazon API Gateway
AWS Summit Barcelona 2015 - Introducing Amazon API GatewayVadim Zendejas
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformAntonio Peric-Mazar
 
Top 11 api testing tools for 2022
Top 11 api testing tools for 2022Top 11 api testing tools for 2022
Top 11 api testing tools for 2022Aparna Sharma
 
Aws Technical Day 2015 - Amazon API Gateway
Aws Technical Day 2015 - Amazon API GatewayAws Technical Day 2015 - Amazon API Gateway
Aws Technical Day 2015 - Amazon API Gatewayaws-marketing-il
 

Similar to API testing - Japura.pptx (20)

B4USolution_API-Testing
B4USolution_API-TestingB4USolution_API-Testing
B4USolution_API-Testing
 
API Testing with Open Source Code and Cucumber
API Testing with Open Source Code and CucumberAPI Testing with Open Source Code and Cucumber
API Testing with Open Source Code and Cucumber
 
Webservicex.pdf
Webservicex.pdfWebservicex.pdf
Webservicex.pdf
 
Do not automate GUI testing
Do not automate GUI testingDo not automate GUI testing
Do not automate GUI testing
 
What is API test automation
What is API test automation What is API test automation
What is API test automation
 
An introduction to the API for OnTime for IBM
An introduction to the API for OnTime for IBMAn introduction to the API for OnTime for IBM
An introduction to the API for OnTime for IBM
 
apidays LIVE Paris 2021 - Inside API delivery Pipeline, the checklist! - Fran...
apidays LIVE Paris 2021 - Inside API delivery Pipeline, the checklist! - Fran...apidays LIVE Paris 2021 - Inside API delivery Pipeline, the checklist! - Fran...
apidays LIVE Paris 2021 - Inside API delivery Pipeline, the checklist! - Fran...
 
Building Better Web APIs with Rails
Building Better Web APIs with RailsBuilding Better Web APIs with Rails
Building Better Web APIs with Rails
 
REST APIs
REST APIsREST APIs
REST APIs
 
API Check Overview - Rigor Monitoring
API Check Overview - Rigor MonitoringAPI Check Overview - Rigor Monitoring
API Check Overview - Rigor Monitoring
 
automated-automation-of-rest-apis.pptx
automated-automation-of-rest-apis.pptxautomated-automation-of-rest-apis.pptx
automated-automation-of-rest-apis.pptx
 
GraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer toolsGraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer tools
 
Practices and tools for building better APIs
Practices and tools for building better APIsPractices and tools for building better APIs
Practices and tools for building better APIs
 
Practices and tools for building better API (JFall 2013)
Practices and tools for building better API (JFall 2013)Practices and tools for building better API (JFall 2013)
Practices and tools for building better API (JFall 2013)
 
AWS API Gateway
AWS API GatewayAWS API Gateway
AWS API Gateway
 
Practices and Tools for Building Better APIs
Practices and Tools for Building Better APIsPractices and Tools for Building Better APIs
Practices and Tools for Building Better APIs
 
AWS Summit Barcelona 2015 - Introducing Amazon API Gateway
AWS Summit Barcelona 2015 - Introducing Amazon API GatewayAWS Summit Barcelona 2015 - Introducing Amazon API Gateway
AWS Summit Barcelona 2015 - Introducing Amazon API Gateway
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API Platform
 
Top 11 api testing tools for 2022
Top 11 api testing tools for 2022Top 11 api testing tools for 2022
Top 11 api testing tools for 2022
 
Aws Technical Day 2015 - Amazon API Gateway
Aws Technical Day 2015 - Amazon API GatewayAws Technical Day 2015 - Amazon API Gateway
Aws Technical Day 2015 - Amazon API Gateway
 

Recently uploaded

call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........LeaCamillePacle
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxLigayaBacuel1
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 

Recently uploaded (20)

call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"
 

API testing - Japura.pptx

  • 1. 99x.io Web API testing with Postman By : Tharinda Liyanage
  • 2. Agenda • Software Testing and Test pyramid • About APIs- classifications of APIs • RESTful Web APIs • Execute APIs using Postman • Testing APIs with Postman • Other features available with Postman • Q&A
  • 3. Software Testing • The primary goal of software testing is to ensure that the software functions correctly, meets its intended requirements, and delivers a satisfactory user experience. • Quality Assurance/ quality control activities • Functional and nonfunctional testing through manual and automated means • Unit tests, API integration testing, Automated end to end testing, Exploratory testing • API testing- GUI less . Tests are based on Request-Response and mainly focus on testing the business logic
  • 5. What is an API • Application Programming Interface: Is a set of rules, protocols, and tools that allows different software applications to communicate with each other • It works as a bridge that enables one piece of software to use the functionality of another piece of software, without needing to understand all the internal details of how that software works (based on Specification) • APIs specify the functions or methods that can be called by developers to perform specific actions or operations. • Different types of API • OS APIs (Windows, Android) • DB APIs • Cloud APIs • Social media APIs • Web APIs • are exposed over the internet (HTTP/HTTPS) for remote access by other applications or developers.
  • 7.
  • 8. RESTful Web API • REST API= “REpresentational State Transfer” Application Programming Interface • Resources: Are the fundamental units of data that the API exposes. In REST, everything is treated as a resource, and each resource is identified by a unique URL • https://example.com/api/books/ • https://example.com/api/authors/ • https://example.com/api/categories/fiction
  • 9. HTTP Methods • REST APIs use standard HTTP methods (GET, POST, PUT, PATCH, DELETE) to perform CRUD (Create, Read, Update, Delete) operations on resources.
  • 10. REST API & JSON • JSON= JavaScript Object Notation • REST uses JSON as the format for exchanging data between the client and server • JSON data is represented as a collection of key-value pairs. The keys are strings (enclosed in double quotes) { "title": "The Catcher in the Rye", "author": "J.D. Salinger", "publicationyear": 1951, "isbn": "978-0-316-76948-0", "genre": "Coming-of-Age Fiction", "language": "English", "publisher": "Little, Brown and Company", "pagecount": 277, "rating": 4.0 }
  • 11.
  • 12. What we test in API • Functionality Testing: • Test the functionality of different API endpoints or methods, including both positive and negative test cases. • Verify that the API performs the intended operations, such as creating, reading, updating, and deleting data. • Request and Response Validation: • Verify that API requests are processed correctly and return the expected responses. • Check the correctness of HTTP status codes (e.g., 200 OK, 404 Not Found, 500 Internal Server Error) in response to different requests. • Headers verification (Content-Type, Content-length)) • Data Accuracy: • Ensure that the data returned by the API is accurate and matches the expected values. This includes checking response payloads, data formats (e.g., JSON, XML), and data types (e.g., strings, numbers, dates). • Security Testing: • Conduct security testing to identify vulnerabilities such as SQL injection, cross-site scripting (XSS), and other security risks. • Ensure that sensitive data is protected, and access controls are properly implemented. • Performance and Load Testing: • Evaluate the API's performance by measuring response times, throughput, and scalability. • Conduct load testing to determine how the API performs under heavy loads and concurrent requests. The goal is to ensure that the API functions correctly and meets its intended requirements
  • 13. 1.Functionality verification 2.Status code verification 3.JSON schema verification 4.Response body verification 5.Header verification 6.Performance (response time, error rate) 7.Security (sec headers, auth etc.) We can perform test manually and using test scripts in Postman What we test in API
  • 14. Postman • https://www.postman.com/ • Current version 10 • Postman is an API platform for building and Testing APIs • Create an Postman account to access all the features and Postman cloud • VS code plugin and browser extensions also available • Free and paid license • Features available for scheduling, performance testing
  • 15. Demo use case • Part of “Book management” Restful web service has been developed (the backend), but there is no front-end UI is created yet, But still we need to verify that backend methods are working as expected. • Search/Read all books • Search/Read a book based on ID or ISBN • Create a book • Update book • Delete book
  • 16. Demo scenarios • Create a workspace • Create a collection • Add requests • Create Environment • Parameterization through variables stored in Environment and collection • Write and execute Tests scripts (expected vs actual)
  • 18. API Endpoints GET http://52.230.26.246:3000/api/books GET http://52.230.26.246:3000/books?isbn=978-0-544- 27349-9&id=64ec4940ef68ef5a1e9b0d69 1. GET All Books 2. GET a book by ID OR/AND ISBN
  • 19. API Endpoints GET http://52.230.26.246:3000/api/books/6502de862a9942dab57de107 POST http://52.230.26.246:3000/api/books 3. GET book by ID 4. Create a new book { "title": "The Catcher in the Rye", "author": "J.D. Salinger", "publicationyear": 1951, "isbn": "978-0-316-76948-0", "genre": "Coming-of-Age Fiction", "language": "English", "publisher": "Little, Brown and Company", "pagecount": 277, "rating": 4 }
  • 20. API Endpoints PUT http://52.230.26.246:3000/api/books/6502de862a9942dab57de107 PATCH http://52.230.26.246:3000/api/books/6502de862a9942dab57de107 5. Update book 6. Partially Update book { "title": "The Catcher in the Rye", "author": "J.D. Salinger", "publicationyear": 1966, "isbn": "978-0-316-76948-0", "genre": "Coming-of-Age Fiction", "language": "English", "publisher": "Little, Brown and Company", "pagecount": 277, "rating": 4 } { "language": "English" }
  • 22. Variables • Scope: • Global • Environment • Collection • Creation: • Manually • Programmatically • Usage: {{variable name}}
  • 23. Writing Test scripts in Postman • Write tests manually • Use code snippets • Ask AI bot to create tests Write tests using "pm" object pm.test pm.expect pm.response pm.environment pm.test(“name of the test", function () { //code and test assertions });
  • 24. Test to verify response status code • 3-digit codes that indicates outcome of an API request • They are included in the API response
  • 25. Test to verify response status code
  • 26. Test to verify properties of the response
  • 27. Test to verify headers Headers are metadata components of an HTTP request or response that provide information about the data being sent or received Request Headers: •Host: Specifies the domain name of the target server. •User-Agent: Provides information about the client making the request (e.g., the browser and its version). •Accept: Indicates the media types (e.g., HTML, XML, JSON) that the client can process. •Authorization: Contains credentials to authenticate the client with the server. •Cookie: Carries client-specific data for server sessions. Response Headers: •Status Code: Informs the client about the result of the request (e.g., 200 for success, 404 for not found, 500 for server error). •Content-Type: Specifies the format of the content (e.g., text/html, application/json). •Content-Length: Indicates the size of the response content in bytes.
  • 28. Test to verify headers
  • 29. Test to verify Performance Performance testing for APIs is essential to ensure that APIs can handle the expected load and perform efficiently under various conditions Response Time Measurement: Measure the response times for API requests under different load conditions and compare them to performance objectives. Load Testing: Conduct load testing to determine how the API behaves under expected load conditions. Gradually increase the load until performance degrades or fails to meet your defined criteria. Stress Testing: Perform stress testing by increasing the load beyond the system's expected capacity. This helps identify the system's breaking point and any potential bottlenecks or performance issues under extreme conditions. Scalability Testing: Evaluate the API's scalability by adding more resources, such as servers, and measuring how it responds to increased demand
  • 30. Test to verify response time
  • 31. Test to verify API security Authentication and Authorization Testing Input Validation and Parameter Tampering Testing: Rate Limiting and Resource Throttling Security Scanning and Penetration Testing Security Headers and CORS Policies Security testing for APIs (Application Programming Interfaces) is crucial to ensure the security of data and resources in your application
  • 32. Test to verify security headers HTTP security headers are a set of HTTP response headers that web servers can use to enhance the security of web applications and protect against various web-related attacks. X-Powered-By header describes the technologies used by the webserver. This information exposes the server to attackers Strict-Transport-Security (HSTS): HSTS ensures that a web application communicates over HTTPS only, even if the user tries to access it via HTTP. This helps prevent man-in-the-middle attacks and SSL-stripping. X-Frame-Options: This header helps prevent clickjacking attacks by specifying whether a web page can be displayed in an iframe. It can be set to "DENY" to disallow framing, or "SAMEORIGIN" to allow framing only from the same origin.
  • 33. Test to verify security headers
  • 34. Other features • Collection runs –manually, scheduled, CI pipeline​ • Performance testing
  • 35. Q&A