Sunday, 28 January 2024

Explain API Test Automation Framework

REST ASSURED API FRAMEWORK 

Design Pattern 

  • Page Object Model

Languages

  •  Java

Tool

  • Rest Assured

Automation Framework

  • Cucumber

Other Dependencies

  •  Apache POI
  • JsonPath
  • JSON schema validator

Logging 

  • log4j

Reporting 

  • Report portal

CI/CD

  • Jenkins Pipeline

Cypress  API FRAMEWORK 

Language

  • Javascript

Tool

  • Cypress

Reporting

  •     Mocheaswesome



Thursday, 25 January 2024

Headers

 What are the header components used in your API test?

  • USER ID
  • STAFF ID
  • WORKING UNIT
  • DEVICE NAME
  • AUTHORIZATION - BASIC unique id

Tuesday, 23 January 2024

What to test in API testing

 What we can test using API testing?

  • Endpoint functionality
    • Verify each endpoint performs the intended functionality
  • HTTP methods
    • Verify each HTTP method performs the intended functionality
  • Request and response validation
    • Verify that the payload and response follow the correct format of JSON
    • Verify that it adheres to the API documentation functionality
    • JSON schema validation
  • Data validation
    • Verify response data is correct
    • Verify it gives the correct response for different query params
    • Verify it gives the correct response for different path params
    • Validate the correctness of the payload
  • Error handling
    • Verify it gives the correct response codes
    • Verify it gives the proper message in the response body for errors
    • Verify it gives the correct response code which matches the client, server, and errors
    • Verify that it gives the correct error code and response when sending invalid data
  • Security testing
    • Verify authentication mechanism
    • Verify that the authorization mechanism is correct 
  • Performance testing
    • Verify response time
    • Throughput (no of requests per second)
    • Error rate
  • Mandatory and optional values
    • Verify request with mandatory properties in payload and query params
    • Verify request with only optional values in payload and query params
  • Verify json scheme
    • Response and payload should include the correct format of JSON
  • Functional testing
    • Verify that data is saved correctly in the DB

Idempotent

 What does idempotent mean?

  • If we perform an operation multiple times but the results are the same always
  • The result remains unchanged regardless of how many times the operation

What does non-idempotent mean?

  • Perform the same operation multiple times but the results are different each time

What are the idempotent request types?

  • GET
  • PUT
  • DELETE
  • PATCH

What are the non idempotent request types?

  • POST





Status Codes

 What are the status codes in REST?

    • 404 
      • Not Found
    • 409
      • Conflict
    • 204
      • No content
    • 200
      • Ok
    • 201
      • Created
    • 500
      • internal server error
    • 503
      • Service Unavailable
    • 502
      • Bad gateway
    • 301
      • Moved permanently
    • 400
      • Bad request
    • 403
      • Forbidden
    • 401
      • Unauthorized

What are the common meanings of these statuses?

  • 1xx
    • Informational
  • 2xx
    • Success
  • 3xx
    • Redirection
  • 4xx
    • Client errors
  • 5xx
    • Server errors

Authentication & Autherization

 Authentication

  • It is verify who the user is
  • It works through passwords
  • One-time pins, bio-metric information
  • Other information provided or entered by the user

Authorization

  • It determines which resources have access
  • It determines which resources users have permission

Friday, 19 January 2024

Assure Pulse

 1. What is RestAssured?

It is a Java-based library that is used to test RESTApis.

2. How to add RestAssured in your project which is based on Maven?

Add as a maven dependency in the pom.xml file

3. What is command chaining when it comes to the RestAssured?

We can use each command one after another as below that is called command chaining

given().when().then()….

4. How to add query parameters in a request?

given().queryParam(“name”, “Alice”)

5. How to perform authentication in RestAssured?

given().auth().basic(“id”)

6. Can we use the page object model when writing rest-assured scripts?

Yes. We can move repeating steps into page objects.

7. What can be verified using RestAssured in API testing?

  • API response
  • status code
  • headers
  • response time

8. What is the best way to create a JSON body using RestAssured?

Use fluent builder pattern. Use Jackson data binding maven dependency into the pom.xml file. Create a String object as the payload of the request.

9. Can you use the JSON file as a payload in a POST request?

Yes. Create a JSON file and keep it under the resources folder. Then give the file name inside the body() method.

map online shopping status with REST API

  Example Sequence of API Calls Browse products : GET /products View product details : GET /products/12345 Add product to cart : POST /cart ...