summaryrefslogtreecommitdiff
path: root/muck1.yarn
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2019-04-29 14:01:10 +0300
committerLars Wirzenius <liw@liw.fi>2019-04-29 14:01:10 +0300
commit315fbae5532c1a0bddac82b927e936e3f666ade0 (patch)
tree3bcb7a31ac63efa573540ff51ca940cb1318218e /muck1.yarn
downloadsaga-poc-315fbae5532c1a0bddac82b927e936e3f666ade0.tar.gz
Add: muck1 and muck2 prototypes
Diffstat (limited to 'muck1.yarn')
-rw-r--r--muck1.yarn131
1 files changed, 131 insertions, 0 deletions
diff --git a/muck1.yarn b/muck1.yarn
new file mode 100644
index 0000000..6cd73a3
--- /dev/null
+++ b/muck1.yarn
@@ -0,0 +1,131 @@
+---
+title: Muck acceptance tests
+author: Lars Wirzenius / The Ick project
+...
+
+Introduction
+=============================================================================
+
+Muck is a persistent in-memory JSON store with an HTTP API and
+advanced access control using signed JWT access tokens. This document
+presents its automated acceptance tests, using a (for now
+hypothetical) language similar to the Gherkin langauge implemented by
+Cucumber.
+
+A happy path scenario
+=============================================================================
+
+This scenario does some basic resource management via the Muck API.
+
+Start Muck. This also sets up access to it for the user by getting an
+access token, which will be used for all requests.
+
+> **given** a running Muck
+
+Check server status.
+
+> **given** I am _tomjon_
+> **when** I make request _GET /status_
+> **then** status code is _200_
+> **and** response body is `{"resources":0}`
+
+Create a simple resource. Remember its id.
+
+> **when** I make request _POST /res_ with body `{"foo":"bar"}`
+> **then** status code is _201_
+> **and** response has header _"Muck-Owner: tomjon"_
+> **and** resource id is remembered as _ID_
+> **and** resource revision is remembered as _REV1_
+>
+> **when** I make request _GET /status_
+> **then** status code is _200_
+> **and** response body is `{"resources":1}`
+
+Retrieve the resource.
+
+> **when** I make request _GET /res_ with header _"Muck-Id: ${ID}"_
+> **then** status code is _200_
+> **and** response body is `{ "foo": "bar" }`
+> **and** response has header _"Muck-Id: ${ID}"_
+> **and** response has header _"Muck-Revision: ${REV1}"_
+> **and** response has header _"Muck-Owner: tomjon"_
+
+Make sure another user can't retreive, update, or delete the resource.
+
+> **given** I am _verence_
+> **when** I make request _GET /res with header "Muck-Id: ${ID}"_
+> **then** status code is _404_
+>
+> **when** I make request _PUT /res_
+> with header _"Muck-Id: ${ID}"_ and
+> header _"Muck-Revision: ${REV1}"_ and
+> body `{"foo": "foobar"}`
+>
+> **then** status code is _404_
+>
+> **when** I make request _DELETE /res_ with header _"Muck-Id: ${ID}"_
+> **then** status code is _404_
+
+Update the resource.
+
+> **given** I am _tomjon_
+> **when** I make request _PUT /res_ with header _"Muck-Id: ${ID}"_ and
+> header _"Muck-Revision: wrong"_ and
+> body `{"foo": "foobar"}`
+> **then** status code is _400_
+>
+> **when** I make request _PUT /res_ with header _"Muck-Id: ${ID}"_ and
+> header _"Muck-Revision: ${REV1}"_ and
+> body `{"foo": "foobar"}`
+> **then** status code is _200_
+> **and** resource revision is remembered as _REV2_
+
+Check the resource has been updated.
+
+> **when** I make request _GET /res_ with header _"Muck-Id: ${ID}"_
+> **then** status code is _200_
+> **and** response body is `{"foo": "foobar"}`
+> **and** response has header _"Muck-Id: ${ID}"_
+> **and** response has header _"Muck-Revision: ${REV2}"_
+> **and** response has header _"Muck-Owner: tomjon"_
+
+Restart Muck. The resource should still exist.
+
+> **when** Muck is restarted
+> **and** I make request _GET /res_ with header _"Muck-Id: ${ID}"_
+> **then** status code is _200_
+> **and** response body is `{"foo":"foobar"}`
+> **and** response has header _"Muck-Id: ${ID}"_
+> **and** response has header _"Muck-Revision: ${REV2}"_
+> **and** response has header _"Muck-Owner: tomjon"_
+
+Search for the resource. First with a condition that is no longer
+true.
+
+> **when** I make request _GET /search_ with body
+> `{"cond": [{"where": "data", "field": "foo", "pattern": "bar","op": "=="}]}`
+> **then** status code is _200_
+> **and** response body is _{"resources": []}_
+
+Now search for the correct value.
+
+> **when** user _tomjon_ makes request _GET /search_ with body
+> `{"cond": [{"where":"data","field":"foo","pattern":"foobar","op":"=="}]}`
+> **then** status code is _200_
+> **and** response body is `{"resources": ["${ID}"]}`
+
+Delete the resource.
+
+> **when** user _tomjon_ makes request _DELETE /res_ with header _"Muck-Id: ${ID}"_
+> **then** status code is _200_
+>
+> **when** user _tomjon_ makes request _GET /res_ with header _"Muck-Id: ${ID}"_
+> **then** status code is _404_
+
+Restart Muck again. The resource should not exist.
+
+> **when** Muck is restarted
+> **and** user _tomjon_ makes request _GET /res_ with header _"Muck-Id: ${ID}"_
+> **then** status code is _404_
+
+All done.