Skip to content

Commit

Permalink
test: new caddy
Browse files Browse the repository at this point in the history
  • Loading branch information
scmmishra committed Aug 6, 2024
1 parent b44dcda commit c44ae9f
Showing 1 changed file with 33 additions and 7 deletions.
40 changes: 33 additions & 7 deletions internal/caddy/caddy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package caddy

import (
"errors"
"fmt"
"testing"

"github.com/scmmishra/slick-deploy/internal/config"
Expand Down Expand Up @@ -41,20 +42,45 @@ func TestConvertToCaddyfile(t *testing.T) {
{
Path: "/",
To: "http://localhost:{port}",
},
},
HeaderUp: []config.HeaderUp{
{
Name: "X-Real-IP",
Value: "{http.request.remote.host}",
HeaderUp: []config.HeaderUp{
{
Name: "X-Real-IP",
Value: "{http.request.remote.host}",
},
},
},
},
},
},
}

caddyfile := ConvertToCaddyfile(caddyCfg, 8080)
expectedCaddyfile := "{\n email [email protected]\n on_demand_tls {\n ask https://acme.example.com/directory\n interval 3600\n burst 13\n }\n}\n\nlocalhost {\n tls {\n internal\n }\n header_up X-Real-IP {http.request.remote.host}\n handle / {\n root * /usr/share/caddy\n }\n handle /healthz {\n respond \"OK\" 200\n }\n reverse_proxy / http://localhost:8080\n}\n\n"
fmt.Println(caddyfile)
expectedCaddyfile := `{
email [email protected]
on_demand_tls {
ask https://acme.example.com/directory
interval 3600
burst 13
}
}
localhost {
tls {
internal
}
handle / {
root * /usr/share/caddy
}
handle /healthz {
respond "OK" 200
}
reverse_proxy / http://localhost:8080 {
header_up X-Real-IP {http.request.remote.host}
}
}
`
assert.Equal(t, expectedCaddyfile, caddyfile)
}

Expand Down

0 comments on commit c44ae9f

Please sign in to comment.