coredns-ldap/setup_test.go

33 lines
712 B
Go
Raw Normal View History

2020-06-01 07:48:07 +00:00
package ldap
import (
"testing"
"github.com/caddyserver/caddy"
)
2018-02-25 08:52:52 +00:00
// TestSetup tests the various things that should be parsed by setup.
// Make sure you also test for parse errors.
func TestSetup(t *testing.T) {
2020-06-10 02:54:01 +00:00
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},
}
2020-06-10 02:54:01 +00:00
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)
}
}
}