Testing with Stresty
Configure Your Box
Create a box here https://aidbox.app/static/aidbox.html. See the tutorial on how to create a new box.
Access the REST Console of the created box. Execute the following requests. Their meaning you can read in the tutorial.
POST /Client
id: basic
secret: secret
grant_types: ['basic']
POST /AccessPolicy
id: api-clients
engine: allow # which means it has permisions for everything
description: Root access to specific clients
link:
# link policy with client
- resourceType: Client
id: basic # client.id
Create a folder on your disk for the stresty files. Go to the folder in a command line console. Execute the following command there to download stresty.jar:
curl -L -o stresty.jar https://github.com/Aidbox/stresty/releases/latest/download/stresty.jar
Create the following file in the same folder. Name it test.yaml.
desc: Create & Read Patient
steps:
- id: clean
desc: Clear all patients
POST: /$sql
body: 'TRUNCATE patient'
match:
status: 200
- id: create
desc: Create test patient
POST: /Patient
body:
id: pt-1
name: [{given: ['Ivan'], family: 'Pupkin'}]
match:
status: 201
body:
id: pt-1
name: [{given: ['Ivan']}] # Checks only given name
- id: read
desc: Read our patient
GET: /Patient/pt-1
match:
status: 200
body:
id: pt-1
name: [{given: ['Ivan'], family: 'Pupkin'}]
- id: search-by-id
GET: /Patient?_id=pt-1
match:
status: 200
body:
entry:
- resource: {resourceType: 'Patient', id: 'pt-1'}
- id: update
desc: Update our patient
PUT: /Patient/pt-1
body:
name: [{given: ['Petr'], family: 'Pupkin'}]
match:
status: 200
body:
name: [{given: ['Petr'], family: 'Pupkin'}]
In the same folder, execute the following commands in the console.
1
Replace <your_box_name> with the name of your box.
export AIDBOX_URL=http://<your_box_name>.aidbox.app
2
export AIDBOX_AUTH_TYPE=Basic
3
export AIDBOX_CLIENT_ID=basic
4
export AIDBOX_CLIENT_SECRET=secret
5
Now you are ready to run the test script with stresty:
java -jar stresty.jar test.yaml
The output will be the following:
$ java -jar stresty.jar test.yaml
Args: [test.yaml]
Configuration:
{:verbosity 0,
:interactive false,
:base-url "https://strestytests.edge.aidbox.app",
:client-id "basic",
:client-secret "secret",
:authorization-type "Basic"}
run test case test.yaml
passed test.yaml
Test results: 5 passed,
0 failed,
0 skipped.
You can check your box, it now has a patient. Access your REST Console and make the request:
GET /Patient
Read more about stresty, predicates and regexps here.
Last updated
Was this helpful?