A Generalized Swagger (OpenAPI) Centered Web Services Testing Framework
Version 0.1
October 23, 2018
http://www.by-star.net/PLPC/180057
Copyright ©2014 Neda Communications, Inc.
Permission is granted to make and distribute complete (not partial)
verbatim copies of this document provided that the copyright notice
and this permission notice are preserved on all copies.
Contents
- Part I Overview Of mmwsIcm Web Services Testing Framework
- Part II rinvoker
- Part III Operation Scenarios
Part I |
1 Invokers Development Model
1.1 Invoker ICMs Development Model
Invoker ICMs Development Model
Given a Service Definition (a swagger file) and a Performer Server, you should be able to conveniently Invoke any of the offered Operations through:
- swagger.ui interface – usually offered by the Performer Server
- unisos.mmwsIcm :: rinvoker.py – command line and batch oriented equivalent of swagger.ui
- unisos.mmwsIcm :: ro.py – invoke-specification – invoke-verification – invoke-reporting
- unisos.mmwsIcm – rich library for building invoker Apps
1.2 Invoker Framework: Ingredients
Remote Invoker ICMs Development Model
Main software packages that implement the framework include:
- Python Bravado – Equivalent of Invoker Codegenartor But Better
- unisos.icm – Interactive Command Module
- Makes icm.Cmnd classes invokable at command-line
- do-icm :: Direct Operation ICMs (Used by performers)
- unisos.mmwsIcm
- unisos.mmwsIcm.wsInvoker.py – Maps invocations to http requests
- unisos.mmwsIcm.ro.py – Abstracts invoke-specifications
- unisos.mmwsIcm.rinvoker.py – Maps command-line args to invokations
Try It: pip install unisos.mmwsIcm
Part II |
2 rinvoker.py
2.1 rinvoker.py Overview
rinvoker.py Overview
Allows you to list all possible invocations based on a service specification (swagger file).
rinvoker.py --svcSpec="http://petstore.swagger.io/v2/swagger.json" -i svcOpsList
Allows you to fully specify an invocation on command line. Example:
rinvoker.py --svcSpec="http://petstore.swagger.io/v2/swagger.json" --resource="user" --opName="createUser" -i rinvoke bodyStr="{...}"
Part III |
3 Invoke-Specifications, Invoke-Verification, Invoke-Reporting
3.1 Model Of Invoke – Specification, Verification And Reporting – Scenarios
Model Of Invoke – Specification, Verification And Reporting – Scenarios
- Invoke Scenarios Are pure python specification of sequence of invocations.
- Invoke-Expect Scenarios Are pure python specification of sequence of invocations subject to preparations and post-invoke verification and reporting.
- opInvoke class allows for complete invoke specification and complete results to be fully captured.
3.2 Scenario Specification For Sequences Of Invocations
Scenario Specification For Sequences Of Invocations
In pure python specify invocation of each operation, for example:
rosList.opAdd( svcSpec=akSkToken_svcSpec, # e.g. "../SvcSpec/akSkToken.json" perfSap=akSkToken_perfSap, # e.g. "http://localhost:8080/access/v1.0" resource="token", opName="obtain", roParams=ro.Ro_Params( headerParams=None, urlParams=None, bodyParams={ 'accessKey': "someOtherId", 'secretKey': "someOtherCredentials",},), roResults=None, )
Then load that list of invocations and subject them to sequential invocations.
Validation And Reporting Of Invokations
Building on the previously mentioned Operation Specification, in pure python you can the specify Operation Expectations, for example:
roExpectationsList.opExpectationAdd( # Above mentioned operation specification # ... preInvokeCallables=[], postInvokeCallables=[ verify_akSkTokenObtainRo, ], )
For example, preInvokeCallables(ro.Ro_OpExpectation) can include a function that initializes the DB.
For example, postInvokeCallables(ro.Ro_OpExpectation) can include a function that verifies the operation’s result was as expected and then reports success or failure.
4 Invoker-Apps Development Model
4.1 Invoker-Apps Can Easily Build On unisos.mmwsIcm Capabilities
Invoker-Apps Can Easily Build On unisos.mmwsIcm Capabilities
- Bravado does invoker code-generation on the fly.
- unisos.mmwsIcm.opInvoke – Abstracts invoke-specifications
- unisos.mmwsIcm.wsInvoker – Allows for invokation and verification of opInvoke
With these in place, building Invoke-Apps becomes very simple.
5 Benefits And Advantages Of The Generalized Swagger Centered Invocation Model
5.1 Taking Full Advantage Of Service Specification For Testing And Development
Benefits And Advantages Of The Generalized Swagger Centered Invocation Model
- The Generalized Model and Capabilities Presented Here Apply To Any Service That Exposes Its Swagger Specifications
- A great deal of automation capabilities have become possible based on swagger specifications.
- The Testing Framework Of (invoke-specification, invoke-verification and invoke-reporting) permits for disciplined compelte external testing of web-services based on swagger specifications.
Very Often, These Best Current Practices Are Not Being Followed.