-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #136 from clue-labs/tests
Clean up and improve structure of integration tests
- Loading branch information
Showing
6 changed files
with
123 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ jobs: | |
coverage: none | ||
- run: make | ||
- run: make served | ||
- run: bash tests/await.bash http://clue.localhost/ | ||
- run: make test | ||
- run: git config --global user.name "GitHub Actions" && git config --global user.email "[email protected]" | ||
- run: git config --global url."https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/".insteadOf "https://github.com/" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
# @copyright Copyright (c) 2024 Christian Lück, taken from https://github.com/clue/framework-x/pull/3 with permission | ||
|
||
base=${1:-http://clue.localhost/} | ||
base=${base%/} | ||
|
||
for i in {1..600} | ||
do | ||
out=$(curl -v -X PROBE $base/ 2>&1) && exit 0 || echo -n . | ||
sleep 0.1 | ||
done | ||
|
||
echo | ||
echo "$out" | ||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#!/bin/bash | ||
|
||
# run with base url argument like "http://clue.localhost" or "https://user:[email protected]" | ||
base=${1:-http://clue.localhost/} | ||
base=${base%/} | ||
|
||
# base url with any userinfo removed | ||
redir=$(echo $base | sed "s,://.*@,://,g") | ||
|
||
n=0 | ||
curl() { | ||
out=$($(which curl) "$@" 2>&1); | ||
} | ||
match() { | ||
n=$[$n+1] | ||
echo "$out" | grep "$@" >/dev/null && echo -n . || \ | ||
(echo ""; echo "Error in test $n: Unable to \"grep $@\" this output:"; echo "$out"; exit 1) || exit 1 | ||
} | ||
|
||
curl -v $base/ | ||
match "HTTP/.* 200" | ||
match -iP "Content-Type: text/html[;\r\n]" | ||
|
||
curl -v $base/index.html | ||
match "HTTP/.* 302" | ||
match -iP "Location: $redir/[\r\n]" | ||
|
||
curl -v $base/index.html/ | ||
match "HTTP/.* 404" | ||
|
||
curl -v $base/index | ||
match "HTTP/.* 404" | ||
|
||
curl -v $base/blog | ||
match "HTTP/.* 200" | ||
match -iP "Content-Type: text/html[;\r\n]" | ||
|
||
curl -v $base/blog.html | ||
match "HTTP/.* 302" | ||
match -iP "Location: $redir/blog[\r\n]" | ||
|
||
curl -v $base/blog/ | ||
match "HTTP/.* 302" | ||
match -iP "Location: $redir/blog[\r\n]" | ||
|
||
curl -v $base/2019 | ||
match "HTTP/.* 302" | ||
match -iP "Location: $redir/blog#2019[\r\n]" | ||
|
||
curl -v $base/2019/ | ||
match "HTTP/.* 302" | ||
match -iP "Location: $redir/blog#2019[\r\n]" | ||
|
||
curl -v $base/2000 | ||
match "HTTP/.* 404" | ||
|
||
curl -v $base/2000/ | ||
match "HTTP/.* 404" | ||
|
||
curl -v $base/2018/hello-world | ||
match "HTTP/.* 200" | ||
match -iP "Content-Type: text/html[;\r\n]" | ||
|
||
curl -v $base/2018/hello-world/ | ||
match "HTTP/.* 302" | ||
match -iP "Location: $redir/2018/hello-world[\r\n]" | ||
|
||
curl -v $base/contact | ||
match "HTTP/.* 200" | ||
match -iP "Content-Type: text/html[;\r\n]" | ||
|
||
curl -v $base/contact -X POST | ||
match "HTTP/.* 400" | ||
|
||
curl -v $base/contact --data name=A --data [email protected] --data company=ACME --data budget=None --data message="Let's get in touch!" | ||
match "HTTP/.* 400" # name length | ||
|
||
curl -v $base/contact --data name=Alice --data email=alice --data company=ACME --data budget=None --data message="Let's get in touch!" | ||
match "HTTP/.* 400" # email invalid | ||
|
||
curl -v $base/contact --data name=Alice --data [email protected] --data company=ACME --data budget=A --data message="Let's get in touch!" | ||
match "HTTP/.* 400" # budget invalid | ||
|
||
# curl -v $base/contact --data name=Alice --data [email protected] --data company= --data budget=Yes --data message="Let's get in touch!!" | ||
# match "HTTP/.* 302" # valid without company | ||
|
||
# curl -v $base/contact --data name=Alice --data [email protected] --data company=ACME --data budget=Yes --data message="Let's get in touch!!" | ||
# match "HTTP/.* 302" # valid with company | ||
|
||
curl -v $base/contact.html | ||
match "HTTP/.* 302" | ||
match -iP "Location: $redir/contact[\r\n]" | ||
|
||
curl -v $base/contact.php | ||
match "HTTP/.* 302" | ||
match -iP "Location: $redir/contact[\r\n]" | ||
|
||
curl -v $base/contact/ | ||
match "HTTP/.* 302" | ||
match -iP "Location: $redir/contact[\r\n]" | ||
|
||
echo "OK ($n)" |