(t *testing.T)
| 391 | } |
| 392 | |
| 393 | func TestHTTPSSetupAutoModeRejectsLocalhost(t *testing.T) { |
| 394 | configPath := writeHTTPSSetupTempConfig(t, sampleHTTPSConfig) |
| 395 | |
| 396 | input := strings.Join([]string{ |
| 397 | "2", |
| 398 | "localhost", |
| 399 | "", |
| 400 | }, "\n") |
| 401 | |
| 402 | output, err := runHTTPSSetupExpectError(t, configPath, input, nil) |
| 403 | if err == nil { |
| 404 | t.Fatalf("https-setup.sh unexpectedly succeeded for localhost") |
| 405 | } |
| 406 | if !strings.Contains(output, "Automatic HTTPS requires a public hostname") { |
| 407 | t.Fatalf("https-setup.sh output did not explain invalid hostname:\n%s", output) |
| 408 | } |
| 409 | |
| 410 | updated := readHTTPSSetupConfig(t, configPath) |
| 411 | if updated != sampleHTTPSConfig { |
| 412 | t.Fatalf("https-setup config changed after invalid auto mode input:\n%s", updated) |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | func TestHTTPSSetupAutoModeNormalizesPastedHostname(t *testing.T) { |
| 417 | configPath := writeHTTPSSetupTempConfig(t, sampleHTTPSConfig) |
nothing calls this directly
no test coverage detected