From e671441e049dc8e4f046758216bf8cce2b5afcb2 Mon Sep 17 00:00:00 2001 From: Emmanuel Gautier Date: Mon, 11 Mar 2024 22:33:04 +0100 Subject: [PATCH] tests: add bruno conformance tests --- tests/conformance/Authorize/Authorize.bru | 20 ++++++++++++++++++ ...uthorize Callback Without Query Params.bru | 14 +++++++++++++ .../Authorize/Callback/Authorize Callback.bru | 20 ++++++++++++++++++ .../Get Sessions When Set Cookie.bru | 21 +++++++++++++++++++ .../Sessions/Get Sessions/Get Sessions.bru | 17 +++++++++++++++ tests/conformance/Sessions/Has Session.bru | 16 ++++++++++++++ tests/conformance/bruno.json | 8 +++++++ tests/conformance/environments/local.bru | 4 ++++ 8 files changed, 120 insertions(+) create mode 100644 tests/conformance/Authorize/Authorize.bru create mode 100644 tests/conformance/Authorize/Callback/Authorize Callback Without Query Params.bru create mode 100644 tests/conformance/Authorize/Callback/Authorize Callback.bru create mode 100644 tests/conformance/Sessions/Get Sessions/Get Sessions When Set Cookie.bru create mode 100644 tests/conformance/Sessions/Get Sessions/Get Sessions.bru create mode 100644 tests/conformance/Sessions/Has Session.bru create mode 100644 tests/conformance/bruno.json create mode 100644 tests/conformance/environments/local.bru diff --git a/tests/conformance/Authorize/Authorize.bru b/tests/conformance/Authorize/Authorize.bru new file mode 100644 index 0000000..315c472 --- /dev/null +++ b/tests/conformance/Authorize/Authorize.bru @@ -0,0 +1,20 @@ +meta { + name: Authorize + type: http + seq: 1 +} + +get { + url: {{host}}/oauth/authorize +} + +assert { + res.status: eq 307 + res.body: isEmpty + res.headers.location: isDefined + res.headers.location: eq {{authServerUrl}}/oauth/authorize +} + +script:pre-request { + req.setMaxRedirects(0); +} diff --git a/tests/conformance/Authorize/Callback/Authorize Callback Without Query Params.bru b/tests/conformance/Authorize/Callback/Authorize Callback Without Query Params.bru new file mode 100644 index 0000000..13c1a92 --- /dev/null +++ b/tests/conformance/Authorize/Callback/Authorize Callback Without Query Params.bru @@ -0,0 +1,14 @@ +meta { + name: Authorize Callback Without Query Params + type: http + seq: 1 +} + +get { + url: {{host}}/oauth/callback +} + +assert { + res.status: eq 400 + res.headers.location: undefined +} diff --git a/tests/conformance/Authorize/Callback/Authorize Callback.bru b/tests/conformance/Authorize/Callback/Authorize Callback.bru new file mode 100644 index 0000000..2a09a5c --- /dev/null +++ b/tests/conformance/Authorize/Callback/Authorize Callback.bru @@ -0,0 +1,20 @@ +meta { + name: Authorize Callback + type: http + seq: 1 +} + +get { + url: {{host}}/oauth/callback +} + +assert { + res.status: eq 301 + res.body: isEmpty + res.headers.location: isDefined + res.headers.location: eq / +} + +script:pre-request { + req.setMaxRedirects(0); +} diff --git a/tests/conformance/Sessions/Get Sessions/Get Sessions When Set Cookie.bru b/tests/conformance/Sessions/Get Sessions/Get Sessions When Set Cookie.bru new file mode 100644 index 0000000..13a4cb7 --- /dev/null +++ b/tests/conformance/Sessions/Get Sessions/Get Sessions When Set Cookie.bru @@ -0,0 +1,21 @@ +meta { + name: Get Sessions When Set Cookie + type: http + seq: 2 +} + +get { + url: {{host}}/sessions + body: none + auth: none +} + +headers { + Cookie: jwt=test +} + +assert { + res.status: eq 200 + res.body: isJson + res.body.sessions: length 0 +} diff --git a/tests/conformance/Sessions/Get Sessions/Get Sessions.bru b/tests/conformance/Sessions/Get Sessions/Get Sessions.bru new file mode 100644 index 0000000..3cb7692 --- /dev/null +++ b/tests/conformance/Sessions/Get Sessions/Get Sessions.bru @@ -0,0 +1,17 @@ +meta { + name: Get Sessions + type: http + seq: 1 +} + +get { + url: {{host}}/sessions + body: none + auth: none +} + +assert { + res.status: eq 200 + res.body: isJson + res.body.sessions: length 0 +} diff --git a/tests/conformance/Sessions/Has Session.bru b/tests/conformance/Sessions/Has Session.bru new file mode 100644 index 0000000..f578f83 --- /dev/null +++ b/tests/conformance/Sessions/Has Session.bru @@ -0,0 +1,16 @@ +meta { + name: Has Session + type: http + seq: 1 +} + +head { + url: {{host}}/sessions + body: none + auth: none +} + +assert { + res.status: eq 204 + res.body: isEmpty +} diff --git a/tests/conformance/bruno.json b/tests/conformance/bruno.json new file mode 100644 index 0000000..14223d6 --- /dev/null +++ b/tests/conformance/bruno.json @@ -0,0 +1,8 @@ +{ + "version": "1", + "name": "baffao", + "type": "collection", + "ignore": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/tests/conformance/environments/local.bru b/tests/conformance/environments/local.bru new file mode 100644 index 0000000..dd248c3 --- /dev/null +++ b/tests/conformance/environments/local.bru @@ -0,0 +1,4 @@ +vars { + host: http://localhost:3000 + authServerUrl: http://localhost:8080 +}