package connector
import (
"html/template"
"net/url"
"testing"
"github.com/coreos/go-oidc/oidc"
)
var (
ns url.URL
lf oidc.LoginFunc
templates *template.Template
func init() {
templates = template.New(LDAPLoginPageTemplateName)
}
func TestLDAPConnectorConfigValidTLS(t *testing.T) {
cc := LDAPConnectorConfig{
ID: "ldap",
Host: "example.com:636",
UseTLS: true,
UseSSL: false,
_, err := cc.Connector(ns, lf, templates)
if err != nil {
t.Fatal(err)
func TestLDAPConnectorConfigInvalidSSLandTLS(t *testing.T) {
UseSSL: true,
if err == nil {
t.Fatal("Expected LDAPConnector initialization to fail when both TLS and SSL enabled.")
func TestLDAPConnectorConfigValidSearchScope(t *testing.T) {
SearchScope: "one",
func TestLDAPConnectorConfigInvalidSearchScope(t *testing.T) {
SearchScope: "three",
t.Fatal("Expected LDAPConnector initialization to fail when invalid value provided for SearchScope.")
func TestLDAPConnectorConfigInvalidCertFileNoKeyFile(t *testing.T) {
CertFile: "/tmp/ldap.crt",
t.Fatal("Expected LDAPConnector initialization to fail when CertFile specified without KeyFile.")
func TestLDAPConnectorConfigValidCertFileAndKeyFile(t *testing.T) {
KeyFile: "/tmp/ldap.key",