Skip to content

Commit 58b4a85

Browse files
Merge pull request #376 from ruby-ldap/HarlemSquirrel-patch-1
Create first GitHub action
2 parents ecd9430 + 6b91444 commit 58b4a85

File tree

5 files changed

+126
-8
lines changed

5 files changed

+126
-8
lines changed

.github/workflows/test.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7+
8+
name: Test
9+
10+
on:
11+
pull_request:
12+
push:
13+
branches:
14+
- master
15+
16+
jobs:
17+
test:
18+
runs-on: ubuntu-latest
19+
strategy:
20+
matrix:
21+
ruby:
22+
- "2.5"
23+
- "2.6"
24+
- "2.7"
25+
- "jruby-9.2"
26+
steps:
27+
- uses: actions/checkout@v2
28+
- name: Run tests with Ruby ${{ matrix.ruby }}
29+
run: docker-compose run ci-${{ matrix.ruby }}

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ rvm:
1818
addons:
1919
hosts:
2020
- ldap.example.org # needed for TLS verification
21+
- cert.mismatch.example.org
2122

2223
services:
2324
- docker

ci-run.sh

+7
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

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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-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
39+
working_dir: /code
40+
41+
ci-2.6:
42+
image: ruby:2.7
43+
entrypoint: /code/ci-run.sh
44+
environment:
45+
INTEGRATION: openldap
46+
INTEGRATION_HOST: ldap.example.org
47+
depends_on:
48+
- openldap
49+
networks:
50+
integration_test_network:
51+
volumes:
52+
- .:/code
53+
working_dir: /code
54+
55+
ci-2.7:
56+
image: ruby:2.7
57+
entrypoint: /code/ci-run.sh
58+
environment:
59+
INTEGRATION: openldap
60+
INTEGRATION_HOST: ldap.example.org
61+
depends_on:
62+
- openldap
63+
networks:
64+
integration_test_network:
65+
volumes:
66+
- .:/code
67+
working_dir: /code
68+
69+
ci-jruby-9.2:
70+
image: jruby:9.2
71+
entrypoint: /code/ci-run.sh
72+
environment:
73+
INTEGRATION: openldap
74+
INTEGRATION_HOST: ldap.example.org
75+
depends_on:
76+
- openldap
77+
networks:
78+
integration_test_network:
79+
volumes:
80+
- .:/code
81+
working_dir: /code

test/integration/test_bind.rb

+8-8
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 = '127.0.0.1'
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 = '127.0.0.1'
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 = '127.0.0.1'
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 = '127.0.0.1'
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 = '127.0.0.1'
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 = [['127.0.0.1', 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 = [['127.0.0.1', 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 = [['127.0.0.1', 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)