SlideShare ist ein Scribd-Unternehmen logo
1 von 31
API Testing with
Rest Assured & TestNG
Topics to be covered
• What is REST assured ?
• Postman vs REST Assured
• What is REST, its Constraints and Architectural Elements .
• Pre Requisite and Requirement.
• Headers and Parameter.
• GET Request using REST Assured
• Authentication and Authorization in Web Services
• POST Request Using REST Assured.
• Data Driven Test Using REST Assured.
Common Architecture of Rest Assured
What is REST Assured ?
• REST Assured is a Java library .
Which, provides a domain-specific language (DSL) for writing powerful,
maintainable tests for Restful APIs.
• Library behaves like a headless Client to access REST web services.
• Highly Customized HTTP Request can be created to REST Servers.
• Testing and validating REST services in Java is harder than in dynamic
languages such as Ruby and Groovy.
Postman vs REST Assured
• Postman - Tool for Exploratory Testing/Manual Testing and Automation
Testing.
• REST Assured - Java Library for Validating Web Services.
• Postman takes lesser time than REST Assured . For best results it is better
to consider both.
• Code Reusability can be done in REST Assured Since, it is a Java Client. But,
in Postman we need to copy request from one collection to another.
• Both Postman and REST Assured can be integrated using Jenkins using
Newman Tool. In REST Assured Maven can be used for Jenkins.
WHAT is REST ?
• REST is an acronym for Representational State Transfer.
• It is an architectural style for distributed hypermedia systems.
• Representation State Transfer (REST) is a set of constraints.
Constraints
• Client Server Architecture
• Stateless
• Cache
• Uniform Interface
• Layered System
• Code on Demand (Optional)
Constrains
Client – Server- Both Client-Server should be separated to
evolve independently . Client should not know about Business
Layer/Logic or data access layer. Server should not know front end
UI.
Stateless - Server should not store context of the Client.
Which, improves scalability.
Cache - Responses from the server should contain relevant
information to tell whether the Response can be cached by the
client or not.
• Client’s efficiency is improved for cacheable responses where
Client need not make requests to the server. This makes REST API
time efficient.
Constraint (contd.)
Uniform Interface
• It Simplifies and decouples the architecture. Which enables each part
to evolve independently.
• Identification & Manipulation of resources through these
representations.
Layered System
• System implementation should be of multiple layers. Eg. MVC
• Layer should not know about the existence of other layers apart from
the layers that it directly interacts with.
• It decreases the complexity of different component within the system.
• Model-Data, View – Output and Controller – Incoming requests.
Rest Architectural Elements
• Resource - Information stored on a Server, which can be requested by a
client.
• Resource Identifier - Need to uniquely identify the resource. That is
actually the complete URL.
• Representation - Resource is an actual data which can be represented as
an XML, HTML or may be simple text. It is called a Representation.
• Representation Metadata – It is an extra data needs to be passed in the
request. In order for the Clients to specify and process a resources given in
a particular Representation
Domain , URI and Query String
Headers and Parameters
• REST headers and parameters contain a wealth of information that
can help you track down issues when you encounter them. For eg.
HTTP connection types, proxies etc.
Headers carry information for
• Request and Response Body
• Request Authorization
• Response Caching
• Response Cookies
Headers
• Headers are mostly classified as request headers and response
headers.
• Headers that should be considered in API testing are the following
• Authorization
• WWW-Authenticate
• Accept-Charset
• Content-Type
• Cache-Control
Parameters
• REST parameters specify the variable parts of your resources.
• URL (Uniform Resource Locator) is a special case of the URI Uniform
Resource Identifier.
• URI consist of four parts.
• scheme_name:hierarchical_part?query#fragment
• Path Parameter
• Query Parameter
• Fragment Parameter
Path parameter & Query parameter
• Path Parameter- Parameters within the path of the endpoint,
before the query string (?). These are usually set off within
curly braces.
• Query parameter appears after “?” in the URL. It comes after
resource path. Following is the example for query parameter.
Path parameter & Query parameter
Pre Requisites and Requirement.
• Basic Knowledge of Java Programming Language and OOPS
Concepts.
• Eclipse IDE (Java) Installed in PC or Laptop.
• Basic Knowledge of Maven Build Tool, Test NG and
Dependencies.
• Basic Knowledge about Web API and Web Services .
Dependencies Required
• Dependencies are another archived—JAR or ZIP which are for
projects in order to compile, build, test, and/or to run.
• The dependencies are gathered in the pom. xml file, inside of a
<dependencies> tag.
• List of Dependencies
• TEST NG
• J unit
• Apache POI
• REST Assured
• Google Simple JSON
Dependencies in POM.xml
List of Dependencies
• Test NG is an automation framework. NG stands for “Next Generation”
• Test NG overcomes disadvantages of J unit.
• Test NG can be integrated with tools like
Maven and Jenkins.
• Apache POI’s purpose is to create and maintain Java APIs for manipulating
various file formats based upon the Office Open XML standards.
• Google JSON.Simple – simple Java toolkit for JSON
GET Request using REST Assured
• Some Points about GET Request
• GET requests can only be used to retrieve data not to modify and it
can be cached.
• GET requests are less secure and should be avoided when trying to
retrieve data from a sensitive resource.
• GET requests parameter data is limited as there are length restrictions
and it can be bookmarked.
• GET requests are prone to get hacked easily.
GET Request using REST Assured
• Dummy API has been taken https://reqres.in/api/users/
GET Request using REST Assured
GET Request using REST Assured
Authentication and Authorization in
Web Services
• Authentication is a process to prove that user is the person who is
intended to access API.
• API’s require to provide identification to make REST API Secure
Identification used are
• Username and a Password
• Authentication tokens
• Secret keys
• Bio-metrics and many other ways
• First 3 identification are used in REST APIs
Contd.
• REST request can have a special header called Authorization Header.
• Header contain the credentials (username and password) in some
form.
• Once a request with Authorization Header is received, server can
validate the credentials and can let you access the private resources.
Basic Authentication
• Pre-emptive and Challenged are the forms of Basic Authentication.
• Pre-emptive sends the basic authentication credentials even before
the server gives an unauthorized response in certain situation.
• It reduces the overhead of making an additional connection.
• In Challenged basic authentication server will not supply credentials
unless server explicitly asked for it.
• This means additional request will be made in order to be challenged
and then followed.
Basic Authentication using Pre-Emptive
POST Request in REST Assured
• POST is the HTTP method that is designed to send loads of data to a
server from a specified resource.
• POST method will not be visible in the URL, as parameters are not
sent along with the URI.
• Format of an HTTP POST should have HTTP headers, followed by a
blank line, followed by the request body.
• Content-Type header indicates the type of body in the POST request.
POST Request in REST Assured
POST Request with multiple data
API Testing Using REST Assured with TestNG

