REST Plugin — Step Reference

Autogenerated from steps.yaml. Do not edit manually.


rest.auth.headers

Role: given

Sets headers that will be sent with every subsequent HTTP request in the scenario.

Additional data

A two-column table where each row specifies a header name and its value.

dsl

Expression: set HTTP persistent headers:

Example:

* set HTTP persistent headers:
  | X-Tenant-Id | acme |
  | X-Version   | 2    |

Scenarios:

Set persistent headers for all requests

* set HTTP persistent headers:
  | X-Tenant-Id | acme |
* do HTTP GET "users"
* assert HTTP status code = 200

en

Expression: the following headers are set for all subsequent requests:

Example:

Given the following headers are set for all subsequent requests:
  | X-Tenant-Id | acme |
  | X-Version   | 2    |

Scenarios:

Set custom headers for all requests in the scenario

Given the following headers are set for all subsequent requests:
  | X-Tenant-Id | acme |
  | X-Version   | 2    |
When I make a GET request to "users"
Then the HTTP status code is equal to 200
When I make a GET request to "users/1"
Then the HTTP status code is equal to 200

es

Expression: los siguientes headers se aplican a todas las peticiones posteriores:

Example:

Dado que los siguientes headers se aplican a todas las peticiones posteriores:
  | X-Tenant-Id | acme |
  | X-Version   | 2    |

Scenarios:

Establecer headers comunes para todas las peticiones del escenario

Dado que los siguientes headers se aplican a todas las peticiones posteriores:
  | X-Tenant-Id | acme |
  | X-Version   | 2    |
Cuando hago una petición GET a "users"
Entonces el código de estado HTTP es igual a 200
Cuando hago una petición GET a "users/1"
Entonces el código de estado HTTP es igual a 200

rest.auth.bearer

Role: given

Sets a Bearer token as the authorization for every subsequent HTTP request in the scenario.

Parameters

Name Type Description
token text The Bearer token value

dsl

Expression: set HTTP auth Bearer {token:text}

Example:

* set HTTP auth Bearer "mytoken"

Scenarios:

Authenticate with a Bearer token

* set HTTP auth Bearer "mytoken"
* do HTTP GET "secure/resource"
* assert HTTP status code = 200

en

Expression: the authorization is Bearer {token:text}

Example:

Given the authorization is Bearer "mytoken"

Scenarios:

Authenticate with a static Bearer token

Given the authorization is Bearer "mytoken"
When I make a GET request to "secure/resource"
Then the HTTP status code is equal to 200

Authenticate with a token stored in a variable

Given the authorization is Bearer "${accessToken}"
When I make a GET request to "secure/resource"
Then the HTTP status code is equal to 200

es

Expression: la autorización es Bearer {token:text}

Example:

Dado que la autorización es Bearer "mitoken"

Scenarios:

Autenticarse con un token Bearer estático

Dado que la autorización es Bearer "mitoken"
Cuando hago una petición GET a "secure/resource"
Entonces el código de estado HTTP es igual a 200

Autenticarse con un token almacenado en una variable

Dado que la autorización es Bearer "${accessToken}"
Cuando hago una petición GET a "secure/resource"
Entonces el código de estado HTTP es igual a 200

rest.auth.basic

Role: given

Sets HTTP Basic authentication credentials for every subsequent HTTP request in the scenario. The credentials are Base64-encoded and sent as an Authorization header.

Parameters

Name Type Description
username text The username
password text The password

dsl

Expression: set HTTP auth Basic {username:text} {password:text}

Example:

* set HTTP auth Basic "admin" "secret"

Scenarios:

Authenticate with Basic credentials

* set HTTP auth Basic "admin" "secret"
* do HTTP GET "admin/settings"
* assert HTTP status code = 200

en

Expression: the authorization is Basic with username {username:text} and password {password:text}

Example:

Given the authorization is Basic with username "admin" and password "secret"

Scenarios:

Authenticate with Basic credentials

Given the authorization is Basic with username "admin" and password "secret"
When I make a GET request to "admin/settings"
Then the HTTP status code is equal to 200

Authenticate using credentials from configuration variables

Given the authorization is Basic with username "${api.user}" and password "${api.password}"
When I make a POST request to "data" with body:
"""json
{"key": "value"}
"""
Then the HTTP status code is equal to 201

es

Expression: la autorización es Basic con usuario {username:text} y contraseña {password:text}

Example:

Dado que la autorización es Basic con usuario "admin" y contraseña "secret"

Scenarios:

Autenticarse con credenciales Basic

Dado que la autorización es Basic con usuario "admin" y contraseña "secret"
Cuando hago una petición GET a "admin/settings"
Entonces el código de estado HTTP es igual a 200

rest.auth.apikey.header

Role: given

Sets an API key that will be sent as a request header with every subsequent HTTP request in the scenario.

Parameters

Name Type Description
key text The API key value
name text The header name to use (e.g. X-API-Key)

dsl

Expression: set HTTP auth API key {key:text} in header {name:text}

Example:

* set HTTP auth API key "abc123" in header "X-API-Key"

Scenarios:

Authenticate with an API key header

* set HTTP auth API key "abc123" in header "X-API-Key"
* do HTTP GET "data"
* assert HTTP status code = 200

en

Expression: the API key {key:text} is sent in header {name:text}

Example:

Given the API key "abc123" is sent in header "X-API-Key"

Scenarios:

Authenticate with an API key in a custom header

