-
-
Notifications
You must be signed in to change notification settings - Fork 393
test: add smoke tests for caddy and unix sockets #861
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Xe
wants to merge
9
commits into
main
Choose a base branch
from
Xe/smoke-test/caddy-and-unix-socket
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7ca45f7
test: adapt caddy testing environment into a smoke test
Xe eacc001
fix(cmd/anubis): ignore errors for unix socket chmod
Xe 7cfefcd
test: make unix-socket-xff into a smoke test
Xe 950ec24
ci: enable caddy and unix-socket-xff tests
Xe 06122fc
chore(devcontainer): put node_modules in a volume
Xe a47e781
test(caddy): fix automated testing
Xe cf510ee
chore: spelling
Xe b320af7
test(caddy): fix automated testing?
Xe b12c594
test(caddy): why are you failing?
Xe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,9 +1,10 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| pwd | ||
| sudo chown -R vscode:vscode ./node_modules | ||
|
|
||
| npm ci & | ||
| go mod download & | ||
| go install ./utils/cmd/... & | ||
| go install mvdan.cc/sh/v3/cmd/shfmt@latest & | ||
|
|
||
| wait |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,10 @@ | ||
| bots: | ||
| - name: challenge | ||
| user_agent_regex: Mozilla | ||
| action: WEIGH | ||
| weight: | ||
| adjust: 10 | ||
|
|
||
| status_codes: | ||
| CHALLENGE: 401 | ||
| DENY: 403 |
This file contains hidden or 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 hidden or 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 hidden or 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,27 @@ | ||
| async function testWithUserAgent(userAgent) { | ||
| const statusCode = | ||
| await fetch("https://caddy.local.cetacean.club:8443/reqmeta", { | ||
| headers: { | ||
| "User-Agent": userAgent, | ||
| } | ||
| }) | ||
| .then(resp => resp.status); | ||
| return statusCode; | ||
| } | ||
|
|
||
| const codes = { | ||
| Mozilla: await testWithUserAgent("Mozilla"), | ||
| curl: await testWithUserAgent("curl"), | ||
| } | ||
|
|
||
| const expected = { | ||
| Mozilla: 401, | ||
| curl: 200, | ||
| }; | ||
|
|
||
| console.log("Mozilla:", codes.Mozilla); | ||
| console.log("curl: ", codes.curl); | ||
|
|
||
| if (JSON.stringify(codes) !== JSON.stringify(expected)) { | ||
| throw new Error(`wanted ${JSON.stringify(expected)}, got: ${JSON.stringify(codes)}`); | ||
| } |
This file contains hidden or 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,17 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -x | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| source ../lib/lib.sh | ||
|
|
||
| build_anubis_ko | ||
|
|
||
| docker compose up -d --build | ||
|
|
||
| export NODE_TLS_REJECT_UNAUTHORIZED=0 | ||
|
|
||
| sleep 2 | ||
|
|
||
| backoff-retry node test.mjs |
This file contains hidden or 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,54 @@ | ||
| REPO_ROOT=$(git rev-parse --show-toplevel) | ||
| (cd $REPO_ROOT && go install ./utils/cmd/...) | ||
|
|
||
| function cleanup() { | ||
| pkill -P $$ | ||
|
|
||
| if [ -f "docker-compose.yaml" ]; then | ||
| docker compose down | ||
| fi | ||
| } | ||
|
|
||
| trap cleanup EXIT SIGINT | ||
|
|
||
| function build_anubis_ko() { | ||
| ( | ||
| cd ../.. && | ||
| VERSION=devel ko build \ | ||
| --platform=all \ | ||
| --base-import-paths \ | ||
| --tags="latest" \ | ||
| --image-user=1000 \ | ||
| --image-annotation="" \ | ||
| --image-label="" \ | ||
| ./cmd/anubis \ | ||
| --local | ||
| ) | ||
| } | ||
|
|
||
| function mint_cert() { | ||
| if [ "$#" -ne 1 ]; then | ||
| echo "Usage: mint_cert <domain.name>" | ||
| fi | ||
|
|
||
| domainName="$1" | ||
|
|
||
| # If the transient local TLS certificate doesn't exist, mint a new one | ||
| if [ ! -f "../pki/${domainName}/cert.pem" ]; then | ||
| # Subshell to contain the directory change | ||
| ( | ||
| cd ../pki && | ||
| mkdir -p "${domainName}" && | ||
| # Try using https://github.com/FiloSottile/mkcert for better DevEx, | ||
| # but fall back to using https://github.com/jsha/minica in case | ||
| # you don't have that installed. | ||
| ( | ||
| mkcert \ | ||
| --cert-file ./"${domainName}"/cert.pem \ | ||
| --key-file ./"${domainName}"/key.pem \ | ||
| "${domainName}" || | ||
| go tool minica -domains "${domainName}" | ||
| ) | ||
| ) | ||
| fi | ||
| } |
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,33 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| source ../lib/lib.sh | ||
|
|
||
| mint_cert "relayd.local.cetacean.club" | ||
|
|
||
| # Build static assets | ||
| (cd ../.. && npm ci && npm run assets) | ||
|
|
||
| # Spawn three jobs: | ||
|
|
||
| # HTTP daemon that listens over a unix socket (implicitly ./unixhttpd.sock) | ||
| go run ../cmd/unixhttpd & | ||
|
|
||
| # A copy of Anubis, specifically for the current Git checkout | ||
| go tool anubis \ | ||
| --bind=./anubis.sock \ | ||
| --bind-network=unix \ | ||
| --socket-mode=0700 \ | ||
| --policy-fname=../anubis_configs/aggressive_403.yaml \ | ||
| --target=unix://$(pwd)/unixhttpd.sock & | ||
|
|
||
| # A simple TLS terminator that forwards to Anubis, which will forward to | ||
| # unixhttpd | ||
| go run ../cmd/relayd \ | ||
| --proxy-to=unix://./anubis.sock \ | ||
| --cert-dir=../pki/relayd.local.cetacean.club & | ||
|
|
||
| export NODE_TLS_REJECT_UNAUTHORIZED=0 | ||
|
|
||
| backoff-retry node test.mjs |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.