Wednesday, July 22, 2020

API Testing- benefits, Type of APIs, API Gateways

What is API?

Application programming interface

  • Software creation
  • System interaction
  • Consists of
    • Protocols
    • Functions
    • Objects
    • Commands
  • Code does not have to be rewritten
  • Available for web, window and mobile apps

 

Key benefits of using APIs

  • Conform to standards
  • Can be provided as a service
  • Data and functionality can be outsources
  • APIs can be offered by local systems
  • Allows developers to focus on other important aspect of application development

 

Decoupling services from applications

  • Consuming application is not connected to the servicing infrastructure
  • Service providers have great flexibility
  • Endpoint service delivery remains unchanged
  • API contract

 

Remote APIs

Overview of Remote APIs

  • Access and manipulate remote resources
  • Utilizes various protocols and standards
  • Independent of language and platform

 

Web APIs

  • Standards for connecting application to an API
  • Network or internet connections
  • Hypertext Transfer protocol
  • Web API
    • Web addressable endpoints
    • Support HTTP commands
  • Various internet based APIs

 

Common browser APIs

  • Document manipulation in browser
  • Fetch data from server
  • Audio
  • Video
  • Create and manipulate graphics like canvas and webGL

 

RestAPI

  • representation state transfer
  • web service access protocols
  • Rest aims to address soap shortcomings
  • Rest is lighter weight
  • Relies more on URL than xml
  • Provides flexibility on data output form

 

REST API tasks

  • GET -to retrieve
  • POST – to create
  • PUT – to update
  • Delete- to delete

 

REST API Advantages over SOAP

  • Designed similar to existing web technology
  • Does not require expensive tools
  • Easier to learn
  • No excessive processing
  • More efficient- smaller messaging

 

SOAP API

  • Simple object access protocol
  • Web service access protocols
  • Well established
  • More rigid than rest api
  • Relies on XML – can become highly complicated
  • Highly extensible
  • Difficulty depend on language used
  • http vs SMTP

 

SOAP advantages over rest API

  • independent of language and platform
  • independent of transport protocols
  • standardized
  • ideal for distributed environments
  • WS* standards
  • Build in error handling
  • Automation

 

API gateways

  • Classic API gateways
    • Sit between provider and consumer
    • Web services
    • Centralize functions
  • Microservice architectures
  • Microgateways
    • Functions are a subset of classic api gateway functions
    • Unique and automated deployment method
    • Scalability

 

Security functions

  • Multilayered API protection
  • Authentication
  • Authorization
  • Identity mediation
  • Security monitoring
  • Traffic encryption and signatures
  • Key and certificate management

 

Monitoring and Administration functions

  • Real time monitoring
  • Alerts
  • Insights and trends
  • Managing daily operations
  • Client management
  • Other integration scenarios

 

Control functions

  • Control and governance
  • Service level agreement
  • Throttling
  • Load balancing
  • Content based routing
  • Blocking
  • Quote management

 

Transformation functions

  • Bidirectional transformation
  • Less time to market
  • Numerous protocols, formats and various standards
  • Replacement of existing systems
  • Lightweight API orchestration tools

 

API Endpoints

  • Web service entry point : URL
  • Used to reduce latency
  • Some services support regional endpoints
  • Multiple region deployment
  • Custom domain name
  • Route clients to low latency regions

 

Cheers.

TJ

 

API Management and Strategy

API Management Strategy

  • Robust strategy is mandatory
  • Allowing users to create, manage, secure, analyze and scale APIs is important
  • Managing the architecture, performance and security is critical
  • Managing and engaging developers is crucial
  • Permitting developers to rapidly create PIs from existing data and service is essential

 

API management infrastructure

  • API gateways are platform for hosting API proxies
  • API developer portals allow for the usage of published APIs
  • API management UIs permit the management and development of APIs, API proxies and API environments

 

