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.
Create a client:
1
POST /Client
2
3
id: basic
4
secret: secret
5
grant_types: ['basic']
Copied!
Create an access policy for your client:
1
POST /AccessPolicy
2
3
id: api-clients
4
engine: allow # which means it has permisions for everything
5
description: Root access to specific clients
6
link:
7
# link policy with client
8
- resourceType: Client
9
id: basic # client.id
Copied!
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:
1
curl -L -o stresty.jar https://github.com/Aidbox/stresty/releases/latest/download/stresty.jar
Copied!
Create the following file in the same folder. Name it test.yaml.
test.yaml
1
desc: Create & Read Patient
2
3
steps:
4
- id: clean
5
desc: Clear all patients
6
POST: /$sql
7
body: 'TRUNCATE patient'
8
match:
9
status: 200
10
- id: create
11
desc: Create test patient
12
POST: /Patient
13
body:
14
id: pt-1
15
name: [{given: ['Ivan'], family: 'Pupkin'}]
16
match:
17
status: 201
18
body:
19
id: pt-1
20
name: [{given: ['Ivan']}] # Checks only given name
21
- id: read
22
desc: Read our patient
23
GET: /Patient/pt-1
24
match:
25
status: 200
26
body:
27
id: pt-1
28
name: [{given: ['Ivan'], family: 'Pupkin'}]
29
- id: search-by-id
30
GET: /Patient?_id=pt-1
31
match:
32
status: 200
33
body:
34
entry:
35
- resource: {resourceType: 'Patient', id: 'pt-1'}
36
- id: update
37
desc: Update our patient
38
PUT: /Patient/pt-1
39
body:
40
name: [{given: ['Petr'], family: 'Pupkin'}]
41
match:
42
status: 200
43
body:
44
name: [{given: ['Petr'], family: 'Pupkin'}]
Copied!
In the same folder, execute the following commands in the console.

1

Replace <your_box_name> with the name of your box.
1
export AIDBOX_URL=http://<your_box_name>.aidbox.app
Copied!

2

1
export AIDBOX_AUTH_TYPE=Basic
Copied!

3

1
export AIDBOX_CLIENT_ID=basic
Copied!

4

1
export AIDBOX_CLIENT_SECRET=secret
Copied!

5

Now you are ready to run the test script with stresty:
1
java -jar stresty.jar test.yaml
Copied!
The output will be the following:
1
$ java -jar stresty.jar test.yaml
2
Args: [test.yaml]
3
Configuration:
4
{:verbosity 0,
5
:interactive false,
6
:base-url "https://strestytests.edge.aidbox.app",
7
:client-id "basic",
8
:client-secret "secret",
9
:authorization-type "Basic"}
10
11
12
run test case test.yaml
13
passed test.yaml
14
15
Test results: 5 passed,
16
0 failed,
17
0 skipped.
Copied!
You can check your box, it now has a patient. Access your REST Console and make the request:
Request
Response
Execute in the box REST Console:
1
GET /Patient
Copied!
Status: 200
1
query-time: 20
2
meta: {versionId: '10'}
3
type: searchset
4
resourceType: Bundle
5
total: 1
6
link:
7
- {relation: first, url: '/Patient?page=1'}
8
- {relation: self, url: '/Patient?page=1'}
9
query-timeout: 60000
10
entry:
11
- resource:
12
name:
13
- given: [Petr]
14
family: Pupkin
15
id: pt-1
16
resourceType: Patient
17
meta: {lastUpdated: '2020-02-17T19:33:13.568499Z',
18
createdAt: '2020-02-17T19:33:13.063733Z', versionId: '9'}
19
fullUrl: https://strestytests.edge.aidbox.app/Patient/pt-1
20
query-sql: ['SELECT "patient".* FROM "patient" LIMIT ? OFFSET ? ', 100, 0]
Copied!
Read more about stresty, predicates and regexps here.
Copy link