-
Notifications
You must be signed in to change notification settings - Fork 0
/
APITest.robot
155 lines (85 loc) · 4.51 KB
/
APITest.robot
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
*** Settings ***
Documentation API testing
Library SeleniumLibrary
Library Collections
Test Teardown Close Browser
Resource resource.robot
Library RequestsLibrary
Library OperatingSystem
*** Variables ***
${base_url} https://app.snapp-box.com
${auth_token} eyJhbGciOiJIUzUxMiJ9.eyJjaWQiOjI0Njk5NzQ3LCJjcmlkIjoiNDE5NzQ0MjYiLCJlIjoiZW1hZGRleW1AZ21haWwuY29tIiwid2UiOmZhbHNlLCJzdWIiOiIwOTM3NjY4MTg1NiIsImF1dGgiOiJST0xFX0NVU1RPTUVSIiwidHlwZSI6ImN1c3RvbWVyIn0.CFRH8o4qccBjmBbGq9WEFOT_jtuZSKldcIuehE3f-OOvaUD-uIMmb-Z8-YlYcwoOlp-IBFLBTwi3vS8bbJd21g
&{json_data} city=tehran
... deliveryCategory=bike-without-box
... terminals=${terminals}
@{terminals} &{terminal1} &{terminal2}
&{terminal1} address=بزرگراه شهید حقانی، گاندی شمالی، محمد صانعی
... plate=
... sequenceNumber=1
... unit=
... latitude=35.75842340059014
... longitude=51.41138076782227
... type=pickup
&{terminal2} address=بزرگراه شهید حقانی، گاندی شمالی، محمد صانعی
... sequenceNumber=2
... latitude=35.75842340059014
... longitude=51.41232490539551
... type=drop
... collectCash=no
... paymentType=prepaid
&{Missing_json_data}
... terminals=${terminals_Miss}
@{terminals_Miss} &{terminal1_Miss} &{terminal2_Miss}
&{terminal1_Miss} address=New york
&{terminal2_Miss}
... sequenceNumber=2
&{Wrong_Data} city=tehran
... deliveryCategory=bike-without-box
... terminals=${terminals_Wrong}
@{terminals_Wrong} &{terminal1_Wrong} &{terminal2_Wrong}
&{terminal1_Wrong} address=بزرگراه شهید حقانی، گاندی شمالی، محمد صانعی
... plate=
... sequenceNumber=1
... unit=
... latitude=0000
... longitude=00000
... type=2
&{terminal2_Wrong} address=بزرگراه شهید حقانی، گاندی شمالی، محمد صانعی
... sequenceNumber=2
... latitude=35.75842340059014
... longitude=51.41232490539551
... type=2
... collectCash=no
... paymentType=prepaid
*** Test Cases ***
Test API Endpoint - Pricing with Authorization Token
Create Session API ${base_url}
# Define request headers with Authorization token and defective data
${headers}= Create Dictionary Content-Type=application/json Authorization=${auth_token}
${response}= Post Request API /api/v1/customer/order/pricing json=${json_data} headers=${headers}
Should Be Equal As Strings ${response.status_code} 200
Test API Endpoint - Pricing with Authorization Token and sending defective data
Create Session API ${base_url}
# Define request headers with unAuthorization token and defective data
${headers}= Create Dictionary Content-Type=application/json Authorization=${auth_token}
${response}= Post Request API /api/v1/customer/order/pricing json=${Missing_json_data} headers=${headers}
Should Be Equal As Strings ${response.status_code} 500
Test API Endpoint - Pricing with unAuthorization Token
Create Session API ${base_url}
# Define request headers with unAuthorization token
${headers}= Create Dictionary Content-Type=application/json
${response}= Post Request API /api/v1/customer/order/pricing json=${json_data} headers=${headers}
Should Be Equal As Strings ${response.status_code} 401
Log ${response.json()}
Test API Endpoint - Pricing with Authorization Token and missing data
Create Session API ${base_url}
# Define request headers with Authorization token and missing data
${headers}= Create Dictionary Content-Type=application/json Authorization=${auth_token}
${response}= Post Request API /api/v1/customer/order/pricing json=${Missing_json_data} headers=${headers}
Should Be Equal As Strings ${response.status_code} 500
Test API Endpoint - Pricing with Authorized Token and empty data
Create Session API ${base_url}
# Define request headers with Authorization token and wrong data
${headers}= Create Dictionary Content-Type=application/json Authorization=${auth_token}
${response}= Post Request API /api/v1/customer/order/pricing headers=${headers}
Should Be Equal As Strings ${response.status_code} 400