# Testing collection for lorem-api.com
$ REST_ORIGIN = https://lorem-api.com/api
$ GQL_ORIGIN = https://lorem-api.com/api/graphql
---
Echo a request
POST {{ REST_ORIGIN }}/echo
~~~ application/json
{ "username" : "test", "boolean": true, "number": 123 }
~~~
# Echo request succeeds
^ & status == 200
# Echoes the username
^ & body.username == "test"
# Echoes the boolean
^ & body.boolean == true
# Echoes the number
^ & body.number == 123
---
Get Lorem text
GET {{ REST_ORIGIN }}/lorem
? paragraphs=1
? seed = 1234
# Lorem request succeeds
^ & status == 200
# Returns non-empty lorem text
^ & body ~= /[A-Za-z0-9_.-]+/
---
Get a JSON Article (REST)
GET {{ REST_ORIGIN }}/article/foo
? format = json
# JSON article request succeeds
^ & status == 200
# Returns the requested slug
^ & body.slug == "foo"
# Marks the response as JSON
^ & header.content-type == "application/json"
---
Get a YAML Article (REST)
GET {{ REST_ORIGIN }}/article/foo
? format = yaml
# YAML article request succeeds
^ & status == 200
# Marks the response as YAML
^ & header.content-type == "application/yaml"
---
Get a JSON Article (GraphQL)
POST {{ GQL_ORIGIN }}
~~~application/json
{
"query":"query Query($slug: String) {\n getArticle(slug: $slug) {\n author {\n name\n }\n slug\n subtitle\n }\n}",
"variables":{"slug":"lorem-ipsum"}
}
~~~
# GraphQL article request succeeds
^ & status == 200
# Returns the requested GraphQL article
^ & body.data.getArticle.slug == "lorem-ipsum"
---
Get a User (GraphQL)
POST {{ GQL_ORIGIN }}
~~~application/json
{
"query":"query GetUser($getUserId: String) {\n getUser(id: $getUserId) {\n id\n name\n }\n}",
"variables":{"getUserId":"abc1234"}
}
~~~
# GraphQL user request succeeds
^ & status == 200
# Returns the requested user id
^ & body.data.getUser.id == "abc1234"
---
Get JWT
POST {{ REST_ORIGIN }}/jwt
~~~ application/json
{
"username": "foo",
"password": "lorem_ipsum"
}
~~~
& body.token -> $JWT_TOKEN
# JWT request succeeds
^ STATUS == 200
# Captures a JWT token
^ JWT_TOKEN ~= /[A-Za-z0-9_.-]+/
! echo $JWT_TOKEN | cut -d '.' -f2 | base64 --decode | jq .
---
Get Random Uniform Float
GET {{ REST_ORIGIN }}/number
? type = float
? format = json
? length = 1
? seed = 1234
? distribution = uniform
# Float request succeeds
^ & status == 200
# Returns the seeded float
^ & body.[0] == 0.2982523797545582
---
Get Random Uniform Int
GET {{ REST_ORIGIN }}/number
? type = int
? format = json
? length = 1
? min = 0
? max = 10
? seed = 1234
? distribution = uniform
# Integer request succeeds
^ & status == 200
# Returns the seeded integer
^ & body.[0] == 3
---
Get an Image (PNG)
GET {{ REST_ORIGIN }}/image
? format = png
? fill = CECECE
? text = https%3A%2F%2Florem-api.com
# PNG request succeeds
^ & status == 200
# Returns a PNG image
^ & header.content-type == "image/png"
---
Get an Image (JPEG)
GET {{ REST_ORIGIN }}/image
? format = jpeg
? fill = CECECE
? text = https%3A%2F%2Florem-api.com
# JPEG request succeeds
^ & status == 200
# Returns a JPEG image
^ & header.content-type == "image/jpeg"
---
Get a QR Code
GET {{ REST_ORIGIN }}/qr
? data = https://lorem-api.com
# QR request succeeds
^ & status == 200
# Returns an SVG QR code
^ & header.content-type == "image/svg+xml"