coredns-ldap/setup_test.go

38 lines
782 B
Go
Raw Permalink Normal View History

2020-06-10 07:41:44 +00:00
package ldap_test
import (
"testing"
"github.com/caddyserver/caddy"
2020-06-10 07:41:44 +00:00
. "github.com/xoe-labs/ldap/v0"
)
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
}{
2020-06-10 06:40:13 +00:00
{`ldap`, true},
2020-06-10 02:54:01 +00:00
{`ldap :`, true},
{`ldap {
ldap_url ldap://example.com
base_dn ou=ae-dir
filter (objectClass=aeNwDevice)
sasl
2020-06-10 06:40:13 +00:00
attributes {
fqdn aeFqdn
ip4 ipHostNumber
}
2020-06-10 02:54:01 +00:00
}`, false},
}
2020-06-10 02:54:01 +00:00
for i, test := range tests {
c := caddy.NewTestController("dns", test.body)
2020-06-10 06:40:13 +00:00
if _, err := ParseStanza(c); (err == nil) == test.expectedError {
t.Fatalf("Unexpected errors in test %d: %v\n%s", i, err, test.body)
2020-06-10 02:54:01 +00:00
}
}
}