Given the API key "abc123" is sent in header "X-API-Key"
When I make a GET request to "data"
Then the HTTP status code is equal to 200

Authenticate using an API key from a configuration variable

Given the API key "${api.key}" is sent in header "X-API-Key"
When I make a GET request to "data"
Then the HTTP status code is equal to 200

es

Expression: la API key {key:text} se envía en el header {name:text}

Example:

Dado que la API key "abc123" se envía en el header "X-API-Key"

Scenarios:

Autenticarse con una API key en un header personalizado

Dado que la API key "abc123" se envía en el header "X-API-Key"
Cuando hago una petición GET a "data"
Entonces el código de estado HTTP es igual a 200

rest.auth.apikey.query

Role: given

Sets an API key that will be appended as a query parameter to every subsequent HTTP request URL in the scenario.

Parameters

Name Type Description
key text The API key value
name text The query parameter name (e.g. api_key)

dsl

Expression: set HTTP auth API key {key:text} in query {name:text}

Example:

* set HTTP auth API key "abc123" in query "api_key"

Scenarios:

Authenticate with an API key query parameter

* set HTTP auth API key "abc123" in query "api_key"
* do HTTP GET "data"
* assert HTTP status code = 200

en

Expression: the API key {key:text} is sent as query parameter {name:text}

Example:

Given the API key "abc123" is sent as query parameter "api_key"

Scenarios:

Authenticate with an API key as a query parameter

Given the API key "abc123" is sent as query parameter "api_key"
When I make a GET request to "data"
Then the HTTP status code is equal to 200

Authenticate using an API key from a configuration variable

Given the API key "${api.key}" is sent as query parameter "api_key"
When I make a GET request to "data"
Then the HTTP status code is equal to 200

es

Expression: la API key {key:text} se envía como parámetro de query {name:text}

Example:

Dado que la API key "abc123" se envía como parámetro de query "api_key"

Scenarios:

Autenticarse con una API key como parámetro de query

Dado que la API key "abc123" se envía como parámetro de query "api_key"
Cuando hago una petición GET a "data"
Entonces el código de estado HTTP es igual a 200

rest.auth.oauth2.client_credentials

Role: given

Obtains an OAuth2 access token using the client credentials grant and stores it in a scenario variable. Credentials are sent via HTTP Basic Authentication (CLIENT_SECRET_BASIC, RFC 6749 §2.3.1). The token can then be used with the rest.auth.bearer step.

Parameters

Name Type Description
url text The token endpoint URL (always used as-is, regardless of rest.baseURL)
clientId text The OAuth2 client ID
clientSecret text The OAuth2 client secret
variable id The variable name where the access token will be stored

dsl

Expression: OAuth2 client credentials {url:text} client {clientId:text} secret {clientSecret:text} into {variable:id}

Example:

* OAuth2 client credentials "${auth.tokenUrl}" client "${auth.clientId}" secret "${auth.clientSecret}" into accessToken

Scenarios:

Obtain an OAuth2 token and access a protected resource

* OAuth2 client credentials "${auth.tokenUrl}" client "${auth.clientId}" secret "${auth.clientSecret}" into accessToken
* set HTTP auth Bearer "${accessToken}"
* do HTTP GET "secure/resource"
* assert HTTP status code = 200

en

Expression: I obtain an OAuth2 client credentials token from {url:text} with client {clientId:text} and secret {clientSecret:text} into variable {variable:id}

Example:

Given I obtain an OAuth2 client credentials token from "https://auth.example.com/token" with client "my-client" and secret "my-secret" into variable accessToken

Scenarios:

Obtain an OAuth2 token and use it to access a protected resource

Given I obtain an OAuth2 client credentials token from "${auth.tokenUrl}" with client "${auth.clientId}" and secret "${auth.clientSecret}" into variable accessToken
And the authorization is Bearer "${accessToken}"
When I make a GET request to "secure/resource"
Then the HTTP status code is equal to 200

Obtain a token and verify the protected resource response body

Given I obtain an OAuth2 client credentials token from "${auth.tokenUrl}" with client "${auth.clientId}" and secret "${auth.clientSecret}" into variable accessToken
And the authorization is Bearer "${accessToken}"
When I make a POST request to "orders" with body:
"""json
{"product": "widget", "qty": 5}
"""
Then the HTTP status code is equal to 201

es

Expression: obtengo un token OAuth2 de cliente de {url:text} con cliente {clientId:text} y secreto {clientSecret:text} en la variable {variable:id}

Example:

Dado que obtengo un token OAuth2 de cliente de "https://auth.example.com/token" con cliente "my-client" y secreto "my-secret" en la variable accessToken

Scenarios:

Obtener un token OAuth2 y usarlo para acceder a un recurso protegido

Dado que obtengo un token OAuth2 de cliente de "${auth.tokenUrl}" con cliente "${auth.clientId}" y secreto "${auth.clientSecret}" en la variable accessToken
Y la autorización es Bearer "${accessToken}"
Cuando hago una petición GET a "secure/resource"
Entonces el código de estado HTTP es igual a 200

rest.auth.oauth2.password

Role: given

Obtains an OAuth2 access token using the Resource Owner Password Credentials grant (ROPC) and stores it in a scenario variable. Useful for testing endpoints secured by user roles. Credentials are sent via HTTP Basic Authentication (CLIENT_SECRET_BASIC, RFC 6749 §2.3.1). The token can then be used with the rest.auth.bearer step.

Parameters

