Introduction to API Testing

Introduction to API Testing


Lot of times in our testing life cycle there comes a situation when we need to quickly test our web-application or test it without any GUI (Graphical User Interface) in that case API testing can help us a lot.

So in this Series of Blog I will discuss all the aspects related to API Testing using Rest Assured-Framework.

So Let’s Get started with basic introduction and terminology that we will be using while testing doing API Testing.

What is Web Applications?

A Web Application is a software application that is deployed to a Web Server. This means the application is installed onto a computer and users access the application via a Web Browser.

The Web Application we will test has an API, which is a way of accessing the application without using a Web Browser or the application’s Graphical User Interface (GUI).

Google Is an Example of a Web Application

Google.com is an example of a Web Application. A user visits google.com in a Browser and the application’s Graphical User Interface (GUI) is displayed in the Browser. The GUI consists of a search input field which the user fills in and then clicks a button to search the Web.

When the user clicks the search button, the Browser makes a request to the Web Application on the Web Server to have the Google Search Application make the search and return the results to the user in the form of a web page with clickable links.

When we first visit Google in a Browser we type in the URL or address for Google. i.e.  https://google.com

The Browser then sends a type of HTTP request to Google called a GET request to ‘get’, or retrieve, the main search form. Google Web Application receives the request and replies with an HTTP response containing the HTML of the search page. HTML is the specification for the Web Page so the Browser knows how to display it to the user.

When the user types in a search term and presses the search button. The Browser sends a POST request to Google. The POST request is different from the GET request because it contains the details of the search term that the user wants the Google Web Application to search for.

The Google Web Application then responds with an HTTP response that contains the HTML containing all the search results matching the User’s search term.


What is API?

An API is an Application Programming Interface. This is an interface to an application designed for other computer systems to use. As opposed to a Graphical User Interface (GUI) which is designed for humans to use.

An HTTP based API is often called a Web API since they are used to access Web Applications which are deployed to Servers accessible over the Internet.

Applications which are accessed via HTTP APIs are often called Web Services.




What Is an HTTP Request?

HTTP stands for Hypertext Transfer Protocol and is a way of sending messages to software on another computer over the Internet or over a Network.

An HTTP request is sent to a specific URL and consists of:

• VERB specifying the type of request e.g. GET, POST, PUT, DELETE
• A set of HTTP Headers. The headers specify information such as the type of Browser,
type of content in the message, and what type of response is accepted in return.
• A body, or payload in the request, representing the information sent to, or from, the Web Application. Not all HTTP messages can have payloads: POST and PUT can have payloads, GET and DELETE can not.


What Is a URL?

URL is a Uniform Resource Locator and is the address we use to access websites and web applications.
When working with APIs you will often see this referred to as a URI (Uniform Resource Identifier).
Think of a URI as the generic name for a URL.

What Are HTTP Verbs?

A Web Browser will usually make GET requests and POST requests.
• GET requests ask to read information from the server e.g. clicking on a link.
• POST requests supply information to the server e.g. submitting a form.
GET requests do not have a body, and just consist of the Verb, URL and the Headers.

When Working with Web Application or HTTP API the typical verbs used are :

GET- The GET method is used to extract information from the given server using a given URI. While using GET request, it should only extract data and should have no other effect on the data.

POST- A POST request is used to send data to the server, for example, customer information, file upload, etc. using HTML forms.

PUT- Replaces all current representations of the target resource with the uploaded content.

DELETE- Removes all current representations of the target resource given by a URI.

What Is an HTTP Response?

When you issue an HTTP Request to the server you receive an HTTP Response.
The response from the server tells you if your request was successful, or if there was a problem.

• A status code of 200, which means that the request was successful.
• A Content-Type header of application/json which means that the body is a JSON response.
• A body which contains the actual payload response from the server.


What Is an HTTP Status Code?

Web Services and HTTP APIs use HTTP Status Codes to tell us what happened when the server processed the request.

The simple grouping for HTTP Status Codes is:

• 1xx - Informational
• 2xx - Success e.g. 200 Success
• 3xx - Redirection e.g. 302 Temporary Redirect
• 4xx - Client Error e.g. 400 Bad Request, 404 Not Found
• 5xx - Server Error e.g. 500 Internal Server Error

The type of status code you receive depends on the application you are interacting with.
Usually a 4xx error means that you have done something wrong and a 5xx error means that something has gone wrong with the application server you are interacting with.

