Skip to content

Commit 4703a85

Browse files
Add docker-compose config so we can run tests
1 parent a2bb2e7 commit 4703a85

File tree

3 files changed

+54
-8
lines changed

3 files changed

+54
-8
lines changed

ci-run.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
gem install bundler
6+
bundle check || bundle install
7+
bundle exec rake ci

docker-compose.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
version: "3.8"
2+
3+
networks:
4+
integration_test_network:
5+
6+
services:
7+
openldap:
8+
image: osixia/openldap:1.4.0
9+
networks:
10+
integration_test_network:
11+
aliases:
12+
- ldap.example.org
13+
- cert.mismatch.example.org
14+
environment:
15+
LDAP_TLS_VERIFY_CLIENT: "try"
16+
LDAP_SEED_INTERNAL_LDIF_PATH: "/ldif"
17+
healthcheck:
18+
test: ["CMD", "ldapsearch", "-x", "-s", "base"]
19+
interval: 60s
20+
start_period: 30s
21+
timeout: 5s
22+
retries: 1
23+
hostname: "ldap.example.org"
24+
volumes:
25+
- ./test/fixtures/ldif:/ldif:ro
26+
27+
ci-ruby-2.5:
28+
image: ruby:2.5
29+
entrypoint: /code/ci-run.sh
30+
environment:
31+
INTEGRATION: openldap
32+
INTEGRATION_HOST: ldap.example.org
33+
depends_on:
34+
- openldap
35+
networks:
36+
integration_test_network:
37+
volumes:
38+
- .:/code:ro
39+
working_dir: /code

test/integration/test_bind.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_bind_tls_with_bad_hostname_verify_none_no_ca_passes
5757
end
5858

5959
def test_bind_tls_with_bad_hostname_verify_none_no_ca_opt_merge_passes
60-
@ldap.host = INTEGRATION_HOSTNAME
60+
@ldap.host = 'cert.mismatch.example.org'
6161
@ldap.encryption(
6262
method: :start_tls,
6363
tls_options: TLS_OPTS.merge(verify_mode: OpenSSL::SSL::VERIFY_NONE),
@@ -67,7 +67,7 @@ def test_bind_tls_with_bad_hostname_verify_none_no_ca_opt_merge_passes
6767
end
6868

6969
def test_bind_tls_with_bad_hostname_verify_peer_ca_fails
70-
@ldap.host = INTEGRATION_HOSTNAME
70+
@ldap.host = 'cert.mismatch.example.org'
7171
@ldap.encryption(
7272
method: :start_tls,
7373
tls_options: { verify_mode: OpenSSL::SSL::VERIFY_PEER,
@@ -84,7 +84,7 @@ def test_bind_tls_with_bad_hostname_verify_peer_ca_fails
8484
end
8585

8686
def test_bind_tls_with_bad_hostname_ca_default_opt_merge_fails
87-
@ldap.host = INTEGRATION_HOSTNAME
87+
@ldap.host = 'cert.mismatch.example.org'
8888
@ldap.encryption(
8989
method: :start_tls,
9090
tls_options: TLS_OPTS.merge(ca_file: CA_FILE),
@@ -100,7 +100,7 @@ def test_bind_tls_with_bad_hostname_ca_default_opt_merge_fails
100100
end
101101

102102
def test_bind_tls_with_bad_hostname_ca_no_opt_merge_fails
103-
@ldap.host = INTEGRATION_HOSTNAME
103+
@ldap.host = 'cert.mismatch.example.org'
104104
@ldap.encryption(
105105
method: :start_tls,
106106
tls_options: { ca_file: CA_FILE },
@@ -138,7 +138,7 @@ def test_bind_tls_with_valid_hostname_just_verify_peer_ca_passes
138138
end
139139

140140
def test_bind_tls_with_bogus_hostname_system_ca_fails
141-
@ldap.host = INTEGRATION_HOSTNAME
141+
@ldap.host = 'cert.mismatch.example.org'
142142
@ldap.encryption(method: :start_tls, tls_options: {})
143143
error = assert_raise Net::LDAP::Error,
144144
Net::LDAP::ConnectionRefusedError do
@@ -164,7 +164,7 @@ def test_bind_tls_with_multiple_hosts
164164

165165
def test_bind_tls_with_multiple_bogus_hosts
166166
@ldap.host = nil
167-
@ldap.hosts = [[INTEGRATION_HOSTNAME, 389], ['bogus.example.com', 389]]
167+
@ldap.hosts = [['cert.mismatch.example.org', 389], ['bogus.example.com', 389]]
168168
@ldap.encryption(
169169
method: :start_tls,
170170
tls_options: TLS_OPTS.merge(verify_mode: OpenSSL::SSL::VERIFY_PEER,
@@ -180,7 +180,7 @@ def test_bind_tls_with_multiple_bogus_hosts
180180

181181
def test_bind_tls_with_multiple_bogus_hosts_no_verification
182182
@ldap.host = nil
183-
@ldap.hosts = [[INTEGRATION_HOSTNAME, 389], ['bogus.example.com', 389]]
183+
@ldap.hosts = [['cert.mismatch.example.org', 389], ['bogus.example.com', 389]]
184184
@ldap.encryption(
185185
method: :start_tls,
186186
tls_options: TLS_OPTS.merge(verify_mode: OpenSSL::SSL::VERIFY_NONE),
@@ -191,7 +191,7 @@ def test_bind_tls_with_multiple_bogus_hosts_no_verification
191191

192192
def test_bind_tls_with_multiple_bogus_hosts_ca_check_only_fails
193193
@ldap.host = nil
194-
@ldap.hosts = [[INTEGRATION_HOSTNAME, 389], ['bogus.example.com', 389]]
194+
@ldap.hosts = [['cert.mismatch.example.org', 389], ['bogus.example.com', 389]]
195195
@ldap.encryption(
196196
method: :start_tls,
197197
tls_options: { ca_file: CA_FILE },

0 commit comments

Comments
 (0)