This repository has been archived by the owner on May 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests
executable file
·183 lines (153 loc) · 4.5 KB
/
run_tests
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
174
175
176
177
178
179
180
181
182
183
#!/bin/bash
./stop_server
./start_server
. venv/bin/activate
TEST_1="$(imprimatur tests/1/test.py)"
TEST_1_DES="Name: single regex failure
Request: http://localhost:5000/text_1
The regular expression 'sportive bombination' fails.
('content-length', '33')
('content-type', 'text; charset=utf-8')
('date', 'Sat, 17 Jan 2015 13:30:54 GMT')
('server', 'Werkzeug/0.9.6 Python/3.4.0')
The best of all possible worlds."
if [[ "$TEST_1" != "$TEST_1_DES" ]]
then
echo -e "Test 1 failed.\n$TEST_1"
exit 1
fi
if imprimatur tests/1/test.py > /dev/null
then
echo "Test 1 should fail, but it returned success."
exit 1
fi
echo "Passed Test 1"
TEST_2="$(imprimatur tests/2/test.py)"
TEST_2_DES="Name: single regex success
Request: http://localhost:5000/text_2
Name: status code as string
Request: http://localhost:5000/text_1
Name: Auth success
Request: http://localhost:5000/auth
Name: Auth carried over success
Request: http://localhost:5000/auth
Name: Relative file upload success
Request: http://localhost:5000/echo
Name: Post name and value with regex. Success.
Request: http://localhost:5000/echo
Name: Reset tries. Success.
Request: http://localhost:5000/counter_reset
Name: Tries. Success.
Request: http://localhost:5000/counter
Request: http://localhost:5000/counter
Request: http://localhost:5000/counter
Name: Regex on header. Success
Request: http://localhost:5000/redirect?location=http://localhost:5000/here.html
Name: HTTP HEAD request. Success
Request: http://localhost:5000/text_1
Name: Upload script with syntax errors
Request: http://localhost:5000/
Name: Custom HTTP headers
Request: http://localhost:5000/text_1
Name: Binary file upload success
Request: http://localhost:5000/echo_bin
Name: Unzip
Request: http://localhost:5000/text_2_zip
Name: Default path
Request: http://localhost:5000/
Passed all tests!"
if [[ "$TEST_2" != "$TEST_2_DES" ]]
then
echo -e "Test 2 failed.\n$TEST_2"
exit 1
fi
if ! imprimatur tests/2/test.py > /dev/null
then
echo "Test 2 should return success, but it returned fail."
exit 1
fi
echo "Passed Test 2"
TEST_3="$(imprimatur tests/3/test.py)"
TEST_3_DES="Name: Auth failure
Request: http://localhost:5000/auth
The regular expression 'sportive bombination' fails.
('content-length', '14')
('content-type', 'text; charset=utf-8')
('date', 'Sat, 17 Jan 2015 13:30:54 GMT')
('server', 'Werkzeug/0.9.6 Python/3.4.0')
not authorized"
if [[ "$TEST_3" != "$TEST_3_DES" ]]
then
echo -e "Test 3 failed.\n$TEST_3"
exit 1
fi
if imprimatur tests/3/test.py > /dev/null
then
echo "Test 3 should fail, but it returned success."
exit 1
fi
echo "Passed Test 3"
TEST_4="$(imprimatur tests/4/test.py)"
TEST_4_DES="Name: Response code failure
Request: http://localhost:5000/text_1
The desired status code 302 doesn't match the actual status code 200.
('content-length', '33')
('content-type', 'text; charset=utf-8')
('date', 'Sat, 17 Jan 2015 13:30:54 GMT')
('server', 'Werkzeug/0.9.6 Python/3.4.0')
The best of all possible worlds."
if [[ "$TEST_4" != "$TEST_4_DES" ]]
then
echo -e "Test 4 failed.\n$TEST_4"
exit 1
fi
if imprimatur tests/4/test.py > /dev/null
then
echo "Test 4 should fail, but it returned success."
exit 1
fi
echo "Passed Test 4"
TEST_5="$(imprimatur tests/5/test.py)"
TEST_5_DES="Name: Response has no body, and status_code doesn't match.
Request: http://localhost:5000/blank
The desired status code 303 doesn't match the actual status code 200.
('content-length', '0')
('content-type', 'text; charset=utf-8')
('date', 'Sat, 17 Jan 2015 13:30:54 GMT')
('server', 'Werkzeug/0.9.6 Python/3.4.0')"
if [[ "$TEST_5" != "$TEST_5_DES" ]]
then
echo -e "Test 5 failed.\n$TEST_5"
exit 1
fi
if imprimatur tests/5/test.py > /dev/null
then
echo "Test 5 should fail, but it returned success."
exit 1
fi
echo "Passed Test 5"
if imprimatur tests/6/test.py > /dev/null
then
echo "Test 6 should fail, but it returned success."
exit 1
fi
echo "Passed Test 6"
TEST_7="$(imprimatur tests/7/test.py)"
TEST_7_DES_1="Name: Invalid regex
Request: http://localhost:5000/text_2
Problem with regex: unexpected end of regular expression"
TEST_7_DES_2="Name: Invalid regex
Request: http://localhost:5000/text_2
Problem with regex: unterminated character set at position 0"
if [[ "$TEST_7" != "$TEST_7_DES_1" && "$TEST_7" != "$TEST_7_DES_2" ]]
then
echo -e "Test 7 failed.\n$TEST_7"
exit 1
fi
if imprimatur tests/7/test.py > /dev/null
then
echo "Test 7 should fail, but it returned success."
exit 1
fi
echo "Passed Test 7"
echo "Passed All!!"