| 1 | package integrationscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/caddytest/integration`/ |
| 2 | |
| 3 | import ( |
| 4 | "bytesscip-go gomod github.com/golang/go/src go1.25.1 bytes/" |
| 5 | "net/httpscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/" |
| 6 | "testingscip-go gomod github.com/golang/go/src go1.25.1 testing/" |
| 7 | |
| 8 | "github.com/caddyserver/caddy/v2/caddytestscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/caddytest`/" |
| 9 | ) |
| 10 | |
| 11 | func TestBrowsescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/caddytest/integration`/TestBrowse().(t *testingscip-go gomod github.com/golang/go/src go1.25.1 testing/.Tscip-go gomod github.com/golang/go/src go1.25.1 testing/T#) { |
| 12 | tester := caddytestscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/caddytest`/.NewTesterscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/caddytest`/NewTester().(t) |
| 13 | tester.InitServerscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/caddytest`/Tester#InitServer().(` |
| 14 | { |
| 15 | skip_install_trust |
| 16 | admin localhost:2999 |
| 17 | http_port 9080 |
| 18 | https_port 9443 |
| 19 | grace_period 1ns |
| 20 | } |
| 21 | http://localhost:9080 { |
| 22 | file_server browse |
| 23 | } |
| 24 | `, "caddyfile") |
| 25 | |
| 26 | req, err := httpscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/.NewRequestscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/NewRequest().(httpscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/.MethodGetscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/MethodGet., "http://localhost:9080/", nil) |
| 27 | if err != nil { |
| 28 | t.Failscip-go gomod github.com/golang/go/src go1.25.1 testing/common#Fail().() |
| 29 | return |
| 30 | } |
| 31 | tester.AssertResponseCodescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/caddytest`/Tester#AssertResponseCode().(req, 200) |
| 32 | } |
| 33 | |
| 34 | func TestRespondWithJSONscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/caddytest/integration`/TestRespondWithJSON().(t *testingscip-go gomod github.com/golang/go/src go1.25.1 testing/.Tscip-go gomod github.com/golang/go/src go1.25.1 testing/T#) { |
| 35 | tester := caddytestscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/caddytest`/.NewTesterscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/caddytest`/NewTester().(t) |
| 36 | tester.InitServerscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/caddytest`/Tester#InitServer().(` |
| 37 | { |
| 38 | skip_install_trust |
| 39 | admin localhost:2999 |
| 40 | http_port 9080 |
| 41 | https_port 9443 |
| 42 | grace_period 1ns |
| 43 | } |
| 44 | localhost { |
| 45 | respond {http.request.body} |
| 46 | } |
| 47 | `, "caddyfile") |
| 48 | |
| 49 | res, _ := tester.AssertPostResponseBodyscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/caddytest`/Tester#AssertPostResponseBody().("https://localhost:9443/", |
| 50 | nil, |
| 51 | bytesscip-go gomod github.com/golang/go/src go1.25.1 bytes/.NewBufferStringscip-go gomod github.com/golang/go/src go1.25.1 bytes/NewBufferString().(`{ |
| 52 | "greeting": "Hello, world!" |
| 53 | }`), 200, `{ |
| 54 | "greeting": "Hello, world!" |
| 55 | }`) |
| 56 | if res.Headerscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Response#Header..Getscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Header#Get().("Content-Type") != "application/json" { |
| 57 | t.Errorfscip-go gomod github.com/golang/go/src go1.25.1 testing/common#Errorf().("expected Content-Type to be application/json, but was %s", res.Headerscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Response#Header..Getscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Header#Get().("Content-Type")) |
| 58 | } |
| 59 | } |