# Demonstrates dependencies between requests.

$ API_URL = https://lorem-api.com/api

---

Get JWT

POST {{ API_URL }}/jwt

~~~ application/json
{
  "username": "foo",
  "password": "[[ password ]]",
  "role": "admin"
}
~~~

& body.token -> $JWT_TOKEN

^ STATUS == 200
^ $JWT_TOKEN ~= /[A-Za-z0-9_.-]+/

! echo $JWT_TOKEN | cut -d '.' -f2 | base64 --decode  -> $JWT_PAYLOAD

^ $JWT_PAYLOAD ~= /"Username":\s*"foo"/ || "Username missing or incorrect"
^ $JWT_PAYLOAD ~= /"Role":\s*"admin"/ || "Role missing or incorrect"

---

Echo Response

> requires: Get JWT

POST {{ API_URL }}/echo

~~~ application/json
{ "foo" : "{{ JWT_TOKEN }}" }
~~~

^ & body.foo == $JWT_TOKEN