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

Function TestRejectAnonymousImportBlock

caddyconfig/caddyfile/parse_test.go:888–911  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

886}
887
888func TestRejectAnonymousImportBlock(t *testing.T) {
889 p := testParser(`
890 (site) {
891 http://{args[0]} https://{args[0]} {
892 {block}
893 }
894 }
895
896 import site test.domain {
897 {
898 header_up Host {host}
899 header_up X-Real-IP {remote_host}
900 }
901 }
902 `)
903 _, err := p.parseAll()
904 if err == nil {
905 t.Fatal("Expected an error, but got nil")
906 }
907 expected := "anonymous blocks are not supported"
908 if !strings.HasPrefix(err.Error(), "anonymous blocks are not supported") {
909 t.Errorf("Expected error to start with '%s' but got '%v'", expected, err)
910 }
911}
912
913func TestAcceptSiteImportWithBraces(t *testing.T) {
914 p := testParser(`

Callers

nothing calls this directly

Calls 3

testParserFunction · 0.85
parseAllMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected