-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathapi.http
120 lines (95 loc) · 2.28 KB
/
api.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
## Create Admin
POST http://localhost:3000/users
Content-Type: application/json
{
"name": "Admin",
"email": "[email protected]",
"password": "admin",
"role": "ADMIN"
}
### Create Reader
POST http://localhost:3000/users
Content-Type: application/json
Authorization: Bearer {{tokenAdmin}}
{
"name": "Reader",
"email": "[email protected]",
"password": "reader",
"role": "READER"
}
### Create Writer
POST http://localhost:3000/users
Content-Type: application/json
Authorization: Bearer {{tokenAdmin}}
{
"name": "Writer",
"email": "[email protected]",
"password": "writer",
"role": "WRITER",
"permissions": [
{
"action": "read",
"resource": "User"
},
{
"action": "update",
"resource": "Post",
"condition": {
"id": "1"
}
}
]
}
###
GET http://localhost:3000/users
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiQWRtaW4iLCJlbWFpbCI6ImFkbWluQHVzZXIuY29tIiwiaWF0IjoxNzQzNTQ5MzA4LCJleHAiOjE3NDM1NTY1MDh9.QvwOm2s_X9khfW0jOmISX8jiNsviInZkAptWLGFOVxQ
###
GET http://localhost:3000/users/cm8z3gmns0002s9sywsjk9upq
###
# @name adminLogin
POST http://localhost:3000/auth/login
Content-Type: application/json
{
"email": "[email protected]",
"password": "admin"
}
###
@tokenAdmin = {{ adminLogin.response.body.access_token }}
###
# @name readerLogin
POST http://localhost:3000/auth/login
Content-Type: application/json
{
"email": "[email protected]",
"password": "reader"
}
###
@tokenReader = {{ readerLogin.response.body.access_token }}
###
# @name writerLogin
POST http://localhost:3000/auth/login
Content-Type: application/json
{
"email": "[email protected]",
"password": "writer"
}
###
@tokenWriter = {{ writerLogin.response.body.access_token }}
###
POST http://localhost:3000/posts
Content-Type: application/json
Authorization: Bearer {{tokenAdmin}}
{
"title": "My first post",
"content": "This is the content of my first post.",
"published": false
}
###
GET http://localhost:3000/posts
Authorization: Bearer {{tokenReader}}
###
GET http://localhost:3000/posts/cm8z70heh0001s9r7ick5369u
Authorization: Bearer {{tokenReader}}
###
GET http://localhost:3000/users
Authorization: Bearer {{tokenReader}}