MCPcopy
hub / github.com/caddyserver/caddy / TestInvalidPrefix

Function TestInvalidPrefix

caddytest/integration/caddyfile_test.go:134–177  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

132}
133
134func TestInvalidPrefix(t *testing.T) {
135 type testCase struct {
136 config, expectedError string
137 }
138
139 failureCases := []testCase{
140 {
141 config: `wss://localhost`,
142 expectedError: `the scheme wss:// is only supported in browsers; use https:// instead`,
143 },
144 {
145 config: `ws://localhost`,
146 expectedError: `the scheme ws:// is only supported in browsers; use http:// instead`,
147 },
148 {
149 config: `someInvalidPrefix://localhost`,
150 expectedError: "unsupported URL scheme someinvalidprefix://",
151 },
152 {
153 config: `h2c://localhost`,
154 expectedError: `unsupported URL scheme h2c://`,
155 },
156 {
157 config: `localhost, wss://localhost`,
158 expectedError: `the scheme wss:// is only supported in browsers; use https:// instead`,
159 },
160 {
161 config: `localhost {
162 reverse_proxy ws://localhost"
163 }`,
164 expectedError: `the scheme ws:// is only supported in browsers; use http:// instead`,
165 },
166 {
167 config: `localhost {
168 reverse_proxy someInvalidPrefix://localhost"
169 }`,
170 expectedError: `unsupported URL scheme someinvalidprefix://`,
171 },
172 }
173
174 for _, failureCase := range failureCases {
175 caddytest.AssertLoadError(t, failureCase.config, "caddyfile", failureCase.expectedError)
176 }
177}
178
179func TestValidPrefix(t *testing.T) {
180 type testCase struct {

Callers

nothing calls this directly

Calls 1

AssertLoadErrorFunction · 0.92

Tested by

no test coverage detected