# 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 }
~~~

^ & status == 200
^ & body.username == "test"
^ & body.boolean == true
^ & body.number == 123

---

Get Lorem text

GET {{ REST_ORIGIN }}/lorem

? paragraphs=1
? seed = 1234

^ & status == 200
^ & body ~= /[A-Za-z0-9_.-]+/

---

Get a JSON Article (REST)

GET {{ REST_ORIGIN }}/article/foo

? format = json

^ & status == 200
^ & body.slug == "foo"
^ & header.content-type == "application/json"

---

Get a YAML Article (REST)

GET {{ REST_ORIGIN }}/article/foo

? format = yaml

^ & status == 200
^ & 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"}
}
~~~

^ & status == 200
^ & 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"}
}
~~~

^ & status == 200
^ & body.data.getUser.id == "abc1234"

---

Get JWT

POST {{ REST_ORIGIN }}/jwt

~~~ application/json
{
  "username": "foo",
  "password": "lorem_ipsum"
}
~~~

& body.token -> $JWT_TOKEN

^ STATUS == 200
^ 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

^ & status == 200
^ & 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

^ & status == 200
^ & body.[0] == 3

---

Get an Image (PNG)

GET {{ REST_ORIGIN }}/image

? format = png
? fill = CECECE
? text = https%3A%2F%2Florem-api.com

^ & status == 200
^ & header.content-type == "image/png"

---

Get an Image (JPEG)

GET {{ REST_ORIGIN }}/image

? format = jpeg
? fill = CECECE
? text = https%3A%2F%2Florem-api.com

^ & status == 200
^ & header.content-type == "image/jpeg"

---

Get a QR Code

GET {{ REST_ORIGIN }}/qr

? data = https://lorem-api.com

^ & status == 200
^ & header.content-type == "image/svg+xml"

