fix: 修复CSP白屏并优化LDAP配置
This commit is contained in:
1 parent
a14d9e62e6
commit
c7f59f2cbf
12 files changed
+930
-70
No files matched your search
@@ -0,0 +1,32 @@
|
||||
package ldaputil
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestDialURL(t *testing.T) {
|
||||
tests := []struct {
|
||||
address string
|
||||
want string
|
||||
}{
|
||||
{"8.217.205.92", "ldaps://8.217.205.92:636"},
|
||||
{"ldap.opsx.vip", "ldaps://ldap.opsx.vip:636"},
|
||||
{"ldap.opsx.vip:1636", "ldaps://ldap.opsx.vip:1636"},
|
||||
{"2001:db8::1", "ldaps://[2001:db8::1]:636"},
|
||||
{"ldap://ldap.opsx.vip", "ldap://ldap.opsx.vip:389"},
|
||||
{"ldaps://ldap.opsx.vip", "ldaps://ldap.opsx.vip:636"},
|
||||
{" ldaps://8.217.205.92 ", "ldaps://8.217.205.92:636"},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
got, err := DialURL(tt.address)
|
||||
if err != nil || got != tt.want {
|
||||
t.Errorf("DialURL(%q) = %q, %v; want %q", tt.address, got, err, tt.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDialURLRejectsInvalidAddress(t *testing.T) {
|
||||
for _, address := range []string{"", "ldap.opsx.vip/path", "ldap.opsx.vip:", "https://ldap.opsx.vip"} {
|
||||
if _, err := DialURL(address); err == nil {
|
||||
t.Errorf("DialURL(%q) succeeded; want error", address)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user