-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.hurl
199 lines (182 loc) · 5.25 KB
/
test.hurl
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# sign-up
POST http://localhost:3000/api/v1/auth/sign-up
{
"email": "[email protected]",
"password": "1234",
"password_confirmation": "1234"
}
HTTP/1.1 200
[Captures]
user_id: jsonpath "$.id"
# sign-in
POST http://localhost:3000/api/v1/auth/sign-in
{
"email": "[email protected]",
"password": "1234"
}
HTTP/1.1 200
[Captures]
token: jsonpath "$.access_token"
# get user profile
GET http://localhost:3000/api/v1/auth/user-profile
Authorization: Bearer {{token}}
HTTP/1.1 200
[Asserts]
jsonpath "$.email" == "[email protected]"
# post a bookmark
POST http://localhost:3000/api/v1/bookmarks
Authorization: Bearer {{token}}
{
"url": "https://tokio.rs/tokio/topics/tracing",
"tags": ["Rust", "Tokio"]
}
HTTP/1.1 201
[Asserts]
jsonpath "$.url" == "https://tokio.rs/tokio/topics/tracing"
jsonpath "$.tags[*]" includes "Rust"
jsonpath "$.tags[*]" includes "Tokio"
# wait until bookmark completed
GET http://localhost:3000/api/v1/bookmarks
Authorization: Bearer {{token}}
[Options]
retry: 10
HTTP/1.1 200
[Captures]
bookmark_id: jsonpath "$.bookmarks[0].bookmark_id"
# get bookmark by id
GET http://localhost:3000/api/v1/bookmarks/{{bookmark_id}}
Authorization: Bearer {{token}}
HTTP/1.1 200
[Asserts]
jsonpath "$.bookmark_id" == {{bookmark_id}}
jsonpath "$.url" == "https://tokio.rs/tokio/topics/tracing"
# set tags to bookmark
POST http://localhost:3000/api/v1/bookmarks/{{bookmark_id}}/tags
Authorization: Bearer {{token}}
{
"tags": ["rust", "tokio"]
}
HTTP/1.1 200
[Asserts]
jsonpath "$.bookmark_id" == {{bookmark_id}}
jsonpath "$.url" == "https://tokio.rs/tokio/topics/tracing"
jsonpath "$.tags" count == 2
jsonpath "$.tags[*]" includes "rust"
jsonpath "$.tags[*]" includes "tokio"
# append tags to bookmark
PATCH http://localhost:3000/api/v1/bookmarks/{{bookmark_id}}/tags
Authorization: Bearer {{token}}
{
"tags": ["tracing"]
}
HTTP/1.1 200
[Asserts]
jsonpath "$.bookmark_id" == {{bookmark_id}}
jsonpath "$.url" == "https://tokio.rs/tokio/topics/tracing"
jsonpath "$.tags" count == 3
jsonpath "$.tags[*]" includes "rust"
jsonpath "$.tags[*]" includes "tokio"
jsonpath "$.tags[*]" includes "tracing"
# post a new bookmark
POST http://localhost:3000/api/v1/bookmarks
Authorization: Bearer {{token}}
{
"url": "https://tokio.rs/blog/2022-02-announcing-tokio-metrics",
"tags": ["rust", "tokio", "metrics"]
}
HTTP/1.1 201
[Asserts]
jsonpath "$.url" == "https://tokio.rs/blog/2022-02-announcing-tokio-metrics"
jsonpath "$.tags[*]" includes "rust"
jsonpath "$.tags[*]" includes "tokio"
jsonpath "$.tags[*]" includes "metrics"
# wait until the new bookmark completed
GET http://localhost:3000/api/v1/bookmarks
Authorization: Bearer {{token}}
[Options]
retry: 10
HTTP/1.1 200
[Asserts]
body contains "https://tokio.rs/blog/2022-02-announcing-tokio-metrics"
# get_all_tags
GET http://localhost:3000/api/v1/tags
Authorization: Bearer {{token}}
HTTP/1.1 200
[Asserts]
jsonpath "$.tags" count == 4
jsonpath "$.tags[?(@.tag=='rust')].count" includes 2
jsonpath "$.tags[?(@.tag=='tokio')].count" includes 2
jsonpath "$.tags[?(@.tag=='tracing')].count" includes 1
jsonpath "$.tags[?(@.tag=='metrics')].count" includes 1
# get_bookmarks_by_tag
GET http://localhost:3000/api/v1/tags/metrics
Authorization: Bearer {{token}}
HTTP/1.1 200
[Asserts]
jsonpath "$.bookmarks" count == 1
jsonpath "$.bookmarks[0].url" == "https://tokio.rs/blog/2022-02-announcing-tokio-metrics"
# search by query
POST http://localhost:3000/api/v1/search
Authorization: Bearer {{token}}
{
"query": "tracing"
}
HTTP/1.1 200
[Asserts]
jsonpath "$.items" count == 1
jsonpath "$.items[0].bookmark.url" == "https://tokio.rs/tokio/topics/tracing"
jsonpath "$.items[0].search_match" contains "tracing"
# search by query with and
POST http://localhost:3000/api/v1/search
Authorization: Bearer {{token}}
{
"query": "tracing & tokio"
}
HTTP/1.1 200
[Asserts]
jsonpath "$.items" count == 1
jsonpath "$.items[0].bookmark.url" == "https://tokio.rs/tokio/topics/tracing"
jsonpath "$.items[0].search_match" contains "tracing"
jsonpath "$.items[0].search_match" contains "Tokio"
# search by phrase
POST http://localhost:3000/api/v1/search
Authorization: Bearer {{token}}
{
"query": "\"we are happy to announce the initial release of tokio-metrics\""
}
HTTP/1.1 200
[Asserts]
jsonpath "$.items" count == 1
jsonpath "$.items[0].bookmark.url" == "https://tokio.rs/blog/2022-02-announcing-tokio-metrics"
jsonpath "$.items[0].search_match" contains "tokio"
jsonpath "$.items[0].search_match" contains "metrics"
# empty search should return all results
POST http://localhost:3000/api/v1/search
Authorization: Bearer {{token}}
{}
HTTP/1.1 200
[Asserts]
jsonpath "$.items" count == 2
# post a new bookmark with images
POST http://localhost:3000/api/v1/bookmarks
Authorization: Bearer {{token}}
{
"url": "https://tailscale.com/blog/how-nat-traversal-works/",
"tags": ["network"]
}
HTTP/1.1 201
[Asserts]
jsonpath "$.url" == "https://tailscale.com/blog/how-nat-traversal-works/"
jsonpath "$.tags[0]" == "network"
# post the same bookmark again, should update tags
POST http://localhost:3000/api/v1/bookmarks
Authorization: Bearer {{token}}
{
"url": "https://tailscale.com/blog/how-nat-traversal-works/",
"tags": ["network", "nat"]
}
HTTP/1.1 201
[Asserts]
jsonpath "$.url" == "https://tailscale.com/blog/how-nat-traversal-works/"
jsonpath "$.tags[*]" includes "network"
jsonpath "$.tags[*]" includes "nat"