-
Notifications
You must be signed in to change notification settings - Fork 7
/
generate_test_responses.sh
executable file
·133 lines (120 loc) · 3.67 KB
/
generate_test_responses.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
129
130
131
132
#!/usr/bin/env bash
if [ -z $HIBP_KEY ]
then
echo Please set environment variable HIBP_KEY with your API key
echo Get one at https://haveibeenpwned.com/API/Key and support the project
exit 1
fi
BASE_URI="https://api.pwnedpasswords.com"
#BASE_URI="https://haveibeenpwned.com/api/v3"
HEADER_UA="User-Agent=DragonBe\Hibp-0.0.2%20Composer\1.6.4%20PHP\7.3"
HEADER_ACCEPT="Accept=application/vnd.haveibeenpwned.v3+json"
HEADER_KEY="hibp-api-key=$HIBP_KEY"
echo Writing test mock 'new1_password.txt'
echo "GET $BASE_URI/range/071CD" > tests/_files/new1_password.txt
echo "" >> tests/_files/new1_password.txt
curl \
--silent \
--show-error \
--request GET \
--include \
--header $HEADER_UA \
--header $HEADER_ACCEPT \
--header $HEADER_KEY \
$BASE_URI/range/071CD >> tests/_files/new1_password.txt
echo Writing test mock 'new2_passwords.txt'
echo "GET $BASE_URI/range/6F8FE" > tests/_files/new2_password.txt
echo "" >> tests/_files/new2_password.txt
curl \
--silent \
--show-error \
--request GET \
--include \
--header $HEADER_UA \
--header $HEADER_ACCEPT \
--header $HEADER_KEY \
$BASE_URI/range/6F8FE >> tests/_files/new2_password.txt
echo Writing test mock 'new3_passwords.txt'
echo "GET $BASE_URI/range/B23DF" > tests/_files/new3_password.txt
echo "" >> tests/_files/new3_password.txt
curl \
--silent \
--show-error \
--request GET \
--include \
--header $HEADER_UA \
--header $HEADER_ACCEPT \
--header $HEADER_KEY \
$BASE_URI/range/B23DF >> tests/_files/new3_password.txt
echo Writing test mock 'pwned1_password.txt'
echo "GET $BASE_URI/range/5BAA6" > tests/_files/pwned1_password.txt
echo "" >> tests/_files/pwned1_password.txt
curl \
--silent \
--show-error \
--request GET \
--include \
--header $HEADER_UA \
--header $HEADER_ACCEPT \
--header $HEADER_KEY \
$BASE_URI/range/5BAA6 >> tests/_files/pwned1_password.txt
echo Writing test mock 'pwned2_password.txt'
echo "GET $BASE_URI/range/5EAB7" > tests/_files/pwned2_password.txt
echo "" >> tests/_files/pwned2_password.txt
curl \
--silent \
--show-error \
--request GET \
--include \
--header $HEADER_UA \
--header $HEADER_ACCEPT \
--header $HEADER_KEY \
$BASE_URI/range/5EAB7 >> tests/_files/pwned2_password.txt
echo Writing test mock 'pwned3_password.txt'
echo "GET $BASE_URI/range/D033E" > tests/_files/pwned3_password.txt
echo "" >> tests/_files/pwned3_password.txt
curl \
--silent \
--show-error \
--request GET \
--include \
--header $HEADER_UA \
--header $HEADER_ACCEPT \
--header $HEADER_KEY \
$BASE_URI/range/D033E >> tests/_files/pwned3_password.txt
echo Writing test mock 'invalid1.txt'
echo "GET $BASE_URI/range" > tests/_files/invalid1.txt
echo "" >> tests/_files/invalid1.txt
curl \
--silent \
--show-error \
--request GET \
--include \
--header $HEADER_UA \
--header $HEADER_ACCEPT \
--header $HEADER_KEY \
$BASE_URI/range >> tests/_files/invalid1.txt
echo Writing test mock 'invalid2.txt'
echo "GET $BASE_URI/range/" > tests/_files/invalid2.txt
echo "" >> tests/_files/invalid2.txt
curl \
--silent \
--show-error \
--request GET \
--include \
--header $HEADER_UA \
--header $HEADER_ACCEPT \
--header $HEADER_KEY \
$BASE_URI/range/ >> tests/_files/invalid2.txt
echo Writing test mock 'invalid3.txt'
echo "GET $BASE_URI/range/GFEDC" > tests/_files/invalid3.txt
echo "" >> tests/_files/invalid3.txt
curl \
--silent \
--show-error \
--request GET \
--include \
--header $HEADER_UA \
--header $HEADER_ACCEPT \
--header $HEADER_KEY \
$BASE_URI/range/GFEDC >> tests/_files/invalid3.txt