Weitere ähnliche Inhalte

Was ist angesagt?

An Introduction To Automated API Testing
An Introduction To Automated API TestingAn Introduction To Automated API Testing
An Introduction To Automated API TestingSauce Labs
 
API Testing: The heart of functional testing" with Bj Rollison
API Testing: The heart of functional testing" with Bj RollisonAPI Testing: The heart of functional testing" with Bj Rollison
API Testing: The heart of functional testing" with Bj RollisonTEST Huddle
 
API Test Automation Using Karate (Anil Kumar Moka)
API Test Automation Using Karate (Anil Kumar Moka)API Test Automation Using Karate (Anil Kumar Moka)
API Test Automation Using Karate (Anil Kumar Moka)Peter Thomas
 
Rest API Testing
Rest API TestingRest API Testing
Rest API Testingupadhyay_25
 
Test in Rest. API testing with the help of Rest Assured.
Test in Rest. API testing with the help of  Rest Assured.Test in Rest. API testing with the help of  Rest Assured.
Test in Rest. API testing with the help of Rest Assured.Artem Korchevyi
 
2015-StarWest presentation on REST-assured
2015-StarWest presentation on REST-assured2015-StarWest presentation on REST-assured
2015-StarWest presentation on REST-assuredEing Ong
 
Testing RESTful Webservices using the REST-assured framework
Testing RESTful Webservices using the REST-assured frameworkTesting RESTful Webservices using the REST-assured framework
Testing RESTful Webservices using the REST-assured frameworkMicha Kops
 
Accelerate Quality with Postman - Basics
Accelerate Quality with Postman - BasicsAccelerate Quality with Postman - Basics
Accelerate Quality with Postman - BasicsKnoldus Inc.
 
API Testing. Streamline your testing process.
API Testing. Streamline your testing process.API Testing. Streamline your testing process.
API Testing. Streamline your testing process.Andrey Oleynik
 
Postman Introduction
Postman IntroductionPostman Introduction
Postman IntroductionRahul Agarwal
 
Postman 101 for Students
Postman 101 for StudentsPostman 101 for Students
Postman 101 for StudentsPostman
 
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
 

Was ist angesagt? (20)

An Introduction To Automated API Testing
An Introduction To Automated API TestingAn Introduction To Automated API Testing
An Introduction To Automated API Testing
 
Api Testing
Api TestingApi Testing
Api Testing
 
Postman
PostmanPostman
Postman
 
API Testing: The heart of functional testing" with Bj Rollison
API Testing: The heart of functional testing" with Bj RollisonAPI Testing: The heart of functional testing" with Bj Rollison
API Testing: The heart of functional testing" with Bj Rollison
 
API Test Automation Using Karate (Anil Kumar Moka)
API Test Automation Using Karate (Anil Kumar Moka)API Test Automation Using Karate (Anil Kumar Moka)
API Test Automation Using Karate (Anil Kumar Moka)
 
Rest assured
Rest assuredRest assured
Rest assured
 
Rest API Testing
Rest API TestingRest API Testing
Rest API Testing
 
Test in Rest. API testing with the help of Rest Assured.
Test in Rest. API testing with the help of  Rest Assured.Test in Rest. API testing with the help of  Rest Assured.
Test in Rest. API testing with the help of Rest Assured.
 
2015-StarWest presentation on REST-assured
2015-StarWest presentation on REST-assured2015-StarWest presentation on REST-assured
2015-StarWest presentation on REST-assured
 
Testing RESTful Webservices using the REST-assured framework
Testing RESTful Webservices using the REST-assured frameworkTesting RESTful Webservices using the REST-assured framework
Testing RESTful Webservices using the REST-assured framework
 
Accelerate Quality with Postman - Basics
Accelerate Quality with Postman - BasicsAccelerate Quality with Postman - Basics
Accelerate Quality with Postman - Basics
 
API Testing for everyone.pptx
API Testing for everyone.pptxAPI Testing for everyone.pptx
API Testing for everyone.pptx
 
Rest Assured
Rest AssuredRest Assured
Rest Assured
 
API Testing. Streamline your testing process.
API Testing. Streamline your testing process.API Testing. Streamline your testing process.
API Testing. Streamline your testing process.
 
Postman Introduction
Postman IntroductionPostman Introduction
Postman Introduction
 
Postman 101 for Students
Postman 101 for StudentsPostman 101 for Students
Postman 101 for Students
 
Api testing
Api testingApi testing
Api testing
 
Postman.ppt
Postman.pptPostman.ppt
Postman.ppt
 
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
 
Belajar Postman test runner
Belajar Postman test runnerBelajar Postman test runner
Belajar Postman test runner
 

Ähnlich wie API Testing Using REST Assured with TestNG

restapitest-anil-200517181251.pdf
restapitest-anil-200517181251.pdfrestapitest-anil-200517181251.pdf
restapitest-anil-200517181251.pdfmrle7
 
Overview of REST - Raihan Ullah
Overview of REST - Raihan UllahOverview of REST - Raihan Ullah
Overview of REST - Raihan UllahCefalo
 
Rest WebAPI with OData
Rest WebAPI with ODataRest WebAPI with OData
Rest WebAPI with ODataMahek Merchant
 
REST API Recommendations
REST API RecommendationsREST API Recommendations
REST API RecommendationsJeelani Shaik
 
Ch 3: Web Application Technologies
Ch 3: Web Application TechnologiesCh 3: Web Application Technologies
Ch 3: Web Application TechnologiesSam Bowne
 
(ATS6-PLAT04) Query service
(ATS6-PLAT04) Query service (ATS6-PLAT04) Query service
(ATS6-PLAT04) Query service BIOVIA
 
CNIT 129S: Ch 3: Web Application Technologies
CNIT 129S: Ch 3: Web Application TechnologiesCNIT 129S: Ch 3: Web Application Technologies
CNIT 129S: Ch 3: Web Application TechnologiesSam Bowne
 
Rest webservice ppt
Rest webservice pptRest webservice ppt
Rest webservice pptsinhatanay
 
CNIT 129S - Ch 3: Web Application Technologies
CNIT 129S - Ch 3: Web Application TechnologiesCNIT 129S - Ch 3: Web Application Technologies
CNIT 129S - Ch 3: Web Application TechnologiesSam Bowne
 
