aboutsummaryrefslogtreecommitdiff
path: root/script/test-smoke.sh
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2022-02-01 17:55:14 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2022-02-01 17:55:14 +0100
commitf67029ce2af2f8870836d5bb908254d7fdbbe71b (patch)
tree62dd93eabf451766493bfdd637ff9e8840fdb410 /script/test-smoke.sh
parent2760f1cb17469b2fe625ee552a7a6074fa371eda (diff)
downloadgarage-f67029ce2af2f8870836d5bb908254d7fdbbe71b.tar.gz
garage-f67029ce2af2f8870836d5bb908254d7fdbbe71b.zip
Improve testing conf + test CORStest/cors-and-localhost
Diffstat (limited to 'script/test-smoke.sh')
-rwxr-xr-xscript/test-smoke.sh26
1 files changed, 23 insertions, 3 deletions
diff --git a/script/test-smoke.sh b/script/test-smoke.sh
index e6f1c6ea..2dcd69ec 100755
--- a/script/test-smoke.sh
+++ b/script/test-smoke.sh
@@ -353,6 +353,26 @@ EOF
rm /tmp/garage.test_multipart
rm /tmp/garage.test_multipart_reference
rm /tmp/garage.test_multipart_diff
+
+
+ echo "Test CORS endpoints"
+ garage -c /tmp/config.1.toml bucket website --allow eprouvette
+ aws s3api put-object --bucket eprouvette --key index.html
+ CORS='{"CORSRules":[{"AllowedHeaders":["*"],"AllowedMethods":["GET","PUT"],"AllowedOrigins":["*"]}]}'
+ aws s3api put-bucket-cors --bucket eprouvette --cors-configuration $CORS
+ [ `aws s3api get-bucket-cors --bucket eprouvette | jq -c` == $CORS ]
+
+ curl -s -i -H 'Origin: http://example.com' http://eprouvette.web.garage.localhost:3921 | grep access-control-allow-origin
+ curl -s -i -X OPTIONS -H 'Access-Control-Request-Method: PUT' -H 'Origin: http://example.com' http://eprouvette.web.garage.localhost:3921|grep access-control-allow-methods
+ curl -s -i -X OPTIONS -H 'Access-Control-Request-Method: DELETE' -H 'Origin: http://example.com' http://eprouvette.web.garage.localhost:3921 |grep '403 Forbidden'
+
+ #@TODO we may want to test the S3 endpoint but we need to handle authentication, which is way more complex.
+
+ aws s3api delete-bucket-cors --bucket eprouvette
+ ! [ -s `aws s3api get-bucket-cors --bucket eprouvette` ]
+ curl -s -i -X OPTIONS -H 'Access-Control-Request-Method: PUT' -H 'Origin: http://example.com' http://eprouvette.web.garage.localhost:3921|grep '403 Forbidden'
+ aws s3api delete-object --bucket eprouvette --key index.html
+ garage -c /tmp/config.1.toml bucket website --deny eprouvette
fi
rm /tmp/garage.{1..3}.{rnd,b64}
@@ -376,11 +396,11 @@ if [ -z "$SKIP_AWS" ]; then
echo "🧪 Website Testing"
echo "<h1>hello world</h1>" > /tmp/garage-index.html
aws s3 cp /tmp/garage-index.html s3://eprouvette/index.html
- [ `curl -s -o /dev/null -w "%{http_code}" --header "Host: eprouvette.garage.tld" http://127.0.0.1:3921/ ` == 404 ]
+ [ `curl -s -o /dev/null -w "%{http_code}" --header "Host: eprouvette.web.garage.localhost" http://127.0.0.1:3921/ ` == 404 ]
garage -c /tmp/config.1.toml bucket website --allow eprouvette
- [ `curl -s -o /dev/null -w "%{http_code}" --header "Host: eprouvette.garage.tld" http://127.0.0.1:3921/ ` == 200 ]
+ [ `curl -s -o /dev/null -w "%{http_code}" --header "Host: eprouvette.web.garage.localhost" http://127.0.0.1:3921/ ` == 200 ]
garage -c /tmp/config.1.toml bucket website --deny eprouvette
- [ `curl -s -o /dev/null -w "%{http_code}" --header "Host: eprouvette.garage.tld" http://127.0.0.1:3921/ ` == 404 ]
+ [ `curl -s -o /dev/null -w "%{http_code}" --header "Host: eprouvette.web.garage.localhost" http://127.0.0.1:3921/ ` == 404 ]
aws s3 rm s3://eprouvette/index.html
rm /tmp/garage-index.html
fi