coredns-ldap/setup_test.go
2020-06-09 21:54:01 -05:00

33 lines
712 B
Go

package ldap
import (
"testing"
"github.com/caddyserver/caddy"
)
// TestSetup tests the various things that should be parsed by setup.
// Make sure you also test for parse errors.
func TestSetup(t *testing.T) {
tests := []struct {
body string
expectedError bool
}{
{`ldap`, false},
{`ldap :`, true},
{`ldap {
ldap_url ldap://example.com
base_dn ou=ae-dir
filter (objectClass=aeNwDevice)
attributes aeFqdn ipHostNumber
sasl
}`, false},
}
for i, test := range tests {
c := caddy.NewTestController("dns", test.body)
if _, err := ldapParse(c); (err == nil) == test.expectedError {
t.Fatalf("Unexpected errors: %v in test: %d\n\t%s", err, i, test.body)
}
}
}