Best Practices in Web Service Design
Best Practices in Web Service DesignBest Practices in Web Service Design
Best Practices in Web Service DesignLorna Mitchell
 
Modern REST API design principles and rules.pdf
Modern REST API design principles and rules.pdfModern REST API design principles and rules.pdf
Modern REST API design principles and rules.pdfAparna Sharma
 
Pragmatic REST APIs
Pragmatic REST APIsPragmatic REST APIs
Pragmatic REST APIsamesar0
 
An Overview of Web Services: SOAP and REST
An Overview of Web Services: SOAP and REST An Overview of Web Services: SOAP and REST
An Overview of Web Services: SOAP and REST Ram Awadh Prasad, PMP
 
Restful风格ž„web服务架构
Restful风格ž„web服务架构Restful风格ž„web服务架构
Restful风格ž„web服务架构Benjamin Tan
 
CakeFest 2013 - A-Z REST APIs
CakeFest 2013 - A-Z REST APIsCakeFest 2013 - A-Z REST APIs
CakeFest 2013 - A-Z REST APIsanthony_putignano
 

Ähnlich wie API Testing Using REST Assured with TestNG (20)

restapitest-anil-200517181251.pdf
restapitest-anil-200517181251.pdfrestapitest-anil-200517181251.pdf
restapitest-anil-200517181251.pdf
 
Overview of REST - Raihan Ullah
Overview of REST - Raihan UllahOverview of REST - Raihan Ullah
Overview of REST - Raihan Ullah
 
Rest WebAPI with OData
Rest WebAPI with ODataRest WebAPI with OData
Rest WebAPI with OData
 
REST API Recommendations
REST API RecommendationsREST API Recommendations
REST API Recommendations
 
Rest APIs Training
Rest APIs TrainingRest APIs Training
Rest APIs Training
 
Api security-testing
Api security-testingApi security-testing
Api security-testing
 
RESTful Services
RESTful ServicesRESTful Services
RESTful Services
 
Ch 3: Web Application Technologies
Ch 3: Web Application TechnologiesCh 3: Web Application Technologies
Ch 3: Web Application Technologies
 
(ATS6-PLAT04) Query service
(ATS6-PLAT04) Query service (ATS6-PLAT04) Query service
(ATS6-PLAT04) Query service
 
CNIT 129S: Ch 3: Web Application Technologies
CNIT 129S: Ch 3: Web Application TechnologiesCNIT 129S: Ch 3: Web Application Technologies
CNIT 129S: Ch 3: Web Application Technologies
 
Rest webservice ppt
Rest webservice pptRest webservice ppt
Rest webservice ppt
 
CNIT 129S - Ch 3: Web Application Technologies
CNIT 129S - Ch 3: Web Application TechnologiesCNIT 129S - Ch 3: Web Application Technologies
CNIT 129S - Ch 3: Web Application Technologies
 
Best Practices in Web Service Design
Best Practices in Web Service DesignBest Practices in Web Service Design
Best Practices in Web Service Design
 
Modern REST API design principles and rules.pdf
Modern REST API design principles and rules.pdfModern REST API design principles and rules.pdf
Modern REST API design principles and rules.pdf
 
Pragmatic REST APIs
Pragmatic REST APIsPragmatic REST APIs
Pragmatic REST APIs
 
POSTMAN.pptx
POSTMAN.pptxPOSTMAN.pptx
POSTMAN.pptx
 
Rest
RestRest
Rest
 
An Overview of Web Services: SOAP and REST
An Overview of Web Services: SOAP and REST An Overview of Web Services: SOAP and REST
An Overview of Web Services: SOAP and REST
 
Restful风格ž„web服务架构
Restful风格ž„web服务架构Restful风格ž„web服务架构
Restful风格ž„web服务架构
 
CakeFest 2013 - A-Z REST APIs
CakeFest 2013 - A-Z REST APIsCakeFest 2013 - A-Z REST APIs
CakeFest 2013 - A-Z REST APIs
 

Mehr von Siddharth Sharma

Fundamentals of software 2 | Test Case | Test Suite | Test Plan | Test Scenario
Fundamentals of software 2 | Test Case | Test Suite | Test Plan | Test ScenarioFundamentals of software 2 | Test Case | Test Suite | Test Plan | Test Scenario
Fundamentals of software 2 | Test Case | Test Suite | Test Plan | Test ScenarioSiddharth Sharma
 
Fundamentals of software part 1
Fundamentals of software part 1Fundamentals of software part 1
Fundamentals of software part 1Siddharth Sharma
 
