testing soap and rest
testing soap and rest
-------------------------------------------
What is API?
• API stands for Application Programming Interface
• APIs are mechanisms that enable two software components to communicate with each
other
using a set of definitions and protocols.
• API contains collections of functions and procedures
Types
• Private AΡΙ
• Public API
• Partner API
• Composite API
What is SOAP
application1 application2
--------------------
xml
SOAP
WSDL :web serice description language
Agenda: lession 1
------------------
* What is SOAP based web service?
* How it works,architecture
* sw development of soap web service , hello world with java
* how to undestand wsdl file
* how to customized wsdl file
Agenda lession 2:
------------------
Testing simple calculator application
Creating soap project using WSDL
create test suite and test cases
added contains assertions
execute test in sequence and parallel
documentation
Agenda lession 3:
------------------
Contains
Not contains
Xpath Query match
Invalid http status code
valid http status code
soap faults
Example:
https://ws.footballpool.dataaccess.eu/info.wso?WSDL
Xpath:
https://www.w3schools.com/xml/xpath_intro.asp
Xpath: is a query language for selecting
nodes form xml documents
XPath can be used to navigate through elements and attributes in an XML document.
XPath stands for XML Path Language
XPath uses "path like" syntax to identify and navigate nodes in an XML
document
XPath contains over 200 built-in functions
XPath is a major element in the XSLT standard
XPath is a W3C recommendation
http://xpather.com/
All player:
//m:AllPlayerNamesResponse/m:AllPlayerNamesResult/m:tPlayerName[1]/m:iId
//m:AllPlayerNamesResponse/m:AllPlayerNamesResult/m:tPlayerName[1]/m:sName
//count(//m:sName)
Tag presence:
//m:AllPlayerNamesResponse/m:AllPlayerNamesResult/m:tPlayerName/m:sName
true
XQuery:
it is language for Querying XML data
XQuery is to XML same as SQL to database
XQuery buid on top of Xpath expression
XQuery use functions to extract data from xml documents
Tutorial :
https://www.w3schools.com/xml/xquery_intro.asp
Example:
https://www.w3schools.com/xml/books.xml
Uniform interface:
A group of methods, such as GET, PUT, POST, and DELETE,
that are easily understood by the client and server
Stateless: Each request is processed independently from the previous ones
Client-server:
The server has "resources" that are presented to the client as a
representation of the resource's state
Layered system:
Individual components cannot see beyond the immediate layer with which they
are interacting
https://restful-booker.herokuapp.com/apidoc/index.html#api-Booking-CreateBooking
Negative Scenarios
• Record not found
• Request has invalid characters
• Values has to many characters
• Request sent with missing information
• Value is not in correct format
var jsonData=pm.response.json();
pm.environment.set("b_id",jsonData.bookingid);
it will set a variable once we run the request
https://restful-booker.herokuapp.com/booking/{{b_id}}
Do same for api token used to update the api
develpment
best practices
https://martinfowler.com/articles/richardsonMaturityModel.html
Level 0
Level 1 - Resources
Level 2 - HTTP Verbs
Level 3 - Hypermedia Controls
security
basics auth: here username and password need to be passed with each request
jwt token: here rather then username and password we will pass the jwt token
oauth: mainly use for authorization using 3rd party application
https://survayapi.themetasum.com/swagger/index.html
url for getting jwt token, u need to login the the app with the username/password
you have registered:
https://survayapi.themetasum.com/api/Authenticate/login
https://survayapi.themetasum.com/api/Survay/getSurvayData
versioning(live coding)
http://localhost:8080/v1/products
http://localhost:8080/v2/products
<version>2.2.2.RELEASE</version>
<java.version>1.8</java.version>
<version>2.1.4.RELEASE</version>
30 min to try to use api
to run the test cases