Quality Assurance and Testing Guide
Terms
JSON Web Token (JWT)
: An open, industry standard method for representing claims securely between two parties. IETF RFC 7519
AppKey
: The application identity key which is assigned to a specific application for authorization with GeoToolSuite services.
Development Reference
Please refer to the Application Development Guide documentation for additional details about the service.
Creating a JSON Web Token (JWT) for Testing
Before running any tests, you must have a valid AppKey for testing. Please contact a GTS team member to get a test AppKey and the required JWT secret.
For further information, see Creating a JSON Web Token (JWT)in the development documentation.
There are 2 easy ways to create a JWT token for testing:
Option 1: Create the token with jwt.io
Visit the jwt.io site and scroll down to the Debugger
section.
The Header
provided in their debugger does not need to change. It should already look like this:
{
"alg": "HS256",
"typ": "JWT"
}
The Payload
section will need to be completely replaced with our payload section, which looks like this for a get_map_data
request:
{
"appkey": "insert-your-appkey-here",
"resource": "get_map_data",
"project_name": "tests",
"map_name": "osm-tests-wms"
}
The map_name
key is optional. appkey
, resource
, and project_name
are the only required keys.
In the Verify Signature
section, replace your-256-bit-secret
in the provided text box with the secret value provided by the GTS team when you requested a testing AppKey.
Once you've completed replacing the Decoded
values, you can copy the token from the Encoded
section (it updates live) for use as the X-API-KEY
header value in your Maptimus 2 test requests. It should look something like this:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBrZXkiOiJpbnNlcnQteW91ci1hcHBrZXktaGVyZSIsInJlc291cmNlIjoiZ2V0X2luZm8ifQ.FGiv-HSIk-gfGhUgbNjtkYBS7PYOa9F1sJMTxDL8fKI
Option 2: Create the token with a Python script
A simple Python script using pyjwt to create a token on your client:
import jwt
my_resource = 'get_map_data'
my_appkey = 'insert-your-appkey-here'
my_secret = 'insert-the-secret-here'
my_algorithm = 'HS256'
my_project = 'tests'
my_map = 'osm-tests-wms' # OPTIONAL key
# function to create the token
def create_token(resource, appkey, secret, algorithm, project, mapname=None):
""" create a JWT for use with the GeoToolSuite """
# The mapname key is optional. appkey, resource, and project are the only required keys for the payload.
payload = {'appkey': appkey, 'resource': resource, 'project_name': project, 'map_name': mapname}
token = jwt.encode(payload, secret, algorithm)
return token
# test the function
my_token = create_token(my_resource, my_appkey, my_secret, my_algorithm, my_project, my_map)
print(my_token)
You should replace insert-your-appkey-here
with the AppKey provided by the GTS team and replace insert-the-secret-here
with the secret key also provided by the GTS team.
The result will look something like:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBrZXkiOiJpbnNlcnQteW91ci1hcHBrZXktaGVyZSIsInJlc291cmNlIjoiZ2V0X2luZm8ifQ.FGiv-HSIk-gfGhUgbNjtkYBS7PYOa9F1sJMTxDL8fKI
Maptimus 2 Environment Setup
Prior to testing Maptimus 2, ensure that the appropriate TokenService and Maptimus 2 nodes are running in the lifecycle you are about to test. Check with a GTS team member to get a list of hostnames to check.
You can check the status of servers using the Pipelines List Servers Job.
Running Unit Tests
All unit tests provided in the tests
folder in version control should pass once you've setup your development environment correctly.
Make sure all Python modules in deploy/shared/requirements.txt are installed and working in your Python interpreter.
Make sure all Python modules in deploy/mapserver/requirements.txt are installed and working in your Python interpreter.
Make sure all Python modules in deploy/mapcache/requirements.txt are installed and working in your Python interpreter.
Make sure all Python modules in deploy/web/requirements.txt are installed and working in your Python interpreter.
The following environment variables must be set in your operating system with correct values:
RABBITMQPASS, JWTSECRET, PYTHONPATH, MAPTIMUSAPPKEY
Please chat with a GTS team member if you need assistance getting your environment setup.
General Test Case(s)
1. Test the HealthCheck request
MAP-229,
MAP-230,
MAP-231,
MAP-232
1a. Send a message using the following URL:
https://maptimus.certusview.com/api/v2/healthcheck
1b. After sending a message, the response should look like:
{
"MapFiles": "pass",
"MapServer": "pass",
"RabbitMQ": "pass",
"status": "ok"
}