Name Type Description
url text The token endpoint URL (always used as-is, regardless of rest.baseURL)
clientId text The OAuth2 client ID
clientSecret text The OAuth2 client secret
username text The resource owner username
password text The resource owner password
variable id The variable name where the access token will be stored

dsl

Expression: OAuth2 password grant {url:text} client {clientId:text} secret {clientSecret:text} user {username:text} password {password:text} into {variable:id}

Example:

* OAuth2 password grant "${auth.tokenUrl}" client "${auth.clientId}" secret "${auth.clientSecret}" user "admin" password "admin123" into accessToken

Scenarios:

Obtain a user token and access a role-protected resource

* OAuth2 password grant "${auth.tokenUrl}" client "${auth.clientId}" secret "${auth.clientSecret}" user "${test.username}" password "${test.password}" into accessToken
* set HTTP auth Bearer "${accessToken}"
* do HTTP GET "admin/settings"
* assert HTTP status code = 200

en

Expression: I obtain an OAuth2 password grant token from {url:text} with client {clientId:text} and secret {clientSecret:text} as user {username:text} with password {password:text} into variable {variable:id}

Example:

Given I obtain an OAuth2 password grant token from "https://auth.example.com/token" with client "my-client" and secret "my-secret" as user "admin" with password "admin123" into variable accessToken

Scenarios:

Obtain a user token and use it to access a role-protected resource

Given I obtain an OAuth2 password grant token from "${auth.tokenUrl}" with client "${auth.clientId}" and secret "${auth.clientSecret}" as user "${test.username}" with password "${test.password}" into variable accessToken
And the authorization is Bearer "${accessToken}"
When I make a GET request to "admin/settings"
Then the HTTP status code is equal to 200

es

Expression: obtengo un token OAuth2 de contraseña de {url:text} con cliente {clientId:text} y secreto {clientSecret:text} como usuario {username:text} con contraseña {password:text} en la variable {variable:id}

Example:

Dado que obtengo un token OAuth2 de contraseña de "https://auth.example.com/token" con cliente "my-client" y secreto "my-secret" como usuario "admin" con contraseña "admin123" en la variable accessToken

Scenarios:

Obtener un token de usuario y usarlo para acceder a un recurso protegido por rol

Dado que obtengo un token OAuth2 de contraseña de "${auth.tokenUrl}" con cliente "${auth.clientId}" y secreto "${auth.clientSecret}" como usuario "${test.username}" con contraseña "${test.password}" en la variable accessToken
Y la autorización es Bearer "${accessToken}"
Cuando hago una petición GET a "admin/settings"
Entonces el código de estado HTTP es igual a 200

rest.request.headers

Role: given

Sets headers to be sent with the next HTTP request only.

Additional data

A two-column table where each row specifies a header name and its value.

dsl

Expression: set HTTP request headers:

Example:

* set HTTP request headers:
  | Authorization | Bearer mytoken |

Scenarios:

Send custom headers with a request

* set HTTP request headers:
  | Authorization | Bearer ${token} |
* do HTTP GET "secure/resource"
* assert HTTP status code = 200

en

Expression: the next request has the headers:

Example:

Given the next request has the headers:
  | Authorization | Bearer mytoken |
  | X-Tenant-Id   | acme           |

Scenarios:

Send an authorization header with a GET request

Given the next request has the headers:
  | Authorization | Bearer ${token} |
When I make a GET request to "secure/resource"
Then the HTTP status code is equal to 200

es

Expression: la próxima petición tiene los headers:

Example:

Dado que la próxima petición tiene los headers:
  | Authorization | Bearer mitoken |
  | X-Tenant-Id   | acme           |

Scenarios:

Enviar un header de autorización con una petición GET

Dado que la próxima petición tiene los headers:
  | Authorization | Bearer ${token} |
Cuando hago una petición GET a "secure/resource"
Entonces el código de estado HTTP es igual a 200

rest.request.GET

Role: when

Makes a GET request to the specified URL.

Parameters

Name Type Description
endpoint text The URL to which the GET request is made

dsl

Expression: do HTTP GET {endpoint:text}

Example:

* do HTTP GET "users"

Scenarios:

Retrieve a collection of resources

* do HTTP GET "users"
* assert HTTP status code = 200
* assert HTTP response body:
  """json
  [{"id": 1, "name": "Alice"}]
  """

Retrieve a single resource by ID

* do HTTP GET "users/1"
* assert HTTP status code = 200

Request a non-existent resource

* do HTTP GET "users/9999"
* assert HTTP status code = 404

en

Expression: I make a GET request to {endpoint:text}

Example:

When I make a GET request to "users"

Scenarios:

Retrieve a collection of resources

When I make a GET request to "users"
Then the HTTP status code is equal to 200
And the response body contains:
"""json
[{"id": 1, "name": "Alice"}]
"""

Retrieve a single resource by ID

When I make a GET request to "users/1"
Then the HTTP status code is equal to 200

Request a non-existent resource

When I make a GET request to "users/9999"
Then the HTTP status code is equal to 404

es

Expression: hago una petición GET a {endpoint:text}

Example:

Cuando hago una petición GET a "users"

Scenarios:

Obtener una colección de recursos

Cuando hago una petición GET a "users"
Entonces el código de estado HTTP es igual a 200
Y el cuerpo de la respuesta contiene:
"""json
[{"id": 1, "name": "Alice"}]
"""

Obtener un recurso por ID

Cuando hago una petición GET a "users/1"
Entonces el código de estado HTTP es igual a 200

