testrestapi-sample-preview.pdf - Automating and Testing a REST API A Case Study in API testing using Java REST Assured Postman Tracks cURL and HTTP

testrestapi-sample-preview.pdf - Automating and Testing a...

This preview shows page 2 - 7 out of 74 pages.

Automating and Testing a REST APIA Case Study in API testing using: Java, REST Assured,Postman, Tracks, cURL and HTTP ProxiesAlan RichardsonThis book is for sale atThis version was published on 2017-08-21This is aLeanpubbook. Leanpub empowers authors and publishers with the LeanPublishing process.Lean Publishingis the act of publishing an in-progress ebook usinglightweight tools and many iterations to get reader feedback, pivot until you have the rightbook and build traction once you do.© 2013 - 2017 Alan Richardson
Background image
ContentsThanks for Reading This Sample. . . . . . . . . . . . . . . . . . . . . . . . . . . . .1Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3Introduction to APIs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5What Is a Web Application?. . . . . . . . . . . . . . . . . . . . . . . . . . . . .5Google Is an Example of a Web Application. . . . . . . . . . . . . . . . . . . . .5What Is an API?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7What Is an HTTP Request?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8What Is a URL?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9What Are HTTP Verbs?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10What Is an HTTP Response?. . . . . . . . . . . . . . . . . . . . . . . . . . . . .11What Is an HTTP Status Code?. . . . . . . . . . . . . . . . . . . . . . . . . . . .12What Are Payloads?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12What Is JSON?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13What Is XML?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13What Are HTTP Headers?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15What Is Authentication?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15What Is REST?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17What Tools Are Used for Accessing an API?. . . . . . . . . . . . . . . . . . . . .17Example APIs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18Recommended Reading. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18Introducing Tracks Case Study. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19Support Page. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19How to Use This Case Study. . . . . . . . . . . . . . . . . . . . . . . . . . . . .20Source Code Location. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .20Case Study Contents Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . .21
Background image
CONTENTSWhy Test Tracks?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21What Is Tracks and GTD?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24Installing Tracks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26Official Tracks Install. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26Pre-Built Virtual Machines. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27Using Virtual Machines. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .28Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .28A Tour of Tracks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29Why Learn the GUI If We Are Testing the API?. . . . . . . . . . . . . . . . . . .29Login. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .30Home Screen. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31Starred Screen. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32Projects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33Admin. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34Basic Functions to Use and Check in the API. . . . . . . . . . . . . . . . . . . .35Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .36The Tracks REST API. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .37What Is a REST API?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .37Tracks REST API Documentation. . . . . . . . . . . . . . . . . . . . . . . . . .38API Doc Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .38General HTTP REST Return Codes. . . . . . . . . . . . . . . . . . . . . . . . . .40Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40Using a Proxy to View GUI Traffic. . . . . . . . . . . . . . . . . . . . . . . . . . .41Why?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41How?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41Viewing Traffic. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42Implications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44Exploring the Tracks API with cURL Through a Proxy. . . . . . . . . . . . . . . .45Using a Proxy with cURL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .45For Debugging. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .46For Exploration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .46For Simple Scope Coverage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .46Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .46
Background image
CONTENTScURL Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .48Exploring Tracks API with Postman REST Client. . . . . . . . . . . . . . . . . . .50The GUI. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .50Issue Requests. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .51Postman Collections. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .53Environment Variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .54Authentication. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .55Using Postman Through a Proxy. . . . . . . . . . . . . . . . . . . . . . . . . . .55Recreate cURL Requests in Postman. . . . . . . . . . . . . . . . . . . . . . . . .57Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57Starting to Automate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .58Why Explore First?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .58Choosing a Java Library. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .58REST Assured Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .60REST Assured Related Reading. . . . . . . . . . . . . . . . . . . . . . . . . . . .65Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .66About the Author. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .67Thanks for Reading This Sample. . . . . . . . . . . . . . . . . . . . . . . . . . . . .68
Background image
Thanks for Reading This SampleThanks for reading this sample of my “Automating and Testing REST APIs” book. This is anexcerpt from the main book.There should be enough in the sample to provide general introductory information to helpyou get started with testing REST APIs, specifically the Tracks API.What you basically have here are chapters 1, 2, 3, 4, 5, 8, 9 and 10. So you get to see:• Introduction• How to install tracks• A GUI tour of tracks• The tracks API Documentation• Using a Proxy to view GUI traffic• Using cURL through a Proxy• cURL Reference Guide• Starting to Automate DecisionsWhat you don’t see in here is the actual case study, about 120 pages (or more) of extrainformation:• How I used cURL to test the API• How I used a proxy fuzzer to create users automatically via HTTP• How I automated creating users with REST Assured even though the REST API doesn’tsupport it• Creating abstraction layers for REST API testing in Java• How to use the REST Assured Java/Groovy library for HTTP/REST Testing• Random Data Creation• Refactoring and Next StepsAbsolutely masses of valuable and practical content.But you do have links to all the tools, and libraries and you can view the source code onGitHub so you can see exactly what I will explain in detail in the full book.
Background image
Image of page 7

You've reached the end of your free preview.

Want to read all 74 pages?

  • Fall '16
  • fsafasgfsag
  • World Wide Web, Web server, Web browser, Representational State Transfer, HTTP

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes