-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrest.http
111 lines (94 loc) · 1.97 KB
/
rest.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
POST localhost:9501/api/users/signup
Content-Type: application/json
{
"email": "[email protected]",
"password": "test2"
}
> {%
client.global.set('token', response.headers.valuesOf("Token")[0]);
%}
###
POST localhost:9501/api/users/signin
Content-Type: application/json
{
"email": "[email protected]",
"password": "test"
}
> {%
client.global.set('token', response.headers.valuesOf("Token")[0]);
%}
###
POST localhost:9501/api/users/signin
Content-Type: application/json
{
"email": "[email protected]",
"password": "admin"
}
> {%
client.global.set('token', response.headers.valuesOf("Token")[0]);
%}
###
POST localhost:9501/api/users/signout
Content-Type: application/json
Token: {{ token }}
> {%
client.global.set('token', response.headers.valuesOf("Token")[0]);
%}
###
GET localhost:9501/api/users/currentuser
Content-Type: application/json
Token: {{ token }}
###
#==========================================================Testing======================================================
#### Authorization by token, part 1. Retrieve and save token.
#POST https://httpbin.org/post
#Content-Type: application/json
#
#{
# "token": "my-secret-token"
#}
#
#> {% client.global.set("auth_token", response.body.json.token); %}
#
#### Authorization by token, part 2. Use token to authorize.
#GET https://httpbin.org/headers
#Authorization: Bearer {{auth_token}}
#
####
# 1.
POST localhost:9501/api/users/signin
Content-Type: application/json
{
"email": "[email protected]",
"password": "admin"
}
> {%
client.global.set('token', response.headers.valuesOf("Token")[0]);
%}
###
# 2.
POST localhost:9502/api/tickets/create
Content-Type: application/json
Token: {{ token }}
{
"title": "Ticket 1",
"price": 123
}
###
# 3.
POST localhost:9503/api/orders/create
Content-Type: application/json
Token: {{ token }}
{
"ticket_id": 4
}
###
# 4.
POST localhost:9505/api/payments
Content-Type: application/json
Token: {{ token }}
{
"token": "tok_visa",
"order_id": 1
}
###