functional: remove in memory connector configs from ldap tests

This commit is contained in:
Eric Chiang 2016-02-12 15:11:14 -08:00
parent 1658e86b2a
commit 2cc0ae6fac
2 changed files with 22 additions and 4 deletions

View file

@ -21,6 +21,7 @@ install:
script: script:
- docker run -d -p 127.0.0.1:15432:5432 quay.io/coreos/postgres - docker run -d -p 127.0.0.1:15432:5432 quay.io/coreos/postgres
- LDAPCONTAINER=`docker run -e LDAP_TLS_PROTOCOL_MIN=3.0 -e LDAP_TLS_CIPHER_SUITE=NORMAL -d -p 127.0.0.1:1389:389 -p 127.0.0.1:1636:636 -h tlstest.local osixia/openldap` - LDAPCONTAINER=`docker run -e LDAP_TLS_PROTOCOL_MIN=3.0 -e LDAP_TLS_CIPHER_SUITE=NORMAL -d -p 127.0.0.1:1389:389 -p 127.0.0.1:1636:636 -h tlstest.local osixia/openldap`
- ./build
- ./test - ./test
- docker cp ${LDAPCONTAINER}:container/service/:cfssl/assets/default-ca/default-ca.pem /tmp/openldap-ca.pem - docker cp ${LDAPCONTAINER}:container/service/:cfssl/assets/default-ca/default-ca.pem /tmp/openldap-ca.pem
- docker cp ${LDAPCONTAINER}:container/service/slapd/assets/certs/ldap.key /tmp/ldap.key - docker cp ${LDAPCONTAINER}:container/service/slapd/assets/certs/ldap.key /tmp/ldap.key

View file

@ -10,6 +10,7 @@ import (
"testing" "testing"
"github.com/coreos/dex/connector" "github.com/coreos/dex/connector"
"github.com/coreos/dex/db"
"github.com/coreos/dex/repo" "github.com/coreos/dex/repo"
"github.com/coreos/go-oidc/oidc" "github.com/coreos/go-oidc/oidc"
"gopkg.in/ldap.v2" "gopkg.in/ldap.v2"
@ -93,13 +94,17 @@ func TestConnectorLDAPConnectFail(t *testing.T) {
templates := template.New(connector.LDAPLoginPageTemplateName) templates := template.New(connector.LDAPLoginPageTemplateName)
ccr := connector.NewConnectorConfigRepoFromConfigs( ccr := db.NewConnectorConfigRepo(db.NewMemDB())
err := ccr.Set(
[]connector.ConnectorConfig{&connector.LDAPConnectorConfig{ []connector.ConnectorConfig{&connector.LDAPConnectorConfig{
ID: "ldap", ID: "ldap",
ServerHost: ldapHost, ServerHost: ldapHost,
ServerPort: ldapPort + 1, ServerPort: ldapPort + 1,
}}, }},
) )
if err != nil {
t.Fatal(err)
}
cc, err := ccr.GetConnectorByID(tx, "ldap") cc, err := ccr.GetConnectorByID(tx, "ldap")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -121,13 +126,17 @@ func TestConnectorLDAPConnectSuccess(t *testing.T) {
templates := template.New(connector.LDAPLoginPageTemplateName) templates := template.New(connector.LDAPLoginPageTemplateName)
ccr := connector.NewConnectorConfigRepoFromConfigs( ccr := db.NewConnectorConfigRepo(db.NewMemDB())
err := ccr.Set(
[]connector.ConnectorConfig{&connector.LDAPConnectorConfig{ []connector.ConnectorConfig{&connector.LDAPConnectorConfig{
ID: "ldap", ID: "ldap",
ServerHost: ldapHost, ServerHost: ldapHost,
ServerPort: ldapPort, ServerPort: ldapPort,
}}, }},
) )
if err != nil {
t.Fatal(err)
}
cc, err := ccr.GetConnectorByID(tx, "ldap") cc, err := ccr.GetConnectorByID(tx, "ldap")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -149,7 +158,8 @@ func TestConnectorLDAPcaFilecertFileConnectTLS(t *testing.T) {
templates := template.New(connector.LDAPLoginPageTemplateName) templates := template.New(connector.LDAPLoginPageTemplateName)
ccr := connector.NewConnectorConfigRepoFromConfigs( ccr := db.NewConnectorConfigRepo(db.NewMemDB())
err := ccr.Set(
[]connector.ConnectorConfig{&connector.LDAPConnectorConfig{ []connector.ConnectorConfig{&connector.LDAPConnectorConfig{
ID: "ldap", ID: "ldap",
ServerHost: ldapHost, ServerHost: ldapHost,
@ -160,6 +170,9 @@ func TestConnectorLDAPcaFilecertFileConnectTLS(t *testing.T) {
CaFile: "/tmp/openldap-ca.pem", CaFile: "/tmp/openldap-ca.pem",
}}, }},
) )
if err != nil {
t.Fatal(err)
}
cc, err := ccr.GetConnectorByID(tx, "ldap") cc, err := ccr.GetConnectorByID(tx, "ldap")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -181,7 +194,8 @@ func TestConnectorLDAPcaFilecertFileConnectSSL(t *testing.T) {
templates := template.New(connector.LDAPLoginPageTemplateName) templates := template.New(connector.LDAPLoginPageTemplateName)
ccr := connector.NewConnectorConfigRepoFromConfigs( ccr := db.NewConnectorConfigRepo(db.NewMemDB())
err := ccr.Set(
[]connector.ConnectorConfig{&connector.LDAPConnectorConfig{ []connector.ConnectorConfig{&connector.LDAPConnectorConfig{
ID: "ldap", ID: "ldap",
ServerHost: ldapHost, ServerHost: ldapHost,
@ -192,6 +206,9 @@ func TestConnectorLDAPcaFilecertFileConnectSSL(t *testing.T) {
CaFile: "/tmp/openldap-ca.pem", CaFile: "/tmp/openldap-ca.pem",
}}, }},
) )
if err != nil {
t.Fatal(err)
}
cc, err := ccr.GetConnectorByID(tx, "ldap") cc, err := ccr.GetConnectorByID(tx, "ldap")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)