To do most tasks in TestEngine, you must authenticate yourself. This topic describes how you can do this.
Basic authentication
In basic authentication, you must provide your Base64-encoded login and password in the Authorization
header. For example:
Authorization: Basic dXNlcjpwYXNzd29yZA==
Example
ExampleExample
To apply the basic authentication, use the -u "<username>:<password>"
argument. For example, to get a list of test jobs, use the following command:
curl -u "user:password" -X GET "http://localhost:8080/api/v1/testjobs"
In ReadyAPI, you apply the basic authentication by using the Authorization panel:
-
Open the needed request and then open the Auth panel.
-
Select the Basic (Built-in) authorization type.
-
Specify user credentials and select the Authenticate pre-emptively option:
Click the image to enlarge it.
To learn more about applying the basic authorization in ReadyAPI, see Basic Authentication.
Access token
When you use an access token, you authenticate your requests with a token issued by TestEngine. This authentication is more secure since you do not provide your credentials with every request.
The access token does not have an expiration date. If you need to reset the token, revoke it manually.
To authorize requests with an access token:
-
Get an access token by using the following operation:
POST http:///api/v1/token
Authentication
The request must be authenticated by a TestEngine user. TestEngine will issue the access token for the authenticated user.
-
TestEngine responses with a JSON object containing the access token:
JSON
{
"token": "37YkM3l4KQijXxv320HD_n4G2Dc"
}
-
Specify the Authorized: Bearer <access token>
header to authenticate a request. See the examples below.
See details on SwaggerHub.
Example
ExampleExample
To authenticate requests by using an access token:
-
Request an access token by using the following command:
curl -u "user:password" -X POST "http://localhost:8080/api/v1/token"
In this example:
-u user:password
Authenticates the request using the user's credentials.
-X POST
Specifies the POST method.
"http://localhost:8080/api/v1/token"
The endpoint of the request.
The response will contain the issued access token.
-
Specify the Authorization
header with the access token. For example, to get a list of test jobs, use the following command:
curl -H "Authorization: Bearer 37YkM3l4KQijXxv320HD_n4G2Dc" -X GET "http://localhost:8080/api/v1/testjobs"
To authenticate requests by using an access token:
-
Get an access token:
Show steps
Show stepsHide
-
Create a project by using the TestEngine API definition. See Creating Project From OpenAPI/Swagger Definition to learn how to do it.
-
Select the POST request to the /api/v1/token resource:
Click the image to enlarge it.
-
Open the Auth panel.
-
Select the Basic (Built-in) authorization type.
-
Specify user credentials and select the Authenticate pre-emptively option:
Click the image to enlarge it.
-
Send the request:
Click the image to enlarge it.
-
If the operation was successful, the response will contain an access token:
-
Use the access token to send a request:
Show steps
Show stepsHide
-
Open the request you want to send. For example, the GET request to the /api/v1/testjobs resource:
Click the image to enlarge it.
-
Add the Authorization
parameter and set its type to HEADER.
-
Specify Bearer <access token>
for the parameter’s value:
Click the image to enlarge it.
-
Send the request:
Click the image to enlarge it.
Revoke an access token
Revoke a single access token
Use the following operation:
DELETE http:///api/v1/token/
Body
A JSON object containing a token to revoke:
Authentication
Basic authentication by a TestEngine user.
See details on SwaggerHub.
Example
ExampleExample
Use the following command line:
curl -u "user:password" -X DELETE -d "{\"token\":\"37YkM3l4KQijXxv320HD_n4G2Dc\"}" "http://localhost:8080/api/v1/token"
In this example:
-u user:password
Authenticates the request with the user’s credentials.
-X DELETE
Specifies the DELETE method.
-d "{\"token\":\"37YkM3l4KQijXxv320HD_n4G2Dc\"}"
A JSON string that specifies a new password.
"http://localhost:8080/api/v1/token"
The endpoint of the request.
-
Create a project by using the TestEngine API definition. See Creating Project From OpenAPI/Swagger Definition to learn how to do it.
-
Select the DELETE request to the /api/v1/token resource:
Click the image to enlarge it.
-
Enter the new password in a JSON body:
{
"password" : "string",
}
-
Open the Auth panel.
-
Select the Basic (Built-in) authorization type.
-
Specify user credentials and select the Authenticate pre-emptively option:
Click the image to enlarge it.
-
Send the request:
Click the image to enlarge it.
Revoke all your access tokens
Use the following operation:
DELETE http:///api/v1/tokens/
Authentication
Basic authentication by a TestEngine user.
See details on SwaggerHub.
Example
ExampleExample
Use the following command line:
curl -u "user:password" -X DELETE "http://localhost:8080/api/v1/token"
In this example:
-u user:password
Authenticates the request with the user’s credentials.
-X DELETE
Specifies the DELETE method.
"http://localhost:8080/api/v1/token"
The endpoint of the request.
-
Create a project by using the TestEngine API definition. See Creating Project From OpenAPI/Swagger Definition to learn how to do it.
-
Select the DELETE request to the /api/v1/tokens resource:
Click the image to enlarge it.
-
Open the Auth panel.
-
Select the Basic (Built-in) authorization type.
-
Specify user credentials and select the Authenticate pre-emptively option:
Click the image to enlarge it.
-
Send the request:
Click the image to enlarge it.
The address and port of your TestEngine installation.
The address and port of your TestEngine installation.
The address and port of your TestEngine installation.
See Also
Remove Jobs
Get Results
Run Tests