blob: 88b29a5a691719394fc8acdcbb9bb3a4dd621345 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
# A happy path scenario
This scenario does some basic resource management via the Muck API.
SCENARIO Muck
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 status.
WHEN user tomjon makes request GET /status
THEN status code is 200
THEN response body is {"resources":0}
Create a simple resource. Remember its id.
WHEN user tomjon makes request POST /res with body { "foo": "bar" }
THEN status code is 201
THEN remember resource id as ID
THEN remember resource revision as REV1
THEN response has header "Muck-Owner: tomjon"
WHEN user tomjon makes request GET /status
THEN status code is 200
THEN response body is {"resources":1}
Retrieve the resource.
WHEN user tomjon makes request GET /res with header "Muck-Id: ${ID}"
THEN status code is 200
THEN response body is { "foo": "bar" }
THEN response has header "Muck-Id: ${ID}"
THEN response has header "Muck-Revision: ${REV1}"
THEN response has header "Muck-Owner: tomjon"
Make sure another user can't retreive, update, or delete the resource.
WHEN user verence makes request GET /res with header "Muck-Id: ${ID}"
THEN status code is 404
WHEN user verence makes request PUT /res with header "Muck-Id: ${ID}" and
... header "Muck-Revision: ${REV1}" and
... body { "foo": "foobar" }
THEN status code is 404
WHEN user verence makes request DELETE /res with header "Muck-Id: ${ID}"
THEN status code is 404
Update the resource.
WHEN user tomjon makes request PUT /res with header "Muck-Id: ${ID}" and
... header "Muck-Revision: wrong" and
... body { "foo": "foobar" }
THEN status code is 400
WHEN user tomjon makes request PUT /res with header "Muck-Id: ${ID}" and
... header "Muck-Revision: ${REV1}" and
... body { "foo": "foobar" }
THEN status code is 200
THEN remember resource revision as REV2
Check the resource has been updated.
WHEN user tomjon makes request GET /res with header "Muck-Id: ${ID}"
THEN status code is 200
THEN response body is { "foo": "foobar" }
THEN response has header "Muck-Id: ${ID}"
THEN response has header "Muck-Revision: ${REV2}"
THEN response has header "Muck-Owner: tomjon"
Restart Muck. The resource should still exist.
WHEN Muck is restarted
WHEN user tomjon makes request GET /res with header "Muck-Id: ${ID}"
THEN status code is 200
THEN response body is { "foo": "foobar" }
THEN response has header "Muck-Id: ${ID}"
THEN response has header "Muck-Revision: ${REV2}"
THEN response has header "Muck-Owner: tomjon"
Search for the resource. First with a condition that is no longer
true.
WHEN user tomjon makes request GET /search with body
... {
... "cond": [
... {"where": "data", "field": "foo", "pattern": "bar", "op": "=="}
... ]
... }
THEN status code is 200
THEN 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
THEN 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
WHEN user tomjon makes request GET /res with header "Muck-Id: ${ID}"
THEN status code is 404
All done.
FINALLY Muck is stopped
|