How To Run TC in Full Screen Mode In Windows 7 !!!

As in Windows 7 Graphics are different from XP. The difference between the drivers of XP and 7 is just of the way of initialization is different....When we run TC and execute programs we got an error like..."full screen mode is not supported"..Follow simple steps to solve this problem as shown below..

  1. Give the right path in 'initgraph' function i.e. C:\\TC\\BIN(if root directory is C)
  2. uninstall the graphic drivers...and then run TC.
  3. Goto options.
  4. click on linker.
  5. click os settings.
  6. uncross the initialize segments.
  7. now restart your TC ..it will open in new graphic mode as provided by inbuilt BGI.
  8. Enjoy!!!!   

Now You will face the problem that whenever you restart the system you have to install the graphic driver again and then uninstall it to initialize BGI.To solve this issue follow somesteps:


  1. right click on desktop!
  2. click on personalize.
  3. choose the theme named 'Windows 7 Classic'.
  4. Enjoy!!!!

By: Soni10.10

Facebook Phishing Be Attentive(Latest Notice)

Phishing

Pronounced like fishingphishing is a term used to describe a malicious individual or group of individuals scamming users by sending e-mails or creating web pages that are designed to collect an individual's online bank, credit card, or other login information. Below is an example of what a phishing e-mail may look like.
Dear eBay customer,

Your Account has been Suspended. We will ask for your password only once. We will charge your account once per year. However you will receive a confirmation request in about 24 hours after the make complete unsuspend process.You have 24 hours from the time you'll receive the e-mail to complete this eBay Request.
Note: Ignoring this message will cause eBay TKO delete your account forever.

To make unsuspend process please use this link:

http://fakeaddress.com/ebay

eBay will request personal data(password;and so on) in this email.
Thank you for using eBay!
http://www.ebay.com/
--------------------------------------------------------------------------------
This eBay notice was sent to you based on your eBay account preferences. If you would like to review your notification preferences for other communications, click here. If you would like to receive this email in text only, click here.
To a user who frequently uses eBay or any online service, these e-mails may appear as if they have come from the company described in the e-mail. However, phishing e-mails are designed to deceive the user and trick them into visiting the links in the e-mail that are designed to steal personal information such as usernames, passwords, credit card information, etc. Below are some helpful tips on identifying these e-mails and how to handle them.
How to identify a phishing e-mail.
  1. Company - These e-mails are sent out to thousands of different e-mail addresses and often the person sending these e-mails has no idea who you are. If you have no affiliation with the company the e-mail address is supposedly coming from, it's fake. For example, if the e-mail is coming from Wells Fargo bank but you bank at a different bank.
  2. Spelling and grammar - Improper spelling and grammar is almost always a dead give away. Look for obvious errors.
  3. No mention of account information - If the company really was sending you information regarding errors to your account, they would mention your account or username in the e-mail. In the above example the e-mail just says "eBay customer", if this really was eBay they would mention your username.
  4. Deadlines - E-mail requests an immediate response or a specific deadline. For example, in the above example, the requirement to log in and change your account information within 24 hours.
  5. Links - Although many phishing e-mails are getting better at hiding the true URL you are visiting, often these e-mails will list a URL that is not related to the company's URL. For example, in our above eBay example, http://fakeaddress.com/ebay is not an eBay URL, just a URL with an ebay section. If you're unfamiliar with how a URL is structured , see the URL definition for additional information.
What to do if you're not sure if an e-mail is official.
  • Never follow any links in an e-mail you're uncertain about. Instead of following the link in the e-mail, visit the page by manually typing the address of the company. For example, in the above example, instead of visiting the fake ebay URL, you would type: http://www.ebay.com in your web browser and log in through the official website.
  • Never send any personal information through e-mail. If a company is requesting you send them personal information about your account or are saying your account is invalid, visit the web page and log into the account as you normally would.
  • Finally, if you are still not sure about the status of your account or are concerned about your personal information, contact the company directly, either through an e-mail address provided on their website or over the phone.
Issues phishing e-mails commonly address
Below are some of the issues a phishing e-mail may inquire about in order to trick users.
  • Account issues, such as account or password expiring, account being hacked, account out-of-date, or account information needing to be changed.
  • Credit card or other personal information, such as credit card expiring or being stolen, incorrect social security number or other personal information, or duplicate credit card or other personal information
  • Confirming orders, such as request that you log in to confirm recent orders or transactions.
