Skip to content

Commit

Permalink
Add test(s) for caddy (#34470)
Browse files Browse the repository at this point in the history
🤖 generated for as part of [expanding package test
coverage](#13623)

Signed-off-by: Josh Wolf <[email protected]>
  • Loading branch information
joshrwolf authored Nov 19, 2024
1 parent 2b92752 commit 4ce0ad9
Showing 1 changed file with 97 additions and 3 deletions.
100 changes: 97 additions & 3 deletions caddy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,102 @@ update:
use-tag: true

test:
environment:
contents:
packages:
- curl
- netcat-openbsd
- procps
- coreutils
pipeline:
# AUTOGENERATED
- runs: |
- name: "Verify binary and version"
runs: |
caddy version
caddy --version
caddy --help
- name: "Check basic help output"
runs: |
caddy help
caddy list-modules
- name: "Test basic HTTP server"
uses: test/daemon-check-output
with:
setup: |
echo "http://localhost:2020 {
respond \"Hello, Wolfi!\"
}" > test.Caddyfile
start: caddy run --config test.Caddyfile
expected_output: "serving initial configuration"
error_strings: |
"msg":"error"
"level":"error"
"panic"
"fatal"
failed
Error:
error:
denied
- name: "Test static file serving"
uses: test/daemon-check-output
with:
setup: |
mkdir -p webroot
echo "Static Test" > webroot/test.txt
echo "http://localhost:2021 {
root * webroot
file_server
}" > static.Caddyfile
start: caddy run --config static.Caddyfile
expected_output: "serving initial configuration"
error_strings: |
"msg":"error"
"level":"error"
"panic"
"fatal"
failed
Error:
error:
denied
post: |
curl -s http://localhost:2021/test.txt | grep -q "Static Test"
- name: "Test module loading and functionality"
uses: test/daemon-check-output
with:
setup: |
cat <<EOF > modules.Caddyfile
http://localhost:2024 {
route /headers {
header Content-Type "text/plain"
respond "Headers Test"
}
route /reverse/* {
uri strip_prefix /reverse
reverse_proxy http://localhost:2024 {
header_up X-Real-IP {remote_host}
}
}
route /compress {
encode gzip
respond "Compression Test"
}
}
EOF
start: caddy run --config modules.Caddyfile
expected_output: "serving initial configuration"
error_strings: |
"msg":"error"
"level":"error"
"panic"
"fatal"
failed
Error:
error:
denied
post: |
# Test header module
curl -s -i http://localhost:2024/headers | grep -q "Content-Type: text/plain"
# Test reverse_proxy module
curl -s http://localhost:2024/reverse/headers | grep -q "Headers Test"
# Test compression module
curl -s -H "Accept-Encoding: gzip" http://localhost:2024/compress | grep -q "Compression Test"

0 comments on commit 4ce0ad9

Please sign in to comment.