rest.request.POST.empty

Role: when

Makes a POST request to the specified URL with an empty body.

Parameters

Name Type Description
endpoint text The URL to which the POST request is made

dsl

Expression: do HTTP POST {endpoint:text}

Example:

* do HTTP POST "sessions/logout"

Scenarios:

Trigger an action with no payload

* do HTTP POST "sessions/logout"
* assert HTTP status code = 204

en

Expression: I make a POST request to {endpoint:text}

Example:

When I make a POST request to "users"

Scenarios:

Trigger an action with no payload

When I make a POST request to "sessions/logout"
Then the HTTP status code is equal to 204

es

Expression: hago una petición POST a {endpoint:text}

Example:

Cuando hago una petición POST a "users"

Scenarios:

Disparar una acción sin cuerpo

Cuando hago una petición POST a "sessions/logout"
Entonces el código de estado HTTP es igual a 204

rest.request.POST.body

Role: when

Makes a POST request to the specified URL with the given body.

Parameters

Name Type Description
endpoint text The URL to which the POST request is made

Additional data

The body of the POST request, provided as a multi-line text input.

dsl

Expression: do HTTP POST {endpoint:text}:

Example:

* do HTTP POST "users":
"""json
{"name": "John", "age": 30}
"""

Scenarios:

Create a new resource successfully

* do HTTP POST "users":
"""json
{"name": "John", "age": 30}
"""
* HTTP status code = 201

Reject a request with invalid data

* do HTTP POST "users" body:
"""json
{"name": ""}
"""
* assert HTTP status code = 400

en

Expression: I make a POST request to {endpoint:text} with body:

Example:

When I make a POST request to "users" with body:
"""json
{
  "name": "John",
  "age": 30
}
"""

Scenarios:

Create a new resource successfully

When I make a POST request to "users" with body:
"""json
{"name": "John", "age": 30}
"""
Then the HTTP status code is equal to 201
And the response body contains:
"""json
{"name": "John"}
"""

Reject a request with invalid data

When I make a POST request to "users" with body:
"""json
{"name": ""}
"""
Then the HTTP status code is equal to 400

es

Expression: hago una petición POST a {endpoint:text} con el cuerpo:

Example:

Cuando hago una petición POST a "users" con el cuerpo:
"""json
{
  "name": "John",
  "age": 30
}
"""

Scenarios:

Crear un recurso correctamente

Cuando hago una petición POST a "users" con el cuerpo:
"""json
{"name": "John", "age": 30}
"""
Entonces el código de estado HTTP es igual a 201

Rechazar una petición con datos inválidos

Cuando hago una petición POST a "users" con el cuerpo:
"""json
{"name": ""}
"""
Entonces el código de estado HTTP es igual a 400

rest.request.POST.urlencoded

Role: when

Makes a POST request to the specified URL with an application/x-www-form-urlencoded body built from the given key-value table. Values are URL-encoded automatically.

Parameters

Name Type Description
endpoint text The URL to which the POST request is made

Additional data

A two-column table where each row is a form field name and its value.

dsl

Expression: do HTTP POST {endpoint:text} urlencoded:

Example:

* do HTTP POST "login" urlencoded:
  | username | alice  |
  | password | s3cr3t |

Scenarios:

Submit a login form with URL-encoded body

* do HTTP POST "login" urlencoded:
  | username | alice  |
  | password | s3cr3t |
* assert HTTP status code = 200

en

Expression: I make a POST request to {endpoint:text} with URL-encoded form:

Example:

When I make a POST request to "login" with URL-encoded form:
  | username | alice |
  | password | s3cr3t |

Scenarios:

Submit a login form

When I make a POST request to "login" with URL-encoded form:
  | username | alice  |
  | password | s3cr3t |
Then the HTTP status code is equal to 200

es

Expression: hago una petición POST a {endpoint:text} con formulario URL-encoded:

Example:

Cuando hago una petición POST a "login" con formulario URL-encoded:
  | username | alice |
  | password | s3cr3t |

Scenarios:

Enviar un formulario de login

Cuando hago una petición POST a "login" con formulario URL-encoded:
  | username | alice  |
  | password | s3cr3t |
Entonces el código de estado HTTP es igual a 200

rest.request.POST.multipart

Role: when

Makes a POST request to the specified URL with a multipart/form-data body built from the given key-value table. Each row becomes a separate form part.

Parameters

Name Type Description
endpoint text The URL to which the POST request is made

Additional data

A two-column table where each row is a form field name and its value.

dsl

Expression: do HTTP POST {endpoint:text} multipart:

Example:

* do HTTP POST "upload" multipart:
  | name  | Alice             |
  | email | alice@example.com |

Scenarios:

Submit a multipart form

* do HTTP POST "upload" multipart:
  | name  | Alice             |
  | email | alice@example.com |
* assert HTTP status code = 200

en

Expression: I make a POST request to {endpoint:text} with multipart form:

Example:

When I make a POST request to "upload" with multipart form:
  | name  | Alice |
  | email | alice@example.com |

Scenarios:

Submit a multipart form

When I make a POST request to "upload" with multipart form:
  | name  | Alice             |
  | email | alice@example.com |
Then the HTTP status code is equal to 200

es

Expression: hago una petición POST a {endpoint:text} con formulario multipart:

Example:

Cuando hago una petición POST a "upload" con formulario multipart:
  | name  | Alice |
  | email | alice@example.com |

Scenarios:

Enviar un formulario multipart

