Giter VIP home page Giter VIP logo

katalon-finalapi-airlangga's Introduction

Restful-booker API Testing using Katalon Studio

This document outlines the API documentation for Restful-booker along with two test suites created using Katalon Studio. Created for hacktiv8's Quality Assurance learning path.

Authentication

This section covers the endpoint for user authentication. The request includes sending credentials, and based on whether the credentials are correct or not, the response varies. If the credentials are correct, the server responds with an HTTP 200 OK status and includes a token in the response body. In case of incorrect credentials, the server still responds with an HTTP 200 OK status, but the response body contains a reason for bad authorization. These responses are crucial for verifying the authentication process in the Restful-booker API.

Request

GlobalVariable.USERNAME = "jalu"

def response = WS.sendRequest(findTestObject('Object Repository/auth/POST Authenticate'))

String responseBody = WS.getElementPropertyValue(response, 'token')

if(positiveCase){
  assert responseBody != null
} else {
  assert responseBody == null
}

Responses

  • Correct credentials
    HTTP/1.1 200 OK
    
    {
      "token": "${TOKEN}"
    }
  • Incorrect credentials
    HTTP/1.1 200 OK
    
    {
      "reason": "Bad authorization"
    }

Booking

Within the booking section, there are cases for editing bookings and creating/deleting bookings.

Edit Booking

For editing bookings, the request involves partially updating specific details of an existing booking. Upon sending the request, the server responds with details of the updated booking, including the changes made. This response includes various fields such as the new first name, last name, total price, deposit paid status, booking dates, and additional needs. Verifying these details ensures that the booking editing functionality is working as expected.

Request

def response = WS.sendRequest(findTestObject('Object Repository/auth/POST Authenticate'))
GlobalVariable.TOKEN = WS.getElementPropertyValue(response, 'token')

def partialUpdate = WS.sendRequest(findTestObject(
	'Object Repository/bookings/PATCH Partial Update',
	[
		'id': 9,
		'firstname': 'Jalu',
		'lastname': 'Potter'
	]
))

if(WS.verifyResponseStatusCode(partialUpdate, 200)) {
	String newFirstname = WS.getElementPropertyValue(partialUpdate, 'firstname')
	String newLastname = WS.getElementPropertyValue(partialUpdate, 'lastname')
	
	assert newFirstname == 'Jalu'
	assert newLastname == 'Potter'
} else {
	assert false
}

Response

HTTP/1.1 200 OK

{
    "firstname" : "Jalu",
    "lastname" : "Potter",
    "totalprice" : 111,
    "depositpaid" : true,
    "bookingdates" : {
        "checkin" : "2018-01-01",
        "checkout" : "2019-01-01"
    },
    "additionalneeds" : "Breakfast"
}

Create and Delete Booking

In the case of creating and deleting bookings, the process starts with authenticating the user and obtaining a token. The request for creating a booking includes providing details such as first name, last name, price, check-in, check-out dates, and any additional needs. Upon successful creation, the server responds with an HTTP 200 OK status and includes the booking ID. Subsequently, the created booking is deleted using the obtained booking ID. The deletion request results in an HTTP 201 Created status if successful. These cases validate the functionality of creating and deleting bookings in the Restful-booker API.

Request

def response = WS.sendRequest(findTestObject('Object Repository/auth/POST Authenticate'))
GlobalVariable.TOKEN = WS.getElementPropertyValue(response, 'token')

def createBooking = WS.sendRequest(findTestObject(
	'Object Repository/bookings/POST Create Booking',
	[
		"firstname" : "Jalu",
		"lastname" : "Goyang",
		"price" : 394,
		"isAlreadyPaid" : true,
		"checkin" : "2024-13-02",
		"checkout" : "2024-15-02",
		"additionals" : "Pake terminal"
	]
))

Integer bookingId = 0

if(WS.verifyResponseStatusCode(createBooking, 200)) {
	bookingId = WS.getElementPropertyValue(createBooking, 'bookingid')
} else {
	assert false
}

def deleteBooking = WS.sendRequest(findTestObject(
	'Object Repository/bookings/DELETE Delete Booking', 
	['id': bookingId]
))

WS.verifyResponseStatusCode(deleteBooking, 201)

Response

HTTP/1.1 201 Created

katalon-finalapi-airlangga's People

Contributors

airlanggarasyad avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.