Testing the API behind a mobile app. Tutorial Marc van t Veer



Similar documents
Testing the API behind a mobile app

WEB SERVICES TEST AUTOMATION

No quality mobile apps without testing in production (TiP) Marc van t Veer

KonyOne Server Prerequisites _ MS SQL Server

Database FAQs - SQL Server

Gabriel Iuga. London, United Kingdom Tel: ; Website:

Building native mobile apps for Digital Factory

Fairsail REST API: Guide for Developers

FileMaker Server 10 Help

The easy way to a nice looking website design. By a total non-designer (Me!)

Continuous Integration

Expert PHP and MySQL. Application Desscpi and Development. Apress" Marc Rochkind

Checklist of Best Practices in Website

Cloud Elements! Marketing Hub Provisioning and Usage Guide!

Sisense. Product Highlights.

Product Information. Sugar vs Zoho. Features Comparison

Onegini Token server / Web API Platform

Internet Technologies. World Wide Web (WWW) Proxy Server Network Address Translator (NAT)

Certified Selenium Professional VS-1083

July 2014

Contents. 2 Alfresco API Version 1.0

How To Use Kiteworks On A Microsoft Webmail Account On A Pc Or Macbook Or Ipad (For A Webmail Password) On A Webcomposer (For An Ipad) On An Ipa Or Ipa (For

Getting Started Guide

USER GUIDE WEB-BASED SYSTEM CONTROL APPLICATION. August 2014 Phone: Publication: , Rev. C

Cloud Powered Mobile Apps with Microsoft Azure

owncloud Architecture Overview

REST web services. Representational State Transfer Author: Nemanja Kojic

Unit Title: Content Management System Website Creation

Web Service Testing. SOAP-based Web Services. Software Quality Assurance Telerik Software Academy

Morningtime Ogone Pro Manual (manual v1.0) Step 1 - Preparations Step 2 - unpack and copy files... 2

Getting Started Guide for Developing tibbr Apps

Developing Standards Based Cloud Clients

Service Desk Edition

Manage Workflows. Workflows and Workflow Actions

Web24 Web Hosting Guide

RTI v3.3 Lightweight Deep Diagnostics for LoadRunner

Using the Push Notifications Extension Part 1: Certificates and Setup

Table of Contents. Open-Xchange Authentication & Session Handling. 1.Introduction...3

Expert Android Apps Development

Elgg 1.8 Social Networking

VOL. 2, NO. 1, January 2012 ISSN ARPN Journal of Science and Technology ARPN Journals. All rights reserved

Title page. Alcatel-Lucent 5620 SERVICE AWARE MANAGER 13.0 R7

CARRIOTS TECHNICAL PRESENTATION

Workday Mobile Security FAQ

Designing RESTful Web Applications

SmallBiz Dynamic Theme User Guide

$920+ GST Paid Annually. e-commerce Website Hosting Service HOSTING:: WHAT YOU GET WORDPRESS:: THEME + PLUG-IN UPDATES

About Blue Sky Sessions

Sugar Professional. Approvals Competitor tracking Territory management Third-party sales methodologies

Automatic measurement of Social Media Use

Advanced Web Development SCOPE OF WEB DEVELOPMENT INDUSTRY

soapui Product Comparison

Starting User Guide 11/29/2011

Mobile App Framework For any Website

IBM Endpoint Manager Version 9.1. Patch Management for Red Hat Enterprise Linux User's Guide

Criteria for web application security check. Version

SOA Software API Gateway Appliance 7.1.x Administration Guide

Computer Networking LAB 2 HTTP

FileMaker Server 11. FileMaker Server Help

Customers can select one or more of our services as per their requirements.

MailStore Server 7 Technical Specifications

Server based signature service. Overview

MassTransit vs. FTP Comparison

Online Data Services. Security Guidelines. Online Data Services by Esri UK. Security Best Practice

G-Lock EasyMail7. Client-Server Marketing Software for Windows. Reviewer s Guide

About Google Analytics

Reference Guide TEAM. Pogoplug Team. Reference Guide Cloud Engines Inc., All Rights Reserved.

Drupal Performance Tuning

Taylor & Francis Online Mobile FAQs

Sophos Mobile Control Installation guide. Product version: 3.5

Resco CRM Guide. Get to know Resco CRM

Sugar Professional. Approvals Competitor tracking Territory management Third-party sales methodologies

The full setup includes the server itself, the server control panel, Firebird Database Server, and three sample applications with source code.

API documentation - 1 -

vcommander will use SSL and session-based authentication to secure REST web services.

Syllabus INFO-UB Design and Development of Web and Mobile Applications (Especially for Start Ups)

Sophos Mobile Control Startup guide. Product version: 3

INTEGRATION GUIDE. DIGIPASS Authentication for Citrix NetScaler (with AGEE)

Ce document a été téléchargé depuis le site de Precilog. - Services de test SOA, - Intégration de solutions de test.

Document OwnCloud Collaboration Server (DOCS) User Manual. How to Access Document Storage

Building Library Website using Drupal

WEB SERVICES FOR MOBILE COMPUTING

A Quick Introduction to Google's Cloud Technologies

DIGITAL MARKETING TRAINING

SOA Solutions & Middleware Testing: White Paper

Product Manual. MDM On Premise Installation Version 8.1. Last Updated: 06/07/15

A Tool for Evaluation and Optimization of Web Application Performance

Why API? Using the REST API in an education environment. JAMF Software, LLC

Troubleshooting PHP Issues with Zend Server Code Tracing

MOBILE APPLICATIONS AND CLOUD COMPUTING. Roberto Beraldi

Drupal CMS for marketing sites

Index. AdWords, 182 AJAX Cart, 129 Attribution, 174

MailStore Server 7 - Technical Specifications

Computer Networks. Lecture 7: Application layer: FTP and HTTP. Marcin Bieńkowski. Institute of Computer Science University of Wrocław

Administering Jive for Outlook

ISL Online Integration Manual

RTI Quick Start Guide for JBoss Operations Network Users

Embedded Based Web Server for CMS and Automation System

Syllabus INFO-GB Design and Development of Web and Mobile Applications (Especially for Start Ups)

Sophos Mobile Control Startup guide. Product version: 3.5

Transcription:

Testing the API behind a mobile app Tutorial Marc van t Veer Content What is an API Why use an API How to use an API How-to test an API Exercises Group exercises (learning concepts 7) Individual exercises (apply concepts 4) Lessons learned 1

logo van Flair 17-12-2010 Polteq logo_rgb.png What is an API - Definition API, stands for application program interface: Set of routines, protocols, tools and blocks for building applications (systems of systems) and so reducing complexity Definition within the context of this training: An internet web service that opens systems and giving standard way of access to external users Marc van t Veer Polteq 4 2

What is an API - API model Lego bricks are standard building blocks Blocks are a library to build Figure is showing which resources there are Sales box is an example of the possibilities What is an API - API model 3

What is an API Typical structure API is built upon existing internal architecture app SoapUI Browser Test app s app Facebook API Desktop web Mobile web Adapter Backend (Enterprise Service Bus) Adapter Webservices Adapter Why use an API - example Telecom companies provide usage details on their websites. App developers used screen scraping to get this data into their apps. Resulting in: Misinterpretation of data Malformed data Telecom company gets blamed when the app provides wrong information 4

Why use an API - example API provides the telecom companies: More control over the data Control over the content used in an app Key needed to use the API App developer needs to prove that it works correct before getting access Why use an API Scaling development Enhance a program without editing itself Converting competitors into partners Allow competitors to build on top of your product Scaling market reach Open up new markets Empowering users Allow people to use the product for things it wasn t designed for 5

How to use an API Mashup A mashup is a web page or web application that uses and combines data, presentation or functionality from two or more sources to create new services Easy, fast integration Frequently using API Produce enriched results from the raw source data How to use an API Demo of API s Local examples Command line on Windows or Linux Local VB script with Windows API Web API examples Overview of API s: Programmableweb.com Demo of WordPress blog API 6

How to use an API Concepts Concepts of the API Division of data and presentation Root (Start URL, http or https) Navigation View of a command-line Hierarchy Resources Account (private API) Structure How to use an API Who uses it? Apps: Android, Iphone, Windows, Blackberry Internal organizations User via browser version of the API Social media: Facebook, twitter, etc. (internal/external) developers: Documentation Base line code for new App (with guidelines) Operations (monitoring) 7

Summary Introduction to an API Public available via Internet No-frontend Interfaces API is part of an end-to-end solution Architecture / protocol focus External users / devices Test tools are needed Main goal is: a generic API How-to test an API start from scratch 8

How to test an API start from scratch Architecture REST vs. SOAP Stateless vs. Session Media types vs. WSDL text/xml or application/vendor specific Verbs (GET) and resources Headers and caching results Tools SoapUI, Fiddler, new add-ons for Firefox How to test an API RESTful verbs Verbs are actions, actions like CRUD on database POST: Create a new data element GET: Read a data element PUT: Update a data element DELETE: Delete a data element 9

How to test an API Headers HTTP header fields are components of the message header of requests and responses in the Hypertext Transfer Protocol (HTTP). They define the operating parameters of an HTTP transaction Request example: Accept: text/plain Cache-Control: no-cache How to test an API Cache A web browser stores web content for reuse If the back button is pressed, the local cached version of a page is displayed instead of a new request being sent to the web server. Risks Old data Cached errors Layered caching (app API server) 10

How to test an API - Typical risks Unknown integration Big variation of customer data No control of the E2E chain Load is unknown Wrong use of API Dynamic scope How to test an API - Strategy Early integration test with complete infrastructure Integration test and dog fooding during Development and System Testing Multiple integration phases Prototype app (on Acceptance environment) 11

How to test an API - Dogfooding Dogfooding: Don t try to build the sort of API you think people will want, but use the public API s your self everywhere Examples All Google tools use their own public API s Windows 7 is build with windows 7 Twitter.com uses it s own public API How to test an API - Test approach 1. Development (with dogfooding) 2. System testing (API with stubs and SIT) 3. Integration testing (API with backend) 4. Acceptance testing (API with prototype app) 5. Production integration (in phases) 6. Regression testing (automated) 12

How to test an API - Test approach app SoapUI Browser Test app s app Facebook API Desktop web Mobile web Adapter Backend (Enterprise Service Bus) Adapter Webservices Adapter How to test an API - Mocks and stubs - 1 API s are part of a big E2E chain Testing is only possible if a stub framework is available Stub, driver, mock Example of a stub framework 13

How to test an API - Mocks and stubs - 2 Replacement of a reply from backend system How to test an API - Mocks and stubs - 3 If there is no connection to a backend system Re-routing an interface to a local tool like SoapUI 14

Group exercises Minimum of three implementations is needed for a quality API Learning One implementation: it s a trick Two implementations: it s a method Three implementations: it s your own way of working Group exercises learning concepts Exercise 1 Lorum ipsum text Exercise 2 Colour lovers and Color picker Exercise 3 Authorization Exercise 4 Status and error codes Exercise 5 Header injections Exercise 6 Business rules Exercise 7 Current and future version 15

Exercise 1 Lorum ipsum text Description Generation of Lorum ipsum text Assignment Get a number of lines of bacon ipsum text Tool: Firefox Exercise 1 details Lorum ipsum text API http://baconipsum.com/api/ API documentation Open two tabs One with documentation: http://baconipsum.com/api/ One to enter commands like?type=meat-and-filler 16

Exercise 2 Colour lovers and Color picker Description API provide content in many different types, like generation of colors Assignment Find a favorite color with colour lover API and validate the Hex-code with Color picker Tool: Firefox Exercise 2 details Color lovers and Color picker API http://www.colourlovers.com/api/colors? http://www.colorpicker.com/ API documentation http://www.colourlovers.com/api/ 17

Exercise 3 Authorization Description Difference between public and private API Testing of functional security Assignment Get access to API by using access tokens Tools: Firefox Exercise 3 details Authorization API http://openexchangerates.org/api/latest.json Access key: 66e62d8337b545ec9f0508c1215764b5 API documentation https://openexchangerates.org/documentation https://openexchangerates.org/documentation#appids 18

Exercise 4 Status and error codes Description Explore what is a good and what is a bad request Assignment Find status and error codes and rules to trigger them Which error code is shown when (priority) When do you expect an error code Tools: Firefox + Firebug Exercise 4 details Status and error codes API http://openexchangerates.org/api/latest.json?app _id=66e62d8337b545ec9f0508c1215764b5 API documentation https://openexchangerates.org/documentation https://openexchangerates.org/documentation#e rrors http://en.wikipedia.org/wiki/list_of_http_status _codes 19

Exercise 5 Header injections Description Explore what header elements are Assignment Compare results with and without a header elements If-Modified-Since and If-None-Match Tools: Firefox + Rest Client Exercise 5 details - Header injections API http://openexchangerates.org/api/latest.json?app _id=66e62d8337b545ec9f0508c1215764b5 Documentation https://openexchangerates.org/documentation#e tags http://en.wikipedia.org/wiki/list_of_http_heade r_fields 20

Exercise 6 Business rules Description Compare output between different customer types. Which resource has which output? Assignment Find output of a prepaid and a business customer Find a invoice for a prepaid customer Tool: Firefox Exercise 6 details Business rules API https://capi.t-mobile.nl/ Access key {Bearer} with: {StubbedResidentialPostPaid} {StubbedBusinessPostPaid} {StubbedResidentialPrePaid} Documentation https://capi.t-mobile.nl/documentation Marc van t Veer Polteq 42 21

Exercise 7 Versions of resources Description Resources have a life cycle which is organized in versions for now and the future Assignment Find a resource that is active, have multiple versions and is end of life Tool: Firefox Exercise 7 details - Versions of resources API https://capi.t-mobile.nl/ Access key {Bearer} with: {StubbedResidentialPostPaid} {StubbedBusinessPostPaid} {StubbedResidentialPrePaid} Documentation https://capi.t-mobile.nl/documentation 22

Individual exercises Apply concepts Exercise 8 - Design review Exercise 9 Testing design techniques Exercise 10 Explore test application Exercise 11 - Search of the defects Test levels for testing an API Phase Structure Element Test case -2. Create designs Review -Perform review on API design -1. Test case design Design -Create test cases from designs 0. Setup Test application Setup - Stub frame work - Tooling - Interfaces and test data 1. Development Framework Dog fooding Check easy of use framework and how good it functions 2. System testing Functionality with and without stubs SIT With and without stubs Test applications No stubs Integration with Middleware URL Structure, parameters Header request : character set, media types, Verbs (GET/POST/UPDATE), HTTP(S), status/error codes Logging: Support defect analysis (server and database) HTTP-status: Error and related status Common validation/authentication/authorization Access codes (tokes) Profiles (subscription active, SIM active, token status) Customer/contract types Caching: Duration, authorization, clearing, content, multiple users Navigation: between resources Resources Profiles: Business rules for each resource with variation customer data Output Presentation forms and versions (supported not supported) Monitoring Reporting and performance (load filter, backend availability Documentation Variation in customers, rate plans, prices, contract types, history, options with no stubs 3. Integration testing Internal API with complete backend No regression impact of other projects 4. Acceptance testing External integration API with prototype First integration of app with API 5. Production testing Real customers API with live app Real customers with app on production API 6. Regression Regression Reruns - Manual and Automated regression tests 23

Test application JSON API as plugin for WordPress CMS system Customizable and Open source Based on PHP language and MySQL database Also has mobile application for all platforms See also: http://en.wikipedia.org/wiki/wordpress Test environment setup WordPress server Verification Test tool Request Request Reply API Reply Data 24

IP address WordPress Exercise 8 Design review Description An API design should give all information about how it operates Assignment Use a checklist to review design of JSON API plugin 25

Exercise 8 details Design review API http://wordpress.org/extend/plugins/jsonapi/other_notes/ http://<local IP address>/documentation/jsonapi/ Documentation https://github.com/whitehouse/api-standards http://<local IP address>/documentation/designreview-checklist/ Marc van t Veer Polteq 51 Exercise 8 - Design review result Result of design review on JSON API plugin 26

Exercise 9 Test design techniques Description Normal test techniques are useful Assignment Create test cases for the JSON API plugin of Wordpress Use techniques like State transition Data combination / classification tree Equivalence Class partitioning Boundary Value analysis Exercise 9 Testing design techniques Use scrap paper to write test cases See example workout Documentation http://wordpress.org/extend/plugins/jsonapi/other_notes/ 27

Exercise 10 Explore Test application Description Before you can test the API you should first explore it Assignment Open the JSON API and try it out Exercise 10 Explore Test application details API http://<local IP address>/?json= Documentation http://wordpress.org/extend/plugins/jsonapi/other_notes/ http://<local IP address>/json-api/ To comment or post with RestClient use: Marc van t Veer Polteq name = Content-Type and value = application/x-wwwform-urlencoded 56 28

Exercise 11 Search the defects Description Search defects on the JSON API in WordPress Assignment Use the design test cases Use the learned tooling and techniques Analyze the results Tool: Firefox + Rest Client Exercise 11 API details API http://<local IP address>/?json= Documentation http://wordpress.org/extend/plugins/jsonapi/other_notes/ http://<local IP address>/json-api/ To comment or post with RestClient use: name = Content-Type and value = application/x-wwwform-urlencoded 29

Exercise 11 - Search the defects Which defects are found Evaluation of exercises What went well? What went wrong? Conclusion 30

Lessons learned API API/app communication Testing API New test type: production tests Command line Scope Different skills Security Performance Automation No backup tricks 31

API/app communication Provider of the API is seen as responsible for the presentation of the data in the app Presentation errors of data will always occur Very tempting to fix defects in app instead of API More explanation needed with secured API Testing Normal test techniques Instrument for defect analysis Automated regression tests on production New responsibilities SOA/Interfaces/HTTP protocol/tools Experience with building interfaces 32

More information Marc van 't Veer Test consultant Polteq Amersfoort (Netherlands) +31 (0) 6 46 63 61 48 (mob) http://www.polteq.com marc.vantveer@polteq.com Source References [Apple, 2009] [T-Mobile, 2011] [API design, 2013] Link iphone 3g Commercial "There's An App For That" http://www.youtube.com/watch?v=szrsfeylzyg Customer API T-Mobile: https://capi.t-mobile.nl/ http://apidesign.com [Molen animation,2013] Test design technique http://www.animatieplaatjes.nl/molens.html [SmartBear Software, 2011] SoapUI with REST: http://www.soapui.org/rest-testing/getting-started.html API testing: http://blog.smartbear.com/softwarequality/bid/273613/practicing-safe-sex-with-third-party-apis http://www.pragmaticmarketing.com/resources/why-api-as-astrategy 33

References, continued Source [Tweakers, 2012] WordPress Practical API Design Firefox add-ons Link More secure public API from NS: http://tweakers.net/nieuws/81389/ns-wil-apps-die-prijstreinreis-tonen-vooraf-keuren.html http://www.wordpress.org http://en.wikipedia.org/wiki/wordpress http://developer.wordpress.com/docs/api/ http://wordpress.org/extend/plugins/json-api/other_notes/ Jaroslav Tulach, chapter 9: Keep Testability in Mind http://www.garethhunt.com/modifyheaders/help/ http://jsonview.com/ http://restclient.net/ https://addons.mozilla.org/en-us/firefox/addon/make-addressbar-font-size-big/ References, continued Source [Wiki,2012] Link http://en.wikipedia.org/wiki/application_programming_interfac e#use_of_apis_to_share_content REST architecture: http://en.wikipedia.org/wiki/representational_state_transfer Internet Media Types: http://en.wikipedia.org/wiki/internet_media_type#type_applica tion http://en.wikipedia.org/wiki/mashup_%28web_application_hyb rid%29 http://www.mediawiki.org/wiki/api:main_page http://en.wikipedia.org/wiki/hypertext_transfer_protocol#requ est_methods http://en.wikipedia.org/wiki/list_of_http_header_fields http://en.wikipedia.org/wiki/web_browser 34

References, continued Source [Wiki,2012], continued Learning REST API HTTP design App testing HTTP Header elements Link http://en.wikipedia.org/wiki/service-oriented_architecture Sequence diagrams: http://nl.wikipedia.org/wiki/unified_modeling_language Dogfooding: http://en.wikipedia.org/wiki/eating_your_own_dog_food http://www.restapitutorial.com/ http://toc.oreilly.com/2013/02/a-publishers-job-is-to-provide-agood-api-for-books.html http://net.tutsplus.com/tutorials/other/a-beginnersintroduction-to-http-and-rest/ https://github.com/whitehouse/api-standards http://www.ietf.org/rfc/rfc2616.txt http://www.kohl.ca http://themayesfamily.com/blogs/b/2011/05/rest-client-forfirefox-sample-post-request/ 35