Testing BB API with IM
This page describes how to test BB using a request from another BB. GovStack uses for this purpose Information Mediator. REST request goes this way:
Request from another BB → IM of another BB → IM of tested BB → API of tested BB
Let’s assume that OpenAPI specification of the tested API looks like this
{
"openapi" : "3.0.0",
...
"servers" : [ {
"url" : "https://{Service_URL}",
...
} ],
"paths" : {
"/{path_of_API}" :
"get" :
"parameters" :
"x" : string
...
Here {Service_URL} and {path_to_API} are placeholders where some real data must be located.
To call this API one can enter from the prompt of the computer where the tested BB is installed following command:
curl -X GET "https://{Service_URL}/{path_to_API}?x=abcdef"
Let’s assume that the IM of the tested BB is configured this way:
Parameter | Value | Comment |
---|---|---|
Instance | govstack | some agreed constant name |
Member Class | GOV | assume governmental member |
Member Code | 123 | registration number of member |
Application | TestedBB | name for referring Tested BB |
Service Code | srvc | name of the tested service. One can interpret this as name of file witch contains OpenAPI spec |
and the IM of another BB has the following configuration
Parameter | Value | Comment |
---|---|---|
Instance | govstack | the same as for previous IM |
Member Class | COM | assume commercial member |
Member Code | 456 | registration number of member |
Application | AnotherBB | name for referring another BB |
In this case, for the IM of version 1.0 another BB must start the same call this way:
curl -X GET \
-H "X-GovStack-Client: govstack/COM/456/AnotherBB" \
"https://{address_of_IM_of_another_BB}/r1/govstack/GOV/123/TestedBB/srvc/{path_to_API}?x=abcdef"
But starting from the IM version 2.0 this could be called:
There will be scripts in the Sandbox environment to help to automate these testing scenarios.