Configure Your Box
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 .
Copy POST /Client
id : basic
secret : secret
grant_types : [ 'basic' ]
Create an access policy for your client:
Copy 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 :
Copy 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 .
Copy 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.
Copy export AIDBOX_URL = http:// < your_box_name > .aidbox.app
2
Copy export AIDBOX_AUTH_TYPE=Basic
3
Copy export AIDBOX_CLIENT_ID=basic
4
Copy export AIDBOX_CLIENT_SECRET=secret
5
Now you are ready to run the test script with stresty:
Copy java -jar stresty.jar test.yaml
The output will be the following:
Copy $ 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:
Request Response
Execute in the box REST Console:
Copy GET /Patient
Copy query-time: 20
meta: {versionId: '10'}
type: searchset
resourceType: Bundle
total: 1
link:
- {relation: first, url: '/Patient?page=1'}
- {relation: self, url: '/Patient?page=1'}
query-timeout: 60000
entry:
- resource:
name:
- given: [Petr]
family: Pupkin
id: pt-1
resourceType: Patient
meta: {lastUpdated: '2020-02-17T19:33:13.568499Z',
createdAt: '2020-02-17T19:33:13.063733Z', versionId: '9'}
fullUrl: https://strestytests.edge.aidbox.app/Patient/pt-1
query-sql: ['SELECT "patient".* FROM "patient" LIMIT ? OFFSET ? ', 100, 0]
Read more about stresty, predicates and regexps here .
Last updated 3 months ago