Cuando hago una petición POST a "upload" con formulario multipart:
  | name  | Alice             |
  | email | alice@example.com |
Entonces el código de estado HTTP es igual a 200

rest.request.POST.file

Role: when

Makes a POST request to the specified URL with the given body read from a file.

Parameters

Name Type Description
endpoint text The URL to which the POST request is made
file text The path to the file containing the body of the POST request

dsl

Expression: do HTTP POST {endpoint:text} using {file:text}

Example:

* do HTTP POST "users" using "user_data.json"

Scenarios:

Create a resource using a body from file

* do HTTP POST "users" using "fixtures/new_user.json"
* assert HTTP status code = 201

en

Expression: I make a POST request to {endpoint:text} with body from file {file:text}

Example:

When I make a POST request to "users" with body from file "user_data.json"

Scenarios:

Create a resource using a body from file

When I make a POST request to "users" with body from file "fixtures/new_user.json"
Then the HTTP status code is equal to 201

es

Expression: hago una petición POST a {endpoint:text} con el cuerpo del archivo {file:text}

Example:

Cuando hago una petición POST a "users" con el cuerpo del archivo "user_data.json"

Scenarios:

Crear un recurso usando un cuerpo desde archivo

Cuando hago una petición POST a "users" con el cuerpo del archivo "fixtures/new_user.json"
Entonces el código de estado HTTP es igual a 201

rest.request.PUT.body

Role: when

Makes a PUT request to the specified URL with the given body.

Parameters

Name Type Description
endpoint text The URL to which the PUT request is made

Additional data

The body of the PUT request, provided as a multi-line text input.

dsl

Expression: do HTTP PUT {endpoint:text}:

Example:

* do HTTP PUT "users/123":
"""json
{"name": "John", "age": 31}
"""

Scenarios:

Replace a resource completely

* do HTTP PUT "users/1":
"""json
{"name": "John Updated", "age": 31}
"""
* assert HTTP status code = 200

Replace a non-existent resource

* do HTTP PUT "users/9999":
"""json
{"name": "Ghost"}
"""
* assert HTTP status code = 404

en

Expression: I make a PUT request to {endpoint:text} with body:

Example:

When I make a PUT request to "users/123" with body:
"""json
{
  "name": "John",
  "age": 31
}
"""

Scenarios:

Replace a resource completely

When I make a PUT request to "users/1" with body:
"""json
{"name": "John Updated", "age": 31}
"""
Then the HTTP status code is equal to 200
And the response body contains:
"""json
{"name": "John Updated"}
"""

Replace a non-existent resource

When I make a PUT request to "users/9999" with body:
"""json
{"name": "Ghost"}
"""
Then the HTTP status code is equal to 404

es

Expression: hago una petición PUT a {endpoint:text} con el cuerpo:

Example:

Cuando hago una petición PUT a "users/123" con el cuerpo:
"""json
{
  "name": "John",
  "age": 31
}
"""

Scenarios:

Reemplazar un recurso completamente

Cuando hago una petición PUT a "users/1" con el cuerpo:
"""json
{"name": "John Actualizado", "age": 31}
"""
Entonces el código de estado HTTP es igual a 200

rest.request.PUT.file

Role: when

Makes a PUT request to the specified URL with the given body read from a file.

Parameters

Name Type Description
endpoint text The URL to which the PUT request is made
file text The path to the file containing the body of the PUT request

dsl

Expression: do HTTP PUT {endpoint:text} using {file:text}

Example:

* do HTTP PUT "users/123" using "updated_user_data.json"

Scenarios:

Replace a resource using a body from file

* do HTTP PUT "users/1" using "fixtures/updated_user.json"
* assert HTTP status code = 200

en

Expression: I make a PUT request to {endpoint:text} with body from file {file:text}

Example:

When I make a PUT request to "users/123" with body from file "updated_user_data.json"

Scenarios:

Replace a resource using a body from file

When I make a PUT request to "users/1" with body from file "fixtures/updated_user.json"
Then the HTTP status code is equal to 200

es

Expression: hago una petición PUT a {endpoint:text} con el cuerpo del archivo {file:text}

Example:

Cuando hago una petición PUT a "users/123" con el cuerpo del archivo "updated_user_data.json"

Scenarios:

Reemplazar un recurso usando un cuerpo desde archivo

Cuando hago una petición PUT a "users/1" con el cuerpo del archivo "fixtures/updated_user.json"
Entonces el código de estado HTTP es igual a 200

rest.request.PATCH.body

Role: when

Makes a PATCH request to the specified URL with the given body.

Parameters

Name Type Description
endpoint text The URL to which the PATCH request is made

Additional data

The body of the PATCH request, provided as a multi-line text input.

dsl

Expression: do HTTP PATCH {endpoint:text}:

Example:

* do HTTP PATCH "users/123":
"""json
{"age": 32}
"""

Scenarios:

Partially update a resource

* do HTTP PATCH "users/1":
"""json
{"age": 32}
"""
* assert HTTP status code = 200

en

Expression: I make a PATCH request to {endpoint:text} with body:

Example:

When I make a PATCH request to "users/123" with body:
"""json
{
  "age": 32
}
"""

Scenarios:

Partially update a resource

When I make a PATCH request to "users/1" with body:
"""json
{"age": 32}
"""
Then the HTTP status code is equal to 200
And the response body contains:
"""json
{"id": 1, "age": 32}
"""

es

Expression: hago una petición PATCH a {endpoint:text} con el cuerpo:

