-
Notifications
You must be signed in to change notification settings - Fork 0
/
restClientTests.http
173 lines (130 loc) · 3.64 KB
/
restClientTests.http
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
# -*- restclient -*-
#Variables
:port = 8010
:api = http://localhost::port/api/v1
:viewLinkID = d0e74d150c680b3394e5a0deac1ea129
:editLinkID = 21f98c353a1f60484c4fb3f1421d78f5
:unknownLinkID = thisIsNotGonnaWork
# ======== Test Post Creation End-Point ========
# Create post
POST :api/posts
Content-Type: application/json
{
"title" : "This is the title",
"body" : "Lorem Ipsum is simply dummy text of the printing and typesetting industry.",
"scope" : "Private"
}
# Create post with null values
# Reports Bad Request Error
POST :api/posts
Content-Type: application/json
{
"title" : "",
"body" : "",
"scope" : ""
}
# Create post with incorrect JSON. The JSON is missing a comma's.
# Reports Bad Request error.
POST :api/posts
Content-Type: application/json
{
"title" : "This is the post"
"body" : "Lorem Ipsum is simply dummy text of the printing and typesetting industry."
"scope" : "Private"
}
# ======== Test Public Posts Retrieval End-Point ========
# Retrieving all posts end point
# Accessing a valid page
# For each post, their title, body, view link, and timestamp is sent by the server
GET :api/posts?offset=2&limit=2
# Retrieving a page outside the bounds
# Returns empty JSON array
GET :api/posts?offset=2000&limit=2
# Retrieving something from an invalid page number
# Return Bad Request error
GET :api/posts?page=:unknownLinkID
# Retrieving all posts without a query string
# Return Bad Request response
GET :api/posts
# ======== Test Specific Post Retrieval End-Point ========
# Getting the post using its view link
# View link returns the Title, Body and the Timestamp of post creation.
GET :api/posts/:viewLinkID
# Getting the post using its edit link
# View link returns the Title, Body, post creation timestamp, view link, and edit link.
GET :api/posts/:editLinkID
# Getting the post with an unknown link
# Returns Not Found error
GET :api/posts/:unknownLinkID
# ======== Test Post Updating End-Point ========
# Updating with a view link
# Returns forbidden error
PUT :api/posts/:viewLinkID
Content-Type: application/json
{
"title" : "This is the new title",
"scope" : "Public"
}
# Updating with an edit link to the post
# Edits the post
PUT :api/posts/:editLinkID
Content-Type: application/json
{
"title" : "This is the new title",
"scope" : "Public"
}
# Updating with a unknown link
# Returns Not Found error
PUT :api/posts/:unknownLinkID
Content-Type: application/json
{
"title" : "This is the new title",
"scope" : "Public"
}
# Updating with an edit link to the post with an empty title
# Reports Bad Request error
PUT :api/posts/:editLinkID
Content-Type: application/json
{
"title" : "",
"scope" : "Public"
}
# ======== Test Post Reporting End-Point ========
# Reporting with a view link
# Reports the post
POST :api/posts/:viewLinkID/report
Content-Type: application/json
{
"reason" : "Inappropriate Content"
}
# Reporting with a view link and null reason
# Reports bad request error
POST :api/posts/:viewLinkID/report
Content-Type: application/json
{
"reason" : null
}
# Updating with an edit link to the post
# Returns error
POST :api/posts/:editLinkID/report
Content-Type: application/json
{
"reason" : "Inappropriate Content"
}
# Updating with a unknown link
# Returns Not Found error
POST :api/posts/:unknownLinkID/report
Content-Type: application/json
{
"reason" : "Inappropriate Content"
}
# ======== Test Post Deletion End-Point ========
# Deleting the post using its view link
# Returns Forbidden Error
DELETE :api/posts/:viewLinkID
# Getting the post using its edit link
# Deletes the post
DELETE :api/posts/:editLinkID
# Getting the post with an unknown link
# Returns Not Found error
DELETE :api/posts/:unknownLinkID