Skip to content

Commit 2d31b85

Browse files
AnkanMisracodex
andcommitted
fix: harden authorization config and E2E cleanup
Co-authored-by: codex <codex@users.noreply.github.com>
1 parent 16977c9 commit 2d31b85

3 files changed

Lines changed: 6 additions & 1 deletion

File tree

gateway/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ func normalizePaygateAudience() error {
6969
if parsed.Scheme != "http" && parsed.Scheme != "https" {
7070
return fmt.Errorf("PAYGATE_AUDIENCE scheme must be http or https")
7171
}
72+
if parsed.Hostname() == "" {
73+
return fmt.Errorf("PAYGATE_AUDIENCE must have a non-empty host")
74+
}
7275
if parsed.User != nil {
7376
return fmt.Errorf("PAYGATE_AUDIENCE must not contain credentials")
7477
}

gateway/config_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func TestNormalizePaygateAudience(t *testing.T) {
4444
{name: "rejects query", value: "https://gateway.example.com?tenant=a", wantErr: "origin only"},
4545
{name: "rejects credentials", value: "https://user@gateway.example.com", wantErr: "credentials"},
4646
{name: "rejects unsupported scheme", value: "javascript://gateway.example.com", wantErr: "http or https"},
47+
{name: "rejects empty hostname", value: "https://:443", wantErr: "non-empty host"},
4748
}
4849

4950
for _, test := range tests {

run_e2e.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ E2E_TMP_DIR="$(mktemp -d)"
66

77
# Function to cleanup background processes on exit
88
cleanup() {
9+
local exit_code=$?
910
echo "Stopping services..."
1011
# Use a portable check for jobs since xargs -r is not available on all macOS versions
1112
if [ -n "$(jobs -p)" ]; then
1213
jobs -p | xargs kill 2>/dev/null
1314
fi
1415
rm -rf "$E2E_TMP_DIR"
15-
exit
16+
exit "$exit_code"
1617
}
1718

1819
trap cleanup EXIT

0 commit comments

Comments
 (0)