API management features

  • Analytics and statistics help understand how the API is being used
  • Developer friendly documentation with examples is crucial to encourage developers to use the system
  • Engaging the API consumers, developers and partners is extremely important for on boarding
  • Sandbox environments allow for developing and testing code
  • Support should be provided for public and private cloud
  • Identify and access management should be provided for security
  • Traffic management and caching features should be provided
  • Support should be provided to monetize the API
  • Support should be provided for legacy systems
  • The service should be available, scalable and redundant

 

API Management Best practices

  • Ensure the system allows for authorization, billing and payment for API usage
  • Provide an easy to use environment for user to integrate and compose APIs
  • Permit the management of the API life cycle and SOA governance
  • Provide users with a unique API key that can be used to track and set permission for SLAs
  • Enable throttling and configure SLA tiers to help prevent abuse
  • Ensure security detection and prevention are available to prevent malicious functions
  • Standards need to be enforced during the API life cycle
  • APIs should be easy to read about, discuss, and test
  • Cataloging should be performed to enable API discovery and use
  • APIs need to be monitored to track usage, errors and malicious attacks
  • An API portal should be available to engage with developers and B2B partners
  • APIs should be ritualized and protected using an enterprise gateway
  • Notification should be sent when an event impacts an API
  • APIs should be searchable using custom taxonomies or search functionality
  • API traffic should be monitored to track metrics to track metrics for monetization purposes

 

API monitoring strategy

  • Determines if APIs are available and functioning at expected
  • Works together with CI/CD automatically test new version of
  • Provides important performance data to the developers and operational teams

 

Tool selection

  • The tool needs to be intuitive in order to use it to its full potentials
  • Existing scripts created with API tools should be reusable and importable
  • Scheduling should be available to run monitors at peak times and various intervals
  • Sequencing and assertions should be available to ensure that APIs return the correct data
  • The tool should make data easy to consume and share to provide actionable insights
  • The tool should be adaptable and easy to integrate into your existing infrastructure
  • The tool should be able to alert he users when something goes wrong quickly and using multiple methods

 

Methods for creating API monitors

  • Import open API specification or swagger specification files
  • Import test scripts from soapui or ready API
  • Create new API endpoint monitors using a url and add assertions and validations
  • Create a chained API endpoint monitor using endpoints, urls and validations

 

Advantages of reusing functional tests

  • Real API functionality can be continuously tested
  • Existing functional tests already have assertions and more descriptive error messages
  • Functional API monitors imitate real usage and provide insight to technical operations
  • Using a single tool for testing and monitoring  APIs decreases expenses and the learning curve

 

API monitoring best practices

  • API availability needs to be tracked and logged
  • API transactions and authentication need to be monitored
  • Data collected from monitoring needs to be bench marked against competitors
  • To prevent SLA breaches, alerts should be sent for any outages or performance issues
  • Tests need to be configured with request headers for simulating and API transaction
  • Basic HTTP authentication needs to be supported to ensure secure and reliable data
  • Multiple APIs need to be monitored if they are part of an application to determine any performance bottlenecks
  • Analyse performance trends on monitoring data collected over time
  • APIs need to be tested to ensure the data is correct and in the right format
  • Integrate the API testing system data with the monitoring systems
  • API monitoring for performance and functional up time testing can help avoid security breaches
  • Comprehensive end to end testing and monitoring should be performed understand the big picture
  • Functional monitoring should be performed at regular interval to reduce human error
  • Business activity should be monitored to determine throw users are deriving business value from the APIs
  • Metrics need to be tracked to determine how much money is created from the API for both client and business
  • Functionality should be available for clients to write their own customized tests

 

API management tools

Tool selection criteria

  • Tools need to be easy to use and have good training and support documentation
  • Tools need to support scalability and growing demand for APIs
  • Strong single sign on and SSL support are crucial in maintaining security
  • The tools should provide functionality for publishing and consuming APIs

