API Testing
API Testing
I. APPLICATIONS: -
A piece of code written to perform a required task is called as Application.
TYPES OF APPLICATIONS: -
Standalone application
Client server applications
STANDALONE APPLICATION: -
To access the application
No Internet Required
Local Database Required
No Server Required
Installation is Mandatory
Single User will be using the application at a time
Example: Calculator, Paint, MS Office, File Manager, Browser, etc.
Browsers have to be downloaded and installed into our systems. Any downloaded web-
pages, pdf’s etc can be accessed with the help of these browsers.
1
CLIENT SERVER APPLICATION: -
Hi
User1 WHATSAPP SERVER
Hello
Process it
Hi
User2
Hello
Note: - Installing the app from the play store or through the .apk file is called client
software.
Q) What is a server?
Ans) Server is a super computer which has high configuration, it is used to store the source
code written by the developer.
WEB APPLICATION: -
Any application which is launched using the Web browser, URL and Internet.
2
Q) Is internet required to access the web application?
Ans) Yes.
.java
Business layer
The code written by the developer in web server (or) app server we call it as Code
(or) source code (or) business logic code (or) web resource.
Layers:
1. Presentation layer GUI CODE
2. Business layer source code (or) business logic code (or) web resource.
3. Data base layer Data
3
Web Browser:
It is a standalone application which is used to access any web application over the
network via URL.
Browser understands only html, CSS & JavaScript, so it makes use of http protocol.
It’s the only way to access the web application.
Ex: Chrome, IE, safari, Firefox, Opera, etc.
Web Server:
As the name suggest it serves the response to the browser based on the request.
It receives the request from the browser, communicates with the app server and
provides back the response to the browser.
Its helps both web browser and the web application to communicate with each
other.
Database: It is a place or medium where the data is being stored in a systematic and
organised manner. Ex: - SQL, MYSQL, PL-SQL, NO-SQL etc.
JDBC: It’s a collection of java API’s which helps a java object and the database to
communicate with each other. It stands for Java Database Connectivity.
4
Servlet: It is a collection of J2EE API’s which is used for mapping the data between Web
server & App server and they are also used to develop dynamic web applications.
Web URL:
URL is used to uniquely identify the specific web resource inside the web application.
Every web application should have its unique address in the form of URL.
URL is the one & only way to access web application via a browser.
Ex: https://www.google.com/search?q=india&oq=india&aqs
Syntax: -
Protocol://DomainName:PortNumber/ResourcePath?QueryString#FragmentId
Protocol:
When one application wants to communicate with another application their needs
to be a common language which both the application understands, hence we use
protocol.
Protocol acts like a common language between two applications.
It is a set of rules & instructions.
Protocol is an optional information in the URL & it is not case sensitive.
Types of protocol:
1. HTTP Hyper Text Transfer Protocol
2. HTTPS Hyper Text Transfer Protocol Secured
3. FTPFile Transfer Protocol. Ex: Google Drive
4. SMTP Simple Mail Transfer Protocol. Ex: Gmail
Domain Name:
It is used to identify the specific server or computer within the network or area.
Area/Network
Q .com Commercial
GMAIL AMAZON .in India
.gov Government
UBER .org Organization
OLA
.edu Education
5
Domain Name can be the computer name or server name or the IP address.
In initial stage of developing application, they will use IP address only / Domain
Name.
It’s a mandatory information in the URL.
After completion of entire application, they will set the URL.
Port number:
It is used to uniquely identify the specific software/ application inside the computer.
In the URL this is an optional information.
If we are using the IP Address, then only the Port Number is required.
Port Numbers start from 1000 -9999 (8999 parts)
WebLogic (2 digit), Apache J-Boss (3 digits), Apache-Tomcat (4 digits)
Ex: localhost:8888 Vtiger
localhost:8080 Jenkins
localhost:4723 Appium
Resource path:
It is used to uniquely identify the specific web resource inside the application server
(web application).
Ex: http://localhost:8080/index.html
http://localhost:8080/login
Query string:
It is one of the components of the URL which is used to pass a value to a specific
parameter.
It should always begin with “?”
It is always written in “name= value” pairs.
We can have any number of name value pairs separated by “&”
Ex: http://localhost:8888/index.php?module=leads&action=index
Fragment ID:
It is used to uniquely identify the specific fragment or section in the webpage.
It’s not a mandatory field in URL.
Types of Languages:
1. Programming Languages: It is used to develop an application i.e., developing the
Backend. Ex: C, C++, C#, Java, Swift.
2. Scripting Languages: Scripting Language is used to Validate the Front End, i.e., while
developing the UI of the application the developers will give the conditions for each
and every component. Ex: Python, JS, Shell Script, PHP, Visual Basics.
3. Other Languages: Cannot develop/validate the application. So, For API Testing
purposes we use these other languages. Ex: XML, JSON, XSD, DTD, HTML.
XSD – XML Schema Definition (describe and validate the structure and content of
XML documents).DTD – Document Type Definition (defines the structure of XML
document). HTML – Hyper Text Markup Language (structures the web-page).
6
IV. WORK FLOW OF XML:
*SWS: - soap web service https://icici/api.wsdl
R
Web Browser e
url: Amazon q
http req j SWS req u
cc: sbi12345 ja a data
xml XML xml e PY
va x
cvv:123 b s
http res SWS Res t
e
OTP- verification r
Syntax: <root>
<child>
<sub-child> </sub-child>
</child>
</root>
7
Note: Every tag name is case sensitive.
Ex: <ShopperRequest>
<city>string</city>
<country>string</country>
<email>string</email>
<password>string</password>
<phone>0</phone>
</ShopperRequest>
An attribute is always written in name value pair within start tag of the element.
8
It has more number of datatypes.
It’s an extension of JavaScript.
The file name extension of JSON is .json
The contain type is application/json
It’s a platform and technology independent language.
It’s very popular because of its simplicity.
It’s very easy to parse.
It is designed in the form of MAP structure.
It will be in terms of KEY and VALUE pair.
KEY always enclosed within the double quotes, VALUE is based on the data.
} }
1. STRING
2. NUMBER {
3. BOOLEAN “Key1”:” v1”,
4. NULL
“key2”:” v2”,
5. ARRAY
6. OBJECT “key3”: {
7. OBJECT ARRAY
“key4”: v4,
“Key5”: [{ },{ }]
9
Note:
The process of converting java object to JSON is called Serialisation/ Marshalling.
The process of converting JSON to java object is called De-serialisation/
Unmarshalling.
JSON follows MAP structure, hence XML follows tree structure, hence
structure, hence it is light weight. it’s called as very strictly typed
language.
File extension is .json File extension .XML
Contain type is application/json. Contain type is application/xml.
JSON data has datatypes. XML data is type less.
JSON data types are string, number, In XML all the data will be written as
Boolean, null, array, object, Object string.
array.
JSON is an extension of JavaScript. It’s an extension of HTML.
JACKSON is the parser tool to JAXB is the parser tool to convert
convert java to JSON and vice-versa. java to XML and vice-versa.
Parsing time is less in JSON. Parsing time is more in XML.
Files are easy to read. Files are difficult to read.
Serialization and Deserialization Developer have to write addition
happens automatically. JavaScript code for Serialization and
Deserialization
Supported by most browsers. Cross-browsing can be difficult.
Doesn’t support comments. We can comment.
Less Secured. Comparatively more secured.
10
SOA [service-oriented architecture]
Soap ws request
Rest ws request
Ans) The developers would have created an interface. With the help of this Interface the
test engineer is able (getting access) to test the Source code.
Q) what is API?
Ans) Application programming interface acts like a bridge/ interface/ a connection between
two programs.
Ans) Testing the interface between two programs is called API testing.
Q) why API testing is required?
Ans) API TESTING is required in order to make sure that the interface is working as expected
with respect to functionality, performance, scalability, security etc.
11
VI. TYPES OF API TESTING:
1. WBT (White Box Testing)
2. Web Services Testing
a) SOAP web services testing
b) REST web services testing
Bal ();
Deactivate ();
IDE (Eclipse)
………
……….
12
Q) What is web services testing?
Ans) Testing the request and response between two applications is called as web services
testing.
Web service provider has to make sure that all the API’s are working as expected.
Ans) Web services testing is required in order to make sure that all the services are exposed
by the provider is working as expected with respect to functionality, performance,
scalability, security etc.
Ans) It stands for Simple Object Access Protocol. Important points to note are:-
SOAP is a protocol.
It’s a xml based protocol used for application to exchange the information between
each other.
It will send entire WSDL file (Web Services Description Language).
UDDI: Universal Description Discovery Integration
Its where all the soap API’s have to be registered.
Ans) Two application exchanging the information between each other with the help of XML
using SOAP as protocol is called SOAP web service.
Note: All the soap web services are exposed via .WSDL file.
Ans) Testing the request and response between two applications which is based on XML
using soap as protocol is known as SOAP web service testing.
Q) What are the SOAP web service testing tool?
1. SoapUI
2. SOAPSonar
3. Soap Test
4. ReadyAPI
5. Wizdler
Ans) We need to send all the files as an entire package (.wsdl), whereas we can’t send only
particular section of the file.
13
REST WEB SERVICE TESTING:
Q) What is REST?
Ans) It stands for Representational State Transfer. Important points to note are:
It’s an architectural style used to develop web services.
As the name suggest it represents the state of request.
REST supports XML/HTML/JSON/Text/JavaScript.
14
Advantages of web services:
4) Business Opportunity
Web Services will open the door for new business opportunities by making it
easy to connect with partners.
Ex: Dominos can get the order from Food Panda/ Swiggy along with getting
orders from its own site.
5) Service Reuse
Web Services takes code reuse a step further.
Ex: An organization can have a “Single Payment Gateway Services” which
helps other web applications of the organization to interact.
HEADER
BODY
15
HTTP Request & HTTP Response:
REQUEST RESPONSE
HTTP METHOD
STATUS CODE
WEB URL
Header Header RESPONSE TIME
COOKIES
COOKIES
CONTENT TYPE
CONTENT TYPE
Body Body
ACTUAL DATA
FORM DATA / RAW DATA
HTTP Method:
It’s used to specify the type of operation performed in the server.
It’s a mandatory information present in the HTTP Request.
HTTP method is the first element in the http request, used to specify the type of the
request which is sent by client (Browser) to Server (Application).
1. GET: it’s used to read or retrieve the resources from the server.
2. POST: it’s used to create resources inside the server.
3. PUT: it’s used for complete update of the resource inside the server and it
can also be used for creating a resource.
4. PATCH: it’s used for partial updating of the resources inside the server.
5. DELETE: it’s used for deleting the resource inside the server.
NOTE: PUT will be used for updating if you pass the id in the body otherwise it will be
used for creating.
Web URL:
It’s used to specify location or address of the server.
It’s used to identify the specific web resource inside the web application.
In GET: Query will be present in URL.
In POST: Query will be present in the Body of the Request.
16
Cookies:
It’s an additional information (additional add-on’s) provided.
Content type:
It’s used to specify the type of content used to transfer data.
Ex:
a) application/json .json
b) Application/xml .xml
c) Application/zip .zip
d) Application/png .png
e) Application/html .html
HTTP Response: -
Status Code:
It’s used to specify the status of the request sent from the client.
Response time:
Total time required to send the request, process the request, get the response is
called Response time.
Cookies:
It’s an additional information provided.
Content type:
It’s used to specify the type of content used to transfer data.
Ex:
f) application/json .json
g) Application/xml .xml
h) Application/zip .zip
i) Application/png .png
j) Application/html .html
17
Actual Data:
The data sent from the server to the client is called as Actual data.
18
API Testing in Fireflink: -
Query parameters:
It’s similar to query string.
Query parameter are defined as set of parameters attached to the end of the URL.
It is always displayed in table format.
Whatever the key & value is added to the table, it is appended to URL and vice versa.
Authorization:
It’s just like Authentication, providing the access to particular API’s.
If we want to access secured API then we need to pass authorization.
For whole project we have to follow only one kind of authorization.
Ex: - Basic Auth /Bearer Token/ OAuth1/OAuth2.0/etc.
Body:
Form data body in the form of key and value pair
URL encoded body in the form of key and value pair
Raw body in the form of JSON/XML/HTML/JS/TEXT
Binary we will upload the body in the form of files.
Graph QL we will upload the body in the form of graphs.
Pre Requisite:
It’s similar to pre-condition in fireflink.
Test (Assert):
Assets are used for validation.
Request chaining:
After getting the response, save the required data from the response by using
capture data and use it in the next request.
WBT BBT Acceptance HotFix/Incident
Testing Management
End Users
19