Example:

Cuando hago una petición PATCH a "users/123" con el cuerpo:
"""json
{
  "age": 32
}
"""

Scenarios:

Actualizar parcialmente un recurso

Cuando hago una petición PATCH a "users/1" con el cuerpo:
"""json
{"age": 32}
"""
Entonces el código de estado HTTP es igual a 200

rest.request.PATCH.file

Role: when

Makes a PATCH request to the specified URL with the given body read from a file.

Parameters

Name Type Description
endpoint text The URL to which the PATCH request is made
file text The path to the file containing the body of the PATCH request

dsl

Expression: do HTTP PATCH {endpoint:text} using {file:text}

Example:

* do HTTP PATCH "users/123" using "partial_user_update.json"

Scenarios:

Partially update a resource using a body from file

* do HTTP PATCH "users/1" using "fixtures/partial_update.json"
* assert HTTP status code = 200

en

Expression: I make a PATCH request to {endpoint:text} with body from file {file:text}

Example:

When I make a PATCH request to "users/123" with body from file "partial_user_update.json"

Scenarios:

Partially update a resource using a body from file

When I make a PATCH request to "users/1" with body from file "fixtures/partial_update.json"
Then the HTTP status code is equal to 200

es

Expression: hago una petición PATCH a {endpoint:text} con el cuerpo del archivo {file:text}

Example:

Cuando hago una petición PATCH a "users/123" con el cuerpo del archivo "partial_user_update.yaml"

Scenarios:

Actualizar parcialmente un recurso desde archivo

Cuando hago una petición PATCH a "users/1" con el cuerpo del archivo "fixtures/partial_update.json"
Entonces el código de estado HTTP es igual a 200

rest.request.DELETE

Role: when

Makes a DELETE request to the specified URL.

Parameters

Name Type Description
endpoint text The URL to which the DELETE request is made

dsl

Expression: do HTTP DELETE {endpoint:text}

Example:

* do HTTP DELETE "users/123"

Scenarios:

Delete an existing resource

* do HTTP DELETE "users/1"
* assert HTTP status code = 204

Delete a non-existent resource

* do HTTP DELETE "users/9999"
* assert HTTP status code = 404

en

Expression: I make a DELETE request to {endpoint:text}

Example:

When I make a DELETE request to "users/123"

Scenarios:

Delete an existing resource

When I make a DELETE request to "users/1"
Then the HTTP status code is equal to 204

Delete a non-existent resource

When I make a DELETE request to "users/9999"
Then the HTTP status code is equal to 404

es

Expression: hago una petición DELETE a {endpoint:text}

Example:

Cuando hago una petición DELETE a "users/123"

Scenarios:

Eliminar un recurso existente

Cuando hago una petición DELETE a "users/1"
Entonces el código de estado HTTP es igual a 204

Eliminar un recurso inexistente

Cuando hago una petición DELETE a "users/9999"
Entonces el código de estado HTTP es igual a 404

rest.response.statusCode

Role: then

Asserts that the status code of the last REST response matches the expected value.

dsl

Expression: assert HTTP status code {{integer-assertion}}

Assertion expressions:

Example:

* assert HTTP status code = 200

Scenarios:

Verify a successful GET response

* do HTTP GET "users"
* assert HTTP status code = 200

Verify a resource was created

* do HTTP POST "users":
"""json
{"name": "Alice"}
"""
* assert HTTP status code = 201

Verify a successful deletion

* do HTTP DELETE "users/1"
* assert HTTP status code = 204

Verify an error response

* do HTTP GET "users/9999"
* assert HTTP status code = 404

en

Expression: the HTTP status code {{integer-assertion}}

Assertion expressions:

Example:

Then the HTTP status code is equal to 200

Scenarios:

Verify a successful GET response

When I make a GET request to "users"
Then the HTTP status code is equal to 200

Verify a resource was created

When I make a POST request to "users" with body:
"""json
{"name": "Alice"}
"""
Then the HTTP status code is equal to 201

Verify a successful deletion

When I make a DELETE request to "users/1"
Then the HTTP status code is equal to 204

Verify an error response

When I make a GET request to "users/9999"
Then the HTTP status code is equal to 404

es

Expression: el código de estado HTTP {{integer-assertion}}

Assertion expressions:

Example:

Entonces el código de estado HTTP es igual a 200

Scenarios:

Verificar una respuesta exitosa

Cuando hago una petición GET a "users"
Entonces el código de estado HTTP es igual a 200

rest.response.body

Role: then

Asserts that the body of the last REST response matches exactly the expected value.

Additional data

The expected body of the response, provided as a multi-line text input.

dsl

Expression: assert HTTP response body:

Example:

* assert HTTP response body:
"""json
{"id": 123, "name": "John", "age": 30}
"""

Scenarios:

Verify exact response body after a GET

* do HTTP GET "users/1"
* assert HTTP status code = 200
* assert HTTP response body:
"""json
{"id": 1, "name": "Alice", "age": 25}
"""

Verify exact response body after a POST

* do HTTP POST "users":
"""json
{"name": "Bob", "age": 22}
"""
* assert HTTP status code = 201
* assert HTTP response body:
"""json
{"id": 2, "name": "Bob", "age": 22}
"""

en

Expression: the response body is:

Example:

Then the response body is:
"""json
{
  "id": 123,
  "name": "John",
  "age": 30
}
"""

Scenarios:

Verify exact response body after a GET