Kong API manament tool

  • One of the best open source API gateway
  • Good for startups, small, medium, and large sized businesses
  • Delivery can be as a proxy solution
  • Enterprise pricing plans are available as wella s a free evalution plan

 

3scale API management tool

  • Provides a strong developer portal
  • Good for startup, small,medium and large sized businesses
  • Delivery can be as a proxy, agent and hybrid solution
  • Professional and enterprise pricing plans are available

 

Apigee api management ool

>best tool for monetization of API

Good for small and medium sized business

Delivery can be as a proxy, agent or hybrid solution

Professional and enterprise pricing plans are available as well as free evalution plan

 

Akana

  • Has strong life cycle management tool
  • Good for large enterprise sized businesses
  • Delivery can be as proxy, agent or hybrid solution
  • Proessional and enterprise pricing plan

 

API monitring tools

  • Both open source and commercial api montiorning tools are available
  • Endpoints can be monitored for uptime, availability , response time, performance and other variables
  • Provide functionality for logging, visualization and time series data

Time series data gadgets

Assertible api management tools

Alertsite api monitoring tool- support mobile and saas  application

Open source tools- Prometheus is time series monitoring tool, graphite is push based monitoring tool, influxDB is part of large tick stack

 

API Metrics stakeholders

  • The infrastructure teams needs metrics to ensure the API services are running correctly
  • Development teams need metrics to ensure the apis are running quickly and bug free
  • Sales and marketing need to ensure the customers needs are being met with the apis features
  • Product management needs to balance creating new apis with maintaining existing apis, while ensuring all stakeholders are satisfied

 

Infrastructure API metrics

  • Uptime is one of the key metrics for measuring service available
  • CPU usage can indicate high demand or API performance issue
  • Memory usuage can help determine if memory needs to be increased or decreased

 

Development API metrics

  • Requests per minutes can be used by development to help make API more efficient
  • Average and max latency indicate to the developers and infrastructure team that there is something slowing down the api services
  • Errors per minute indicates that there is an issue with api having bugs or that is being called with incorrect parameters

 

Business API metrics

  • Unique api consumers is used by product managers to determine number of customers using the APIs
  • API usuage is important for product managers to determine demand for existing apis
  • Top customers by api usage tells the business who they should work with to develop new api services
  • Api retention allows the business to determine if more funding should be spent on development or growth
  • Time to first hellow world determines the effectiveness of the documentation, tutorials and marketing efforts
  • Api calls per business transaction indicates the effectiveness and efficiency of your endpoints

 

SOAP UI API testing

  • Can be used for testing SOAP and restful web services
  • Can be used for functional, performance, security interoperability and regression testing
  • Can be used for creating virtual services that be used for test driven development
  • 2 error- 400 client something wrong, 500 api something wrong

SOAP UI Rest API testing

  • Create, read, update and delete
  • Get requests can be used to read or retrieve data
  • Post requests can be used to add new data
  • Put requests can be used to update existing data
  • Delete requests can be used to remove data

 

SOAP UI SOAP API testing

  • WSDLs can be imported and default requests can be auto generated
  • Supports common standards such as ws-security, ws-addressing, ws-reliabile messaging, and MTOM
  • WS-I compatibility testing permits validating both contracts and methods
  • Mock services can be created from WSDLs to simulate simple and complex user behavior

 

SOAPUI performance testing

  • Baseline testing examines the system under normal load, which can be compared with other tests
  • Load testing involves increasing the load to test how the system performs
  • Stress testing involves increasing the load until the system stops working
  • Soak testing includes running baseline or load testing over a period of time
  • Scalability testing involves testing the system to ensure it scales as expected

 

SOAPUI API security testing and options

  • Performs common security tests such as SQL injection attacks and XML bombs
  • The empty option creates a test with no pre-configured security scans
  • The automatic option creates a default set of security scans
  • The full control option allows you to select security scans for your tests

 