Agile software development 2
Agile software development 2Agile software development 2
Agile software development 2Siddharth Sharma
 
Agile software development
Agile software developmentAgile software development
Agile software developmentSiddharth Sharma
 
HTTP Response Codes | Errors
HTTP Response Codes | ErrorsHTTP Response Codes | Errors
HTTP Response Codes | ErrorsSiddharth Sharma
 
Differences asked in Software Testing Interview.
Differences asked in Software Testing Interview. Differences asked in Software Testing Interview.
Differences asked in Software Testing Interview. Siddharth Sharma
 
Food that controls high blood pressure
Food that controls high blood pressureFood that controls high blood pressure
Food that controls high blood pressureSiddharth Sharma
 

Mehr von Siddharth Sharma (9)

Timers in j meter
Timers in j meterTimers in j meter
Timers in j meter
 
Fundamentals of software 2 | Test Case | Test Suite | Test Plan | Test Scenario
Fundamentals of software 2 | Test Case | Test Suite | Test Plan | Test ScenarioFundamentals of software 2 | Test Case | Test Suite | Test Plan | Test Scenario
Fundamentals of software 2 | Test Case | Test Suite | Test Plan | Test Scenario
 
Fundamentals of software part 1
Fundamentals of software part 1Fundamentals of software part 1
Fundamentals of software part 1
 
Agile software development 2
Agile software development 2Agile software development 2
Agile software development 2
 
Agile software development
Agile software developmentAgile software development
Agile software development
 
HTTP Response Codes | Errors
HTTP Response Codes | ErrorsHTTP Response Codes | Errors
HTTP Response Codes | Errors
 
Differences asked in Software Testing Interview.
Differences asked in Software Testing Interview. Differences asked in Software Testing Interview.
Differences asked in Software Testing Interview.
 
Food that controls high blood pressure
Food that controls high blood pressureFood that controls high blood pressure
Food that controls high blood pressure
 
R platinum ias 26 dec
R platinum ias 26 decR platinum ias 26 dec
R platinum ias 26 dec
 

Kürzlich hochgeladen

%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2
 

Kürzlich hochgeladen (20)

%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 

