forked from aHappyCamer/mlh-orientation-hackathon-project
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprod-test.sh
32 lines (27 loc) · 1.12 KB
/
prod-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
#! /usr/bin/env bash
assert (){
text=$1
string=$2
if [[ $text == *"$string"* ]];
then
echo "'$string': passed"
else
echo "'$string': not found in text:"
echo "$text"
exit 99
fi
}
username="$RANDOM" #$(shuf -n1 /usr/share/dict/words)
password="$RANDOM" #$(shuf -n1 /usr/share/dict/words)
wrongpassword="wrongPw"
homepage () { curl -s https://hackersportfolio.duckdns.org; }
register () { curl -s -d "username=$1&password=$2" -X POST https://hackersportfolio.duckdns.org/register; }
login () { curl -s -d "username=$1&password=$2" -X POST https://hackersportfolio.duckdns.org/login; }
assert "$(homepage)" "Linda"
assert "$(register "" "$password")" "Username is required."
assert "$(register "$username" "")" "Password is required."
assert "$(register "$username" "$password")" "User ${username} created successfully."
assert "$(register "$username" "$password")" "User ${username} is already registered."
assert "$(login "" "$password")" "Incorrect username."
assert "$(login "$username" "")" "Incorrect password."
assert "$(login "$username" "$password")" "Login Successful."