When I make a GET request to "users/1"
Then the HTTP status code is equal to 200
And the response body is:
"""json
{"id": 1, "name": "Alice", "age": 25}
"""

Verify exact response body after a POST

When I make a POST request to "users" with body:
"""json
{"name": "Bob", "age": 22}
"""
Then the HTTP status code is equal to 201
And the response body is:
"""json
{"id": 2, "name": "Bob", "age": 22}
"""

es

Expression: el cuerpo de la respuesta es:

Example:

Entonces el cuerpo de la respuesta es:
"""json
{
  "id": 123,
  "name": "John",
  "age": 30
}
"""

Scenarios:

Verificar el cuerpo exacto tras un GET

Cuando hago una petición GET a "users/1"
Entonces el código de estado HTTP es igual a 200
Y el cuerpo de la respuesta es:
"""json
{"id": 1, "name": "Alice", "age": 25}
"""

rest.response.body.file

Role: then

Asserts that the body of the last REST response matches exactly the expected value read from a file.

Parameters

Name Type Description
file text The path to the file containing the expected body of the response

dsl

Expression: assert HTTP response body using {file:text}

Example:

* assert HTTP response body using "expected_response.json"

Scenarios:

Verify response body matches a reference file

* do HTTP GET "users/1"
* assert HTTP status code = 200
* assert HTTP response body using "fixtures/expected_user.json"

en

Expression: the response body is the content of file {file:text}

Example:

Then the response body is the content of file "expected_response.json"

Scenarios:

Verify response body matches a reference file

When I make a GET request to "users/1"
Then the HTTP status code is equal to 200
And the response body is the content of file "fixtures/expected_user.json"

es

Expression: el cuerpo de la respuesta es el contenido del archivo {file:text}

Example:

Entonces el cuerpo de la respuesta es el contenido del archivo "expected_response.json"

Scenarios:

Verificar que el cuerpo coincide con un archivo de referencia

Cuando hago una petición GET a "users/1"
Entonces el código de estado HTTP es igual a 200
Y el cuerpo de la respuesta es el contenido del archivo "fixtures/expected_user.json"

rest.response.body.contains

Role: then

Asserts that the body of the last REST response contains the expected value.

Additional data

The expected content that should be present in the response body, provided as a multi-line text input.

dsl

Expression: assert HTTP response body \(loose\):

Example:

* assert HTTP response body (loose):
"""json
{"id": 123, "name": "John"}
"""

Scenarios:

Verify a field is present in the response after a GET

* do HTTP GET "users/1"
* assert HTTP status code = 200
* assert HTTP response body (loose):
"""json
{"name": "Alice"}
"""

Verify a new resource appears in a collection

* do HTTP POST "users" body:
"""json
{"name": "Carol"}
"""
* assert HTTP status code = 201
* assert HTTP response body (loose):
"""json
{"name": "Carol"}
"""

en

Expression: the response body contains:

Example:

Then the response body contains:
"""json
{
  "id": 123,
  "name": "John"
}
"""

Scenarios:

Verify a field is present in the response after a GET

When I make a GET request to "users/1"
Then the HTTP status code is equal to 200
And the response body contains:
"""json
{"name": "Alice"}
"""

Verify a new resource appears in a collection

When I make a POST request to "users" with body:
"""json
{"name": "Carol"}
"""
Then the HTTP status code is equal to 201
And the response body contains:
"""json
{"name": "Carol"}
"""

es

Expression: el cuerpo de la respuesta contiene:

Example:

Entonces el cuerpo de la respuesta contiene:
"""json
{
  "id": 123,
  "name": "John"
}
"""

Scenarios:

Verificar que un campo está presente en la respuesta

Cuando hago una petición GET a "users/1"
Entonces el código de estado HTTP es igual a 200
Y el cuerpo de la respuesta contiene:
"""json
{"name": "Alice"}
"""

rest.response.headers

Role: then

Asserts that the last REST response includes the specified headers with the given values. Additional response headers not listed in the table are accepted.

Additional data

A two-column table where each row specifies an expected header name and its expected value.

dsl

Expression: assert HTTP response headers include:

Example:

* assert HTTP response headers include:
  | Content-Type    | application/json |
  | X-Custom-Header | my-value         |

Scenarios:

Verify expected headers are present in the response

* do HTTP GET "users"
* assert HTTP status code = 200
* assert HTTP response headers include:
  | Content-Type | application/json |

en

Expression: the response headers include:

Example:

Then the response headers include:
  | Content-Type    | application/json |
  | X-Custom-Header | my-value         |

Scenarios:

Verify expected headers are present in the response

When I make a GET request to "users"
Then the HTTP status code is equal to 200
And the response headers include:
  | Content-Type | application/json |

es

Expression: la respuesta incluye los headers:

Example:

Entonces la respuesta incluye los headers:
  | Content-Type    | application/json |
  | X-Custom-Header | mi-valor         |

Scenarios:

Verificar que los headers esperados están presentes en la respuesta

Cuando hago una petición GET a "users"
Entonces el código de estado HTTP es igual a 200
Y la respuesta incluye los headers:
  | Content-Type | application/json |

rest.response.cookies

Role: then

Asserts that the last REST response sets the specified cookies with the given values. Each row names a cookie and its expected value. Only the cookie value is checked; attributes such as Path, Domain, HttpOnly or Secure are ignored. Additional cookies not listed in the table are accepted.

Additional data

A two-column table where each row specifies an expected cookie name and its expected value.

dsl

Expression: assert HTTP cookies include:

Example:

* assert HTTP cookies include:
  | session_id | abc123 |

Scenarios:

Verify cookies after login

* do HTTP POST "login" urlencoded:
  | username | alice  |
  | password | s3cr3t |
* assert HTTP status code = 200
* assert HTTP cookies include:
  | session_id | abc123 |

en

Expression: the response sets the cookies:

Example:

Then the response sets the cookies:
  | session_id | abc123 |
  | theme      | dark   |

Scenarios:

Verify cookies set after a successful login

When I make a POST request to "login" with URL-encoded form:
  | username | alice  |
  | password | s3cr3t |
Then the HTTP status code is equal to 200
And the response sets the cookies:
  | session_id | abc123 |

es

Expression: la respuesta establece las cookies:

Example:

Entonces la respuesta establece las cookies:
  | session_id | abc123 |
  | theme      | dark   |

Scenarios:

Verificar cookies establecidas tras un login exitoso

Cuando hago una petición POST a "login" con formulario URL-encoded:
  | username | alice  |
  | password | s3cr3t |
Entonces el código de estado HTTP es igual a 200
Y la respuesta establece las cookies:
  | session_id | abc123 |

rest.response.extracts.field

Role: then

Stores the value of a field from the response body into a variable for later use in the test scenario.

Parameters

Name Type Description
field text The path of the field in the response body whose value should be stored
variable id The name of the variable where the value will be stored

dsl

Expression: var {variable:id} = {field:text} from HTTP response

Example:

* var userId = 'id' from HTTP response

Scenarios:

Store a field and use it in a subsequent request

* do HTTP POST "users":
"""json
{"name": "Carol"}
"""
* var newUserId = 'id' from HTTP response
* do HTTP GET "users/${newUserId}"
* assert HTTP status code = 200

Store an existing resource ID for reuse

* do HTTP GET "users/1"
* assert HTTP status code = 200
* var existingUserId = 'id' from HTTP response
* do HTTP GET "users/${existingUserId}"
* assert HTTP status code = 200

en

Expression: I store the value of field {field:text} from the response body into variable {variable:id}

Example:

Then I store the value of field "id" from the response body into variable userId

Scenarios:

Store a field and use it in a subsequent request

When I make a POST request to "users" with body:
"""json
{"name": "Carol"}
"""
Then I store the value of field "id" from the response body into variable newUserId
And I make a GET request to "users/${newUserId}"
Then the HTTP status code is equal to 200

Use a stored variable in a subsequent request

When I make a GET request to "users/1"
Then the HTTP status code is equal to 200
And I store the value of field "id" from the response body into variable existingUserId
And I make a GET request to "users/${existingUserId}"
Then the HTTP status code is equal to 200

es

Expression: almaceno el valor del campo {field:text} del cuerpo de la respuesta en la variable {variable:id}

Example:

Entonces almaceno el valor del campo "id" del cuerpo de la respuesta en la variable userId

Scenarios:

Almacenar un campo y usarlo en la siguiente petición

Cuando hago una petición POST a "users" con el cuerpo:
"""json
{"name": "Carol"}
"""
Entonces almaceno el valor del campo "id" del cuerpo de la respuesta en la variable newUserId
Y hago una petición GET a "users/${newUserId}"
Entonces el código de estado HTTP es igual a 200

Usar una variable almacenada en una petición posterior

Cuando hago una petición GET a "users/1"
Entonces el código de estado HTTP es igual a 200
Y almaceno el valor del campo "id" del cuerpo de la respuesta en la variable existingUserId
Y hago una petición GET a "users/${existingUserId}"
Entonces el código de estado HTTP es igual a 200

rest.response.extracts.header

Role: then

Stores the value of a response header into a variable for later use in the test scenario. Fails if the header is not present in the response.

Parameters

Name Type Description
header text The name of the response header whose value should be stored
variable id The name of the variable where the header value will be stored

dsl

Expression: var {variable:id} = header {header:text} from HTTP response

Example:

* var requestId = header 'X-Request-Id' from HTTP response

Scenarios:

Store a response header and use it in a subsequent request

* do HTTP POST "orders":
"""json
{"product": "widget"}
"""
* var orderId = header 'X-Order-Id' from HTTP response
* do HTTP GET "orders/${orderId}"
* assert HTTP status code = 200

en

Expression: I store the value of response header {header:text} into variable {variable:id}

Example:

Then I store the value of response header "X-Request-Id" into variable requestId

Scenarios:

Store a response header and use it in a subsequent request

When I make a POST request to "orders" with body:
"""json
{"product": "widget"}
"""
Then I store the value of response header "X-Order-Id" into variable orderId
When I make a GET request to "orders/${orderId}"
Then the HTTP status code is equal to 200

Store a correlation ID returned by the server

When I make a GET request to "users"
Then I store the value of response header "X-Correlation-Id" into variable correlationId
And the HTTP status code is equal to 200

es

Expression: almaceno el valor del header de respuesta {header:text} en la variable {variable:id}

Example:

Entonces almaceno el valor del header de respuesta "X-Request-Id" en la variable requestId

Scenarios:

Almacenar un header de respuesta y usarlo en una petición posterior

Cuando hago una petición POST a "orders" con el cuerpo:
"""json
{"product": "widget"}
"""
Entonces almaceno el valor del header de respuesta "X-Order-Id" en la variable orderId
Cuando hago una petición GET a "orders/${orderId}"
Entonces el código de estado HTTP es igual a 200