Common companies affected by phishing
Below is a listing of some of the companies phishers often send e-mails about.
  • Any major bank
  • Popular websites such as Amazon, Facebook, MySpace, PayPal, eBay, Microsoft, Apple, Hotmail, YouTube, etc.
  • Government: FBI, CIA, IRS, etc.
  • Internet service providers such as AOL, Comcast, Cox, MSN, etc.
  • Casinos and lottery.
  • Online dating or community websites.

DOWNLOAD Notice.pdf


|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

C Program to Draw a Circle using Bresenham's Algorithm


include <stdio.h>
#include <dos.h>
#include <graphics.h>
void circleBres(int, int, int);
void drawCircle(int, int, int, int);
void main()
{
int xc, yc, r;
int gd = DETECT, gm;
initgraph(&gd, &gm, "");
printf("Enter center coordinates of circle: ");
scanf("%d %d", &xc, &yc);
printf("Enter radius of circle: ");
scanf("%d", &r);
circleBres(xc, yc, r);
getch();
}
void circleBres(int xc, int yc, int r)
{
int x = 0, y = r;
int d = 3 - 2 * r;
while (x < y)
{
drawCircle(xc, yc, x, y);
x++;

if (d < 0)
d = d + 4 * x + 6;
else
{
y--;
d = d + 4 * (x - y) + 10;
}
drawCircle(xc, yc, x, y);
delay(50);
}
}
void drawCircle(int xc, int yc, int x, int y)
{
putpixel(xc+x, yc+y, RED);
putpixel(xc-x, yc+y, RED);
putpixel(xc+x, yc-y, RED);
putpixel(xc-x, yc-y, RED);
putpixel(xc+y, yc+x, RED);
putpixel(xc-y, yc+x, RED);
putpixel(xc+y, yc-x, RED);
putpixel(xc-y, yc-x, RED);
}

C Program to Draw a Circle using Mid - Point Algorithm


include <stdio.h>
#include <dos.h>
#include <graphics.h>
void circleMidpoint(int, int, int);
void drawCircle(int, int, int, int);
void main()
{
int xc, yc, r;
int gd = DETECT, gm;
initgraph(&gd, &gm, "");
printf("Enter center coordinates of circle: ");
scanf("%d %d", &xc, &yc);
printf("Enter radius of circle: ");
scanf("%d", &r);
circleMidpoint(xc, yc, r);
getch();
}
void circleMidpoint(int xc, int yc, int r)
{
int x = 0, y = r;
int p = 1 - r;
while (x < y)
{
drawCircle(xc, yc, x, y);
x++;

if (p < 0)
p = p + 2 * x + 1;
else
{
y--;
p = p + 2 * (x - y) + 1;
}
drawCircle(xc, yc, x, y);
delay(50);
}
}
void drawCircle(int xc, int yc, int x, int y)
{
putpixel(xc+x, yc+y, RED);
putpixel(xc-x, yc+y, RED);
putpixel(xc+x, yc-y, RED);
putpixel(xc-x, yc-y, RED);
putpixel(xc+y, yc+x, RED);
putpixel(xc-y, yc+x, RED);
putpixel(xc+y, yc-x, RED);
putpixel(xc-y, yc-x, RED);
}

C Program to Draw a Line using Bresenham's Algorithm


#include <stdio.h>
#include <dos.h>
#include <graphics.h>
void lineBres(int, int, int, int);
void main()
{
int x1, y1, xn, yn;
int gd = DETECT, gm;
initgraph(&gd, &gm, "");
printf("Enter starting coordinates of line: ");
scanf("%d %d", &x1, &y1);
printf("Enter ending coordinates of line: ");
scanf("%d %d", &xn, &yn);
lineBres(x1, y1, xn, yn);
getch();
}
void lineBres(int x1, int y1, int xn, int yn)
{
int dx = xn - x1, dy = yn - y1;
int di = 2 * dy - dx;
int ds = 2 * dy, dt = 2 * (dy - dx);
putpixel(x1, y1, RED);
while (x1 < xn)
{
x1++;
if (di < 0)
di = di + ds;
else
{
y1++;
di = di + dt;
}
putpixel(x1, y1, RED);
delay(20);
}
}