SOAPUI automated testing

  • Create REST project> enter URL and click ok
  • Get resource appear as request1
  • Top window- method> get and endpoint and run the request
  • Right side shows response with XML, html, JSON
  • Right click on request one >add testcase> enter testsuite name>click ok>enter test case name> enter request name and click ok
  • Click on assertion tab in bottom of window > click + sign>JSON path expression
  • On project url> right click add resource> post
  • Same steps to add test case

 

 

 

 

Test Automation cycle in Agile

Agile Automated Testing quadrants

Q1- Automated- unit

Q2 -Requirements- business focus

Q3- Manual – feedback of Q1 and Q2 and starting for automated testing

Q4- Tools - Non functional requirments

 

Agile Automated Testing plan

  • For each release of application
  • Testing scope
  • Feature complexity tst coverage
  • Test new functionality
  • Performance and load testing
  • Infrastructure review
  • Available resources
  • Mititgation or risk plan
  • Deliverables and milestone of testing

 

Agile Automated testing life cycle

  1. Iteration 0- initial setup identify resource,install tools, scheduling etc- ,
  2. construction iterations
  3. Release end game- system and acceptance testing
  4. Production

 

Agile automated testing risks

  1. Cost to build and maintain
  2. Does not replace exploratory manual testing
  3. Unreliable tests or unclear user stories
  4. Relying on macro-recording test
  5. Part of continuous integration process
  6. Inadequate test plan
  7. Missing setup/tear down scripts
  8. High level of maintenance
  9. Metrics may be misleading
  10. Lack of automated testing expertise
  11. Team collaboration is crucial
  12. Focusing on the valuable features

 

Agile and Devops Test automation

Agile vs. Devops principles

  • Agile- speed of deployment, while in devops-team specialization
  • Agile focus on creating vs deploying software while devops focus on communication vs documentation
  • Devops relies on documentation, while agile will be scheduling timeframe or meetings
  • Agile teams are small, devops many teams collaborate to large team
  • Agile focus not on automation, devops focus on automation

 

Devops test automation factors

  • Management of test data
  • Steering parameters
  • Test servers and virtualization
  • Dedicated test user accounts
  • Continuous testing and integration
  • High degree of communication required among teams

 

Test automation and Dev-Ops

  • Supports continuous development
  • Coordination required amongst stakeholders
  • All processes must be automated

 

Dev-Ops test automation best practices

  • Set achievable expectations
  • Ensure test automaton is adopted
  • Assign dedicated resources
  • Decide on a starting point
  • Include automation testing in definition of done
  • Review and adapt

 


Test Management in Agile using Jira (Scrum/Kanban)

Test Management in Jira

Need account in Jira

To configure jira project click on Jira setting > clicks on Apps > Manage App or find new apps (TM4J- test management for jira – paid plug in (free trial))

Back to main menu

Click on Test

Click on project setting page

Click on “On”

Permission “On”

Test cycle, test cases, reports etc can be set

 

Whole Team Approach

Collaborative user story creation

Tester can give idea for user story creation

  • Release planning
  • Sprint planning
  • Test analysis
  • Automation testing
  • Regression testing

 

Agile testing practices

  • Pairing
  • Incremental test design
  • Agile metrics
  • Sprint retrospectives

 

Agile Testing methods

  • Test driven development – programming practice for unit automated testing
  • Acceptance test driven development – focus on acceptance test cases
  • Behavior driven development – involves visualize the behavior of system or application , its language oriented with simple English cucumber with selenium

 

Scrum and Kanban in Jira

1 scrum project

  • Jira dashboard > project > create project > select Classic > project name and key Template Scrum and create
  • Showing active sprints
  • Click on backlog
  • Create sprint
  • Create user stories

 

kanban project

  • Jira dashboard > project > create project > select Classic > project name and key Template kanban and create
  • Showing kaban board
  • Click create an issue
  • Enter summary select issue type
  • Can move to development, inprogress and done