diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 6c609b5e..d17a521a 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -34,14 +34,14 @@ jobs: uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6 - name: Initialize CodeQL - uses: github/codeql-action/init@e12f0178983d466f2f6028f5cc7a6d786fd97f4b # v4 + uses: github/codeql-action/init@fdbfb4d2750291e159f0156def62b853c2798ca2 # v4 with: languages: ${{ matrix.language }} - name: Autobuild - uses: github/codeql-action/autobuild@e12f0178983d466f2f6028f5cc7a6d786fd97f4b # v4 + uses: github/codeql-action/autobuild@fdbfb4d2750291e159f0156def62b853c2798ca2 # v4 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@e12f0178983d466f2f6028f5cc7a6d786fd97f4b # v4 + uses: github/codeql-action/analyze@fdbfb4d2750291e159f0156def62b853c2798ca2 # v4 with: category: "/language:${{ matrix.language }}" diff --git a/backend/cmd/seed/main.go b/backend/cmd/seed/main.go index 5b12b34c..68a16688 100644 --- a/backend/cmd/seed/main.go +++ b/backend/cmd/seed/main.go @@ -8,12 +8,12 @@ import ( "gorm.io/driver/sqlite" "gorm.io/gorm" - "github.com/Wikid82/CaddyProxyManagerPlus/backend/internal/models" + "github.com/Wikid82/charon/backend/internal/models" ) func main() { // Connect to database - db, err := gorm.Open(sqlite.Open("./data/cpm.db"), &gorm.Config{}) + db, err := gorm.Open(sqlite.Open("./data/charon.db"), &gorm.Config{}) if err != nil { log.Fatal("Failed to connect to database:", err) } @@ -152,7 +152,7 @@ func main() { settings := []models.Setting{ { Key: "app_name", - Value: "Caddy Proxy Manager+", + Value: "Charon", Type: "string", Category: "general", }, diff --git a/scripts/integration-test.sh b/scripts/integration-test.sh new file mode 100755 index 00000000..2ff8c7da --- /dev/null +++ b/scripts/integration-test.sh @@ -0,0 +1,77 @@ +#!/bin/bash +set -e + +# Configuration +API_URL="http://localhost:8080/api/v1" +ADMIN_EMAIL="admin@example.com" +ADMIN_PASSWORD="changeme" + +echo "Waiting for Charon to be ready..." +for i in $(seq 1 30); do + code=$(curl -s -o /dev/null -w "%{http_code}" $API_URL/health || echo "000") + if [ "$code" = "200" ]; then + echo "✅ Charon is ready!" + break + fi + echo "Attempt $i/30: health not ready (code=$code); waiting..." + sleep 2 +done + +if [ "$code" != "200" ]; then + echo "❌ Charon failed to start" + exit 1 +fi + +echo "Logging in..." +TOKEN=$(curl -s -X POST $API_URL/auth/login \ + -H "Content-Type: application/json" \ + -d "{\"email\":\"$ADMIN_EMAIL\",\"password\":\"$ADMIN_PASSWORD\"}" | jq -r .token) + +if [ -z "$TOKEN" ] || [ "$TOKEN" = "null" ]; then + echo "❌ Login failed" + exit 1 +fi +echo "✅ Login successful" + +echo "Creating Proxy Host..." +# We use 'whoami' as the forward host because they are on the same docker network +RESPONSE=$(curl -s -X POST $API_URL/proxy-hosts \ + -H "Authorization: Bearer $TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "domain_names": ["test.localhost"], + "forward_scheme": "http", + "forward_host": "whoami", + "forward_port": 80, + "access_list_id": "", + "certificate_id": "", + "ssl_forced": false, + "caching_enabled": false, + "block_exploits": false, + "allow_websocket_upgrade": true, + "http2_support": true, + "hsts_enabled": false, + "hsts_subdomains": false, + "locations": [] + }') + +ID=$(echo $RESPONSE | jq -r .uuid) +if [ -z "$ID" ] || [ "$ID" = "null" ]; then + echo "❌ Failed to create proxy host: $RESPONSE" + exit 1 +fi +echo "✅ Proxy Host created (ID: $ID)" + +echo "Testing Proxy..." +# We use Host header to route to the correct proxy host +# We hit localhost:80 (Caddy) which should route to whoami +HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -H "Host: test.localhost" http://localhost:80) +CONTENT=$(curl -s -H "Host: test.localhost" http://localhost:80) + +if [ "$HTTP_CODE" = "200" ] && echo "$CONTENT" | grep -q "Hostname:"; then + echo "✅ Proxy test passed! Content received from whoami." +else + echo "❌ Proxy test failed (Code: $HTTP_CODE)" + echo "Content: $CONTENT" + exit 1 +fi