Skip to content

Commit

Permalink
Add static robots.txt to test serving static files from public/
Browse files Browse the repository at this point in the history
  • Loading branch information
clue committed Mar 4, 2024
1 parent fdf062c commit 15a5c74
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ jobs:
php-version: 8.3
- run: composer install -d tests/integration/
- run: docker build -f tests/integration/${{ matrix.dockerfile }} tests/integration/
- run: docker run -d -p 8080:8080 -v "$PWD/composer.json":/app/composer.json -v "$PWD/LICENSE":/app/LICENSE $(docker images -q | head -n1)
- run: docker run -d -p 8080:8080 -v "$PWD/composer.json":/app/composer.json $(docker images -q | head -n1)
- run: bash tests/await.sh
- run: bash tests/integration.bash
- run: docker stop $(docker ps -qn1)
Expand Down
10 changes: 5 additions & 5 deletions tests/integration.bash
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ out=$(curl -v $base/users 2>&1); match "HTTP/.* 404"
out=$(curl -v $base/users/ 2>&1); match "HTTP/.* 404"
out=$(curl -v $base/users/a/b 2>&1); match "HTTP/.* 404"

out=$(curl -v $base/LICENSE 2>&1); match "HTTP/.* 200" && match -iP "Content-Type: text/plain[\r\n]"
out=$(curl -v $base/robots.txt 2>&1); match "HTTP/.* 200" && match -iP "Content-Type: text/plain[\r\n]"
out=$(curl -v $base/source 2>&1); match -i "Location: /source/" && match -iP "Content-Type: text/html; charset=utf-8[\r\n]"
out=$(curl -v $base/source/ 2>&1); match "HTTP/.* 200"
out=$(curl -v $base/source/composer.json 2>&1); match "HTTP/.* 200" && match -iP "Content-Type: application/json[\r\n]"
out=$(curl -v $base/source/LICENSE 2>&1); match "HTTP/.* 200" && match -iP "Content-Type: text/plain[\r\n]"
out=$(curl -v $base/source/LICENSE/ 2>&1); match -i "Location: ../LICENSE" && match -iP "Content-Type: text/html; charset=utf-8[\r\n]"
out=$(curl -v $base/source/LICENSE// 2>&1); match "HTTP/.* 404"
out=$(curl -v $base/source//LICENSE 2>&1); match "HTTP/.* 404"
out=$(curl -v $base/source/public/robots.txt 2>&1); match "HTTP/.* 200" && match -iP "Content-Type: text/plain[\r\n]"
out=$(curl -v $base/source/public/robots.txt/ 2>&1); match -i "Location: ../robots.txt" && match -iP "Content-Type: text/html; charset=utf-8[\r\n]"
out=$(curl -v $base/source/public/robots.txt// 2>&1); match "HTTP/.* 404"
out=$(curl -v $base/source//public/robots.txt 2>&1); match "HTTP/.* 404"
out=$(curl -v $base/source/public 2>&1); match -i "Location: public/" && match -iP "Content-Type: text/html; charset=utf-8[\r\n]"
out=$(curl -v $base/source/invalid 2>&1); match "HTTP/.* 404"
out=$(curl -v $base/source/bin%00ary 2>&1); match "HTTP/.* 40[40]" # expects 404, but not processed with nginx (400) and Apache (404)
Expand Down
1 change: 0 additions & 1 deletion tests/integration/LICENSE

This file was deleted.

2 changes: 1 addition & 1 deletion tests/integration/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
);
});

$app->get('/LICENSE', new FrameworkX\FilesystemHandler(__DIR__ . '/../LICENSE'));
$app->get('/robots.txt', new FrameworkX\FilesystemHandler(__DIR__ . '/robots.txt'));
$app->get('/source/{path:.*}', new FrameworkX\FilesystemHandler(__DIR__ . '/../'));
$app->redirect('/source', '/source/');

Expand Down
2 changes: 2 additions & 0 deletions tests/integration/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
User-agent: *
Disallow: /

0 comments on commit 15a5c74

Please sign in to comment.