Merge pull request #2009 from flant/skip-ldap-tests

fix: do not run LDAP tests locally by default
This commit is contained in:
Márk Sági-Kazár 2021-02-20 23:33:31 +01:00 committed by GitHub
commit 3c5a631ce3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -526,6 +526,11 @@ func getenv(key, defaultVal string) string {
// The tests require LDAP to be runnning. // The tests require LDAP to be runnning.
// You can use the provided docker-compose file to setup an LDAP server. // You can use the provided docker-compose file to setup an LDAP server.
func runTests(t *testing.T, connMethod connectionMethod, config *Config, tests []subtest) { func runTests(t *testing.T, connMethod connectionMethod, config *Config, tests []subtest) {
ldapHost := os.Getenv("DEX_LDAP_HOST")
if ldapHost == "" {
t.Skipf(`test environment variable "DEX_LDAP_HOST" not set, skipping`)
}
// Shallow copy. // Shallow copy.
c := *config c := *config
@ -533,17 +538,17 @@ func runTests(t *testing.T, connMethod connectionMethod, config *Config, tests [
// group search configuration. // group search configuration.
switch connMethod { switch connMethod {
case connectStartTLS: case connectStartTLS:
c.Host = fmt.Sprintf("%s:%s", getenv("DEX_LDAP_HOST", "localhost"), getenv("DEX_LDAP_PORT", "389")) c.Host = fmt.Sprintf("%s:%s", ldapHost, getenv("DEX_LDAP_PORT", "389"))
c.RootCA = "testdata/certs/ca.crt" c.RootCA = "testdata/certs/ca.crt"
c.StartTLS = true c.StartTLS = true
case connectLDAPS: case connectLDAPS:
c.Host = fmt.Sprintf("%s:%s", getenv("DEX_LDAP_HOST", "localhost"), getenv("DEX_LDAP_TLS_PORT", "636")) c.Host = fmt.Sprintf("%s:%s", ldapHost, getenv("DEX_LDAP_TLS_PORT", "636"))
c.RootCA = "testdata/certs/ca.crt" c.RootCA = "testdata/certs/ca.crt"
case connectInsecureSkipVerify: case connectInsecureSkipVerify:
c.Host = fmt.Sprintf("%s:%s", getenv("DEX_LDAP_HOST", "localhost"), getenv("DEX_LDAP_TLS_PORT", "636")) c.Host = fmt.Sprintf("%s:%s", ldapHost, getenv("DEX_LDAP_TLS_PORT", "636"))
c.InsecureSkipVerify = true c.InsecureSkipVerify = true
case connectLDAP: case connectLDAP:
c.Host = fmt.Sprintf("%s:%s", getenv("DEX_LDAP_HOST", "localhost"), getenv("DEX_LDAP_PORT", "389")) c.Host = fmt.Sprintf("%s:%s", ldapHost, getenv("DEX_LDAP_PORT", "389"))
c.InsecureNoSSL = true c.InsecureNoSSL = true
} }