From 1f2771b57e3e211a39ae172b397cd6fce67d7d90 Mon Sep 17 00:00:00 2001 From: "m.nabokikh" Date: Sat, 20 Feb 2021 12:55:52 +0400 Subject: [PATCH 1/2] fix: do not run LDAP tests locally by default Signed-off-by: m.nabokikh --- .github/workflows/ci.yaml | 1 + connector/ldap/ldap_test.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0ea01b98..3fa95864 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -71,6 +71,7 @@ jobs: DEX_POSTGRES_HOST: localhost DEX_POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }} DEX_ETCD_ENDPOINTS: http://localhost:${{ job.services.etcd.ports[2379] }} + DEX_LDAP_TESTS: yes DEX_LDAP_HOST: localhost DEX_LDAP_PORT: 389 DEX_LDAP_TLS_PORT: 636 diff --git a/connector/ldap/ldap_test.go b/connector/ldap/ldap_test.go index 61383924..8c1eec4b 100644 --- a/connector/ldap/ldap_test.go +++ b/connector/ldap/ldap_test.go @@ -526,6 +526,10 @@ func getenv(key, defaultVal string) string { // The tests require LDAP to be runnning. // You can use the provided docker-compose file to setup an LDAP server. func runTests(t *testing.T, connMethod connectionMethod, config *Config, tests []subtest) { + if os.Getenv("DEX_LDAP_TESTS") == "" { + t.Skip("Specify not-empty DEX_LDAP_TESTS env variable to enable LDAP tests") + } + // Shallow copy. c := *config From 84a07a780588bcef200378b23c69ccc4ccc3e899 Mon Sep 17 00:00:00 2001 From: "m.nabokikh" Date: Sat, 20 Feb 2021 17:05:41 +0400 Subject: [PATCH 2/2] Do not run LDAP tests if DEX_LDAP_HOST is not set Signed-off-by: m.nabokikh --- .github/workflows/ci.yaml | 1 - connector/ldap/ldap_test.go | 13 +++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3fa95864..0ea01b98 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -71,7 +71,6 @@ jobs: DEX_POSTGRES_HOST: localhost DEX_POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }} DEX_ETCD_ENDPOINTS: http://localhost:${{ job.services.etcd.ports[2379] }} - DEX_LDAP_TESTS: yes DEX_LDAP_HOST: localhost DEX_LDAP_PORT: 389 DEX_LDAP_TLS_PORT: 636 diff --git a/connector/ldap/ldap_test.go b/connector/ldap/ldap_test.go index 8c1eec4b..9ae45674 100644 --- a/connector/ldap/ldap_test.go +++ b/connector/ldap/ldap_test.go @@ -526,8 +526,9 @@ func getenv(key, defaultVal string) string { // The tests require LDAP to be runnning. // You can use the provided docker-compose file to setup an LDAP server. func runTests(t *testing.T, connMethod connectionMethod, config *Config, tests []subtest) { - if os.Getenv("DEX_LDAP_TESTS") == "" { - t.Skip("Specify not-empty DEX_LDAP_TESTS env variable to enable LDAP tests") + ldapHost := os.Getenv("DEX_LDAP_HOST") + if ldapHost == "" { + t.Skipf(`test environment variable "DEX_LDAP_HOST" not set, skipping`) } // Shallow copy. @@ -537,17 +538,17 @@ func runTests(t *testing.T, connMethod connectionMethod, config *Config, tests [ // group search configuration. switch connMethod { 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.StartTLS = true 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" 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 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 }