-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_tests.sh
executable file
·129 lines (106 loc) · 2.18 KB
/
client_tests.sh
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
#!/bin/bash
# Client test script
echo "Running client test script\n\n"
echo "*** Running negative tests. All should fail ***"
echo "* Testing argument length *"
echo "No arguments ( four short )"
echo "./client"
./client > /dev/null
if [ $? -eq 255 ]
then
echo "Passed"
else
echo "Fail"
fi
echo
echo "One argument ( three short )"
echo "./client fake_host.com"
./client fake_host.com > /dev/null
if [ $? -eq 255 ]
then
echo "Passed"
else
echo "Fail"
fi
echo
echo "Two arguments ( two short )"
echo "./client fake_host.com bad-port"
./client fake_host.com bad-port > /dev/null
if [ $? -eq 255 ]
then
echo "Passed"
else
echo "Fail"
fi
echo
echo "Three arguments ( one short )"
echo "./client fake_host.com bad-port request"
./client fake_host.com bad-port request > /dev/null
if [ $? -eq 255 ]
then
echo "Passed"
else
echo "Fail"
fi
echo
echo "* Testing port input *"
echo "Check that only numeric values are accepted"
echo "./client fake_host.com bad-port request index.html"
./client fake_host.com bad-port request index.html > /dev/null
if [ $? -eq 255 ]
then
echo "Passed"
else
echo "Fail"
fi
echo
echo "Mixed type"
echo "./client fake_host.com bad-123 request index.html"
./client fake_host.com bad-123 request index.html > /dev/null
if [ $? -eq 255 ]
then
echo "Passed"
else
echo "Fail"
fi
echo
echo "* Testing request type *"
echo "This request does not exist"
echo "./client fake_host.com 80 bad_request index.html"
./client fake_host.com 80 bad_request index.html > /dev/null
if [ $? -eq 255 ]
then
echo "Passed"
else
echo "Fail"
fi
echo
echo "'1337' is not a real request"
echo "./client fake_host.com 80 1337 index.html"
./client fake_host.com 80 1337 index.html > /dev/null
if [ $? -eq 255 ]
then
echo "Passed"
else
echo "Fail"
fi
echo
echo "Requests method names should be in all caps"
echo "./client fake_host.com 80 put index.html"
./client fake_host.com 80 put index.html > /dev/null
if [ $? -eq 255 ]
then
echo "Passed"
else
echo "Fail"
fi
echo
echo "./client fake_host.com 80 get index.html"
./client fake_host.com 80 get index.html > /dev/null
if [ $? -eq 255 ]
then
echo "Passed"
else
echo "Fail"
fi
echo