API Testing Using REST Assured with TestNG

  • 1. API Testing with Rest Assured & TestNG
  • 2. Topics to be covered • What is REST assured ? • Postman vs REST Assured • What is REST, its Constraints and Architectural Elements . • Pre Requisite and Requirement. • Headers and Parameter. • GET Request using REST Assured • Authentication and Authorization in Web Services • POST Request Using REST Assured. • Data Driven Test Using REST Assured.
  • 3. Common Architecture of Rest Assured
  • 4. What is REST Assured ? • REST Assured is a Java library . Which, provides a domain-specific language (DSL) for writing powerful, maintainable tests for Restful APIs. • Library behaves like a headless Client to access REST web services. • Highly Customized HTTP Request can be created to REST Servers. • Testing and validating REST services in Java is harder than in dynamic languages such as Ruby and Groovy.
  • 5. Postman vs REST Assured • Postman - Tool for Exploratory Testing/Manual Testing and Automation Testing. • REST Assured - Java Library for Validating Web Services. • Postman takes lesser time than REST Assured . For best results it is better to consider both. • Code Reusability can be done in REST Assured Since, it is a Java Client. But, in Postman we need to copy request from one collection to another. • Both Postman and REST Assured can be integrated using Jenkins using Newman Tool. In REST Assured Maven can be used for Jenkins.
  • 6. WHAT is REST ? • REST is an acronym for Representational State Transfer. • It is an architectural style for distributed hypermedia systems. • Representation State Transfer (REST) is a set of constraints. Constraints • Client Server Architecture • Stateless • Cache • Uniform Interface • Layered System • Code on Demand (Optional)
  • 7. Constrains Client – Server- Both Client-Server should be separated to evolve independently . Client should not know about Business Layer/Logic or data access layer. Server should not know front end UI. Stateless - Server should not store context of the Client. Which, improves scalability. Cache - Responses from the server should contain relevant information to tell whether the Response can be cached by the client or not. • Client’s efficiency is improved for cacheable responses where Client need not make requests to the server. This makes REST API time efficient.
  • 8. Constraint (contd.) Uniform Interface • It Simplifies and decouples the architecture. Which enables each part to evolve independently. • Identification & Manipulation of resources through these representations. Layered System • System implementation should be of multiple layers. Eg. MVC • Layer should not know about the existence of other layers apart from the layers that it directly interacts with. • It decreases the complexity of different component within the system. • Model-Data, View – Output and Controller – Incoming requests.
  • 9. Rest Architectural Elements • Resource - Information stored on a Server, which can be requested by a client. • Resource Identifier - Need to uniquely identify the resource. That is actually the complete URL. • Representation - Resource is an actual data which can be represented as an XML, HTML or may be simple text. It is called a Representation. • Representation Metadata – It is an extra data needs to be passed in the request. In order for the Clients to specify and process a resources given in a particular Representation
  • 10. Domain , URI and Query String
  • 11. Headers and Parameters • REST headers and parameters contain a wealth of information that can help you track down issues when you encounter them. For eg. HTTP connection types, proxies etc. Headers carry information for • Request and Response Body • Request Authorization • Response Caching • Response Cookies
  • 12. Headers • Headers are mostly classified as request headers and response headers. • Headers that should be considered in API testing are the following • Authorization • WWW-Authenticate • Accept-Charset • Content-Type • Cache-Control
  • 13. Parameters • REST parameters specify the variable parts of your resources. • URL (Uniform Resource Locator) is a special case of the URI Uniform Resource Identifier. • URI consist of four parts. • scheme_name:hierarchical_part?query#fragment • Path Parameter • Query Parameter • Fragment Parameter
  • 14. Path parameter & Query parameter • Path Parameter- Parameters within the path of the endpoint, before the query string (?). These are usually set off within curly braces. • Query parameter appears after “?” in the URL. It comes after resource path. Following is the example for query parameter.
  • 15. Path parameter & Query parameter
  • 16. Pre Requisites and Requirement. • Basic Knowledge of Java Programming Language and OOPS Concepts. • Eclipse IDE (Java) Installed in PC or Laptop. • Basic Knowledge of Maven Build Tool, Test NG and Dependencies. • Basic Knowledge about Web API and Web Services .
  • 17. Dependencies Required • Dependencies are another archived—JAR or ZIP which are for projects in order to compile, build, test, and/or to run. • The dependencies are gathered in the pom. xml file, inside of a <dependencies> tag. • List of Dependencies • TEST NG • J unit • Apache POI • REST Assured • Google Simple JSON
  • 19. List of Dependencies • Test NG is an automation framework. NG stands for “Next Generation” • Test NG overcomes disadvantages of J unit. • Test NG can be integrated with tools like Maven and Jenkins. • Apache POI’s purpose is to create and maintain Java APIs for manipulating various file formats based upon the Office Open XML standards. • Google JSON.Simple – simple Java toolkit for JSON
  • 20. GET Request using REST Assured • Some Points about GET Request • GET requests can only be used to retrieve data not to modify and it can be cached. • GET requests are less secure and should be avoided when trying to retrieve data from a sensitive resource. • GET requests parameter data is limited as there are length restrictions and it can be bookmarked. • GET requests are prone to get hacked easily.
  • 21. GET Request using REST Assured • Dummy API has been taken https://reqres.in/api/users/
  • 22. GET Request using REST Assured
  • 23. GET Request using REST Assured
  • 24. Authentication and Authorization in Web Services • Authentication is a process to prove that user is the person who is intended to access API. • API’s require to provide identification to make REST API Secure Identification used are • Username and a Password • Authentication tokens • Secret keys • Bio-metrics and many other ways • First 3 identification are used in REST APIs
  • 25. Contd. • REST request can have a special header called Authorization Header. • Header contain the credentials (username and password) in some form. • Once a request with Authorization Header is received, server can validate the credentials and can let you access the private resources.
  • 26. Basic Authentication • Pre-emptive and Challenged are the forms of Basic Authentication. • Pre-emptive sends the basic authentication credentials even before the server gives an unauthorized response in certain situation. • It reduces the overhead of making an additional connection. • In Challenged basic authentication server will not supply credentials unless server explicitly asked for it. • This means additional request will be made in order to be challenged and then followed.
  • 28. POST Request in REST Assured • POST is the HTTP method that is designed to send loads of data to a server from a specified resource. • POST method will not be visible in the URL, as parameters are not sent along with the URI. • Format of an HTTP POST should have HTTP headers, followed by a blank line, followed by the request body. • Content-Type header indicates the type of body in the POST request.
  • 29. POST Request in REST Assured
  • 30. POST Request with multiple data