Manas Kumar Jha
Telegram: https://t. me/QAIDEAS
Linkedin: https://www.linkedin.com/in/manas-jha/Linkedin Telegram Link WhatsApp Link
What all challenges are included under API testing?
API testing involves testing the functionality, reliabiliy, performance, and security of an API. Some specific
challenges that may be encountered during API testing include:
‘© Ensuring that the API is functional and returns the correct results for different inputs.
‘© Verifying that the API is reliable and returns consistent results over time.
‘© Testing the performance of the API to ensure that it can handle a high volume of requests and has a
fast response time
= Eneuring that the API ie secure and cannat he sccassed hy unauthorized users
‘© Testing the APIs error handling capabilities to ensure that it returns appropriate error messages and
codes when something goes wrong.
‘© Testing the API's compatibility with different platforms, devices, and operating systems.
© Verifying that the API can be easily integrated into other applications.
‘+ Chauring that the API documentation is accurate and up-to-date.
What is the difference between API and WebService?
API (Application Programming Interface) is a set of routines, protocols, and tools for building software
applications. It provides a way for developers to access and interact with application data and functions.
‘A WebService is an application that is accessible over e network, such as the Internet, and provides a set of
functions and data that can be accessed by other ap}
applications, or components of the same application, over anetwork.
What is the difference between SOAP & Rest API.
ications. Itis a means of communication between two
‘SOAP (Simple Object Access Protocol) Is @ protocol that uses XML as its message format to exchange
information between computers over the internet. SOAP is a more complex and rigid protocol, with more
complex security features and requires more bandwidth for communication.
REST (Representational State Transfer) is an architectural style that defines a set of constraints and
properties based on HTTP. itis a more lightweight and flexible architecture that uses HTTP and JSON as its
massage format, REST is simpler ta ure and has hetter perfarmanre, cinre it uses fower rosaurcas than
SOAP. Itis also more secure since It has more bullt-in security features.
Can you write a sample of API(URL) and JSON.
Manas Jha 9145735668LinkedIn Telegram link WhatsApp Link
eee ea
‘Authentication tokens are typically used to store a uses identity and other information securely during a
session. To handle authentication tokens, a server should first generate a token and store it in a secure
location. This token should then be sent to the client with each request that requires authentication. The
client should then send the token back with each request, allowing the server to verify the user's identity
and process the request accordingly. Additionally, the server should regularly check that the token is still
valid, and if not, generate a new one and send it back to the client
oAuth1.0
- Uses HMAC-SHA1 signature method
- Requires user to authorize access via signing @ request
- Uses plain text tokens
Uses 2-legged authorization
muth2.0
Uses digital signature or public/private key encryption
Requires user to authorize access via authenticating with an access token
Manas Jha 9145735668Linkedin Telegram Link WhatsApp Link
Uses JSON Web Tokens (JWT)
- Uses 3-legged authorization
RaseLiRI in RestAssured is the hase URL of the web service that is being tested. itis used to set the endpoint
of the web service that will be tested, BaseURIis set using the RestAssured.baseURI() method.
RequestSpecification request = RestAssured.givent); isan expression used to create a request that can be
Used in RestAssured to send a request to a specific endpoint. It is used to set up the request and define the
parameters of the request such as the headers, cookies, body, and query parameters. It can also be used to
set up the authentication for the request.
To handle different HTTP status codes when testing an API with REST Assured, you can use the statusCode
‘method in the Response object. This method returns the HTTP status cade of the HTTP response. You can
then use an if statement or a switch statement to execute different blocks of code depending on the status
code.
For example, you could use the following code to hancle a 200 OK status code:
ssponse response = given()
Re en a Le eae)
her
enc
If statusCode == 200) {
ener
You can also use the assertThat method to verify that the status code of the response is what you expect it
to be. For example:
sponse response = given()
Dec CMTS
re Eee a a
Manas Jha 9145735668LinkedIn Telegram link WhatsApp Link
at(response.statusCodel), equalTo(200));
This will cause the test to fal ifthe status code of the response is not 200 Ok.
You can use similar techniques to handle other status codes as well. For example, to handle 2 404 NOT
FOUND status code, you could use the following code:
ee ea ns
int statusCode = response statusCode();
oetner lees
ena
To print the response of an API in JSON format using REST Assured, you can use the prettyPrint method of
the Response object. This method returns the body of the response as a formatted JSON string.
Here is an example of how you can use the prettyPrint method to print the response of an API in JSON
format:
ocean)
hheader("Content-Type", "
Pert SU ean a
m.out.printin(response.prettyPrint()
This will print the body of the response in a formatted ISON string. You can also use the asString method to
print the body of the response as a raw string, rather than a formatted JSON string.
For example:
Manas Jha 9145735668LinkedIn Telegram link WhatsApp Link
TT
eee
This will print the raw string representation of the body of the response.
To use REST Assured, you will need to add the following dependencies to your project:
JUnit: This is a Java testing framework that is commonly used to write and run test cases for REST Assured.
Rest-assured: This isthe core library for REST Assured. It provides the classes and methods for making HTTP
requests and validating the responses,
Hamecrest: This is a library of matcher objects that can be used to create assertions in your test cases.
‘Apache HTTP Client: This is @ Java library for making HTTP requests. Its used by REST Assured to send HTTP
requests and receive HTTP responses.
To add these dependencies to your project, you will need to include them in your build too!’s configuration
file, For example, if you are using Maven, you can add the following dependencies to your pom.xml file:
dependencies>
To
eee
Cee
Cee ees
aes
See
ees
eo nere ra
Ree a
Pee Se ers
a
Manas Jha 9145735668Linkedin Telegram Link WhatsApp Link
Sree ees
hamerest-ibrary