-
Notifications
You must be signed in to change notification settings - Fork 74
/
test.sh
executable file
·105 lines (87 loc) · 3.29 KB
/
test.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
#!/usr/bin/env bats
TEST_URL=${TEST_URL:-http://127.0.0.1:4567/}
FIRST_LINE="<root first=\"1\" second=\"2\" third=\"\">"
OOB_HOST=${OOB_HOST:-localhost:8000}
unset PYTHONWARNINGS
@test "Help: works" {
run poetry run xcat -- --help
[ "$status" -eq 0 ]
}
@test "Detect IP: works" {
run poetry run xcat -- ip
[ "$status" -eq 0 ]
}
@test "Injections: works" {
run poetry run xcat -- injections
[ "$status" -eq 0 ]
[ $(echo "${output}" | grep -c "Supports 10 injections:") -ne "0" ]
}
@test "Features: xversion 1 works" {
run poetry run xcat -- detect "${TEST_URL}" query xversion=1.0 query=Rogue --true-string=Lawyer
[ "$status" -eq 0 ]
}
@test "Features: xversion 2 works" {
run poetry run xcat -- detect "${TEST_URL}" query xversion=2.0 query=Rogue --true-string=Lawyer
[ "$status" -eq 0 ]
}
@test "Features: xversion 3 works" {
run poetry run xcat -- detect "${TEST_URL}" query xversion=3.0 query=Rogue --true-string=Lawyer
[ "$status" -eq 0 ]
}
@test "Features: OOB" {
run poetry run xcat -- detect "${TEST_URL}" query xversion=3.0 query=Rogue --true-string=Lawyer --oob=${OOB_HOST}
[ "$status" -eq 0 ]
[ $(echo ${output} | grep -c "oob-http: True") -eq "1" ]
}
@test "Run: Simple" {
run poetry run xcat -- run "${TEST_URL}" query query=Rogue --true-string=Lawyer
[ "$status" -eq 0 ]
[ $(echo "${output}" | grep -c "${FIRST_LINE}") -ne "0" ]
}
@test "Run: without normalization" {
run poetry run xcat -- run "${TEST_URL}" query query=Rogue --true-string=Lawyer --disable=normalize-space
[ "$status" -eq 0 ]
[ $(echo "${output}" | grep -c "${FIRST_LINE}") -ne "0" ]
}
@test "Run: Without codepoint search" {
run poetry run xcat -- run "${TEST_URL}" query query=Rogue --true-string=Lawyer --disable=codepoint-search
[ "$status" -eq 0 ]
[ $(echo "${output}" | grep -c "${FIRST_LINE}") -ne "0" ]
}
@test "Run: Without codepoint and normalize" {
run poetry run xcat -- run "${TEST_URL}" query query=Rogue --true-string=Lawyer --disable=codepoint-search,normalize-space
[ "$status" -eq 0 ]
[ $(echo "${output}" | grep -c "${FIRST_LINE}") -ne "0" ]
}
@test "Run: With OOB server" {
run poetry run xcat -- run "${TEST_URL}" query query=Rogue --true-string=Lawyer --oob=${OOB_HOST}
[ "$status" -eq 0 ]
[ $(echo "${output}" | grep -c "${FIRST_LINE}") -ne "0" ]
}
@test "Run: Headers file" {
cat <<EOF > $BATS_TMPDIR/headers
Cookie: abcdef
SomeHeader: abc
EOF
run poetry run xcat -- run "${TEST_URL}" query query=Rogue --true-string=Lawyer --headers=$BATS_TMPDIR/headers
[ "$status" -eq 0 ]
[ $(echo "${output}" | grep -c "${FIRST_LINE}") -ne "0" ]
}
@test "Run: Headers file - Invalid" {
cat <<EOF > $BATS_TMPDIR/headers
Cookie abcdef
EOF
run poetry run xcat -- run "${TEST_URL}" query query=Rogue --true-string=Lawyer --headers=$BATS_TMPDIR/headers
[ "$(echo \"${output}\" | grep -c "Not a valid header line")" -ne "0" ]
}
@test "Run: POST" {
run poetry run xcat -- run "${TEST_URL}" query query=Rogue --true-string=Lawyer -m POST -e form
[ "$status" -eq 0 ]
[ $(echo "${output}" | grep -c "${FIRST_LINE}") -ne "0" ]
}
@test "Run: Fast mode" {
run poetry run xcat -- run "${TEST_URL}" query query=Rogue --true-string=Lawyer --fast
[ "$status" -eq 0 ]
[ $(echo "${output}" | grep -c "${FIRST_LINE}") -ne "0" ]
[ $(echo "${output}" | grep -c "more characters)") -ne "0" ]
}