API¶
Authentication¶
- Authentication in the API REST can be done with 2 methods:
- By using the function login to obtain a session cookie
- with basic auth
Basic¶
The basic auth must be used with the api key available through the web interface.
It’s possible to generate a new key in the server, to do that you can use the script /opt/xtc/current/Scripts/generate-apikey.py
.
./generate-apikey.py --user=admin
API Key ID: admin
API Key Secret: c025e7a501f144a2e1b40f9f3a91c10a47c8b1d3
API Key: YWRtaW46YzAyNWU3YTUwMWYxNDRhMmUxYjQwZjlmM2E5MWMxMGE0N2M4YjFkMw==
After that, add the header Authorization
in your HTTP request.
Authorization: Basic <my_api_key>
Note
With the basic auth, it’s not necessary to call the login function.
Session cookie¶
The authentication by cookie can be done by calling the function login
to generate a cookie for the session.
This cookie must be present on all next http request in the header Cookie
.
Cookie: session_id=NjQyOTVmOWNlMDgyNGQ2MjlkNzAzNDdjNTQ3ODU5MmU5M
Usage example¶
The REST api is available throught the tcp port 443
(https) with the uri /rest
.
The following example show how to execute a test with the basic auth.
POST /rest/tests/schedule HTTP/1.1
[...]
Authorization: Basic YWRtaW46N2UwMDExY2I3Y2ZhMGQ1MjM4NGQ1YWYyM2QyODBiMjUyM2EzMTA3ZA==
Content-Type: application/json; charset=utf-8
[...]
{
"project-id": 1,
"test-extension": "tux",
"test-name": "01_Wait",
"test-path": "/Snippets/Do/",
"test-inputs": [ {"name": "DURATION", "type": "int", "value": 5} ]
}
Received response:
{
"cmd": "/tests/schedule",
"message": "background"
"test-id": "a3f19398-b463-41e8-9e43-af86aac44a59",
"task-id": 17,
"tab-id": 0
"test-name": "01_Wait"
}
Ressources¶
Description of most important functions:
Authentication
/rest/session/login | Details |
/rest/session/logout | Details |
Execute a test
/rest/tests/schedule | Details |
/rest/tests/schedule/tpg | Details |
Read the result of a test executed
/rest/results/reports | Details |
/rest/results/status | Details |
/rest/results/verdict | Details |