2020-06-01 07:48:07 +00:00
|
|
|
package ldap
|
2018-01-26 18:43:28 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2019-07-10 07:39:00 +00:00
|
|
|
"github.com/caddyserver/caddy"
|
2018-01-26 18:43:28 +00:00
|
|
|
)
|
|
|
|
|
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},
|
2018-01-26 18:43:28 +00:00
|
|
|
}
|
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)
|
|
|
|
}
|
2018-01-26 18:43:28 +00:00
|
|
|
}
|
|
|
|
}
|