-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi-tests.http
More file actions
165 lines (141 loc) · 4.16 KB
/
Copy pathapi-tests.http
File metadata and controls
165 lines (141 loc) · 4.16 KB
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
# -*- restclient -*-
# Create a new post
#
# Note: Exluding publicAccess in the request will
# then default to true
#
POST http://localhost:3333/api/v1/posts
Content-Type: application/json
{
"postTitle": "My FIRST paste",
"postContent": "This will be my first paste!"
}
# Creates a private post
#
# Note: As per the above note, specifying publicAccess
# will determine if a public or private post
#
POST http://localhost:3333/api/v1/posts
Content-Type: application/json
{
"postTitle": "My private post",
"postContent": "this is my private post",
"publicAccess": false
}
# Attempts to create a post with a missing parameter
#
# Result: 400, Bad Request
#
# Note: Must have a non-empty title and content included to avoid
# this error
#
POST http://localhost:3333/api/v1/posts
Content-Type: application/json
{
"postTitle": "",
}
# Update a post from the admin access link
#
# Note: Updating a post can only be accessed from the admin link, and the fields
# that can be changed are: title, content, and public access.
#
PUT http://localhost:3333/api/v1/posts/e5616847-58bc-4337-a027-93b908fab833
Content-Type: application/json
{
"postTitle": "Update post from admin",
"postContent": "newly updated content",
"publicAccess": false
}
# Attempts to update a post from the read access link
#
# Result: 403, Forbidden
#
# Note: Must update from the admin link, NOT the read link
#
PUT http://localhost:3333/api/v1/posts/60da59ad-c18f-42c1-9de8-ad7d6a4f6596
Content-Type: application/json
{
"postTitle": "Updated this post",
"postContent": "newly updated content",
"publicAccess": true
}
# Attempts to report a post through a admin access link
#
# Result: 403, Forbidden
#
# Note: One person should only have access to their admin link post, so they should not
# be able to report their own post
#
POST http://localhost:3333/api/v1/posts/e5616847-58bc-4337-a027-93b908fab833/reports
Content-Type: application/json
{
"reported": true,
"reportedReason": "trying to report my own post"
}
# Report a post through a read access link
#
# Note: Reporting only works from a read-only link
#
POST http://localhost:3333/api/v1/posts/60da59ad-c18f-42c1-9de8-ad7d6a4f6596/reports
Content-Type: application/json
{
"reported": true,
"reportedReason": "don't like the post"
}
# Get a post through a admin access link
#
# Note: Data returned from an admin link will return all of the post data
#
GET http://localhost:3333/api/v1/posts/e5616847-58bc-4337-a027-93b908fab833
# Get a post through a read only access link
#
# Note: Data returned from a read only link will simply return less information
# in comparison to the admin link
#
GET http://localhost:3333/api/v1/posts/d3bacc81-cf0e-4f11-aef6-257fa5b83222
# Attempts to get a post that doesn't exist
#
# Result: 404, Not Found
#
GET http://localhost:3333/api/v1/posts/does-not-exist
# Attempts to get multiple posts without arguments
#
# Result: 400, Bad Request
#
# Note: Getting posts only workings when limit and offset are specified
#
GET http://localhost:3333/api/v1/posts
# Attempts to get multiple posts with limit set at a non-int value
#
# Result: 500, Internal Server Error
#
# Post data returned: Read only link, title, created timestamp, updated timestamp
GET http://localhost:3333/api/v1/posts?limit=nonint&offset=0
# Get multiple posts with limit and offset at 0
#
# Note: When offset is set at 0 it simply gets n posts sorted
# by creation date. (n=limit)
#
# Post data returned: Read only link, title, created timestamp, updated timestamp
GET http://localhost:3333/api/v1/posts?limit=10&offset=0
# Get multiple posts with limit and offset both set
#
# Note: If offset is greather than number of posts in DB it
# will return rempty
#
GET http://localhost:3333/api/v1/posts?limit=5&offset=5
# Deletes a post through with a admin access link
#
# Note: Deletion only works through an admin access link
#
DELETE http://localhost:3333/api/v1/posts/e5616847-58bc-4337-a027-93b908fab833
# Attempts to delete a post through a read access link
#
# Result: 403, Forbidden
#
DELETE http://localhost:3333/api/v1/posts/60da59ad-c18f-42c1-9de8-ad7d6a4f6596
# Attempts to delete a post that does not exist
#
# Result: 404, Not Found
#
DELETE http://localhost:3333/api/v1/posts/does-not-exist