Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 64c6e08

Browse files
committed
Configure connection with GitHub::Ldap::Test#options
Also use that port value, as it changes depending on the integration test LDAP server in use.
1 parent 142e3fd commit 64c6e08

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

test/referral_chaser_test.rb

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33
class GitHubLdapReferralChaserTestCases < GitHub::Ldap::Test
44

55
def setup
6-
@mock_connection = GitHub::Ldap.new({
7-
admin_user: "uid=admin,dc=github,dc=com",
8-
admin_password: "passworD1",
9-
port: 389
10-
})
6+
@mock_connection = GitHub::Ldap.new(options)
117
@chaser = GitHub::Ldap::ReferralChaser.new(@mock_connection)
128
end
139

@@ -18,25 +14,21 @@ def test_creates_referral_with_connection_credentials
1814
referral.stubs(:search).returns([])
1915

2016
GitHub::Ldap::ReferralChaser::Referral.expects(:new)
21-
.with("referral string", "uid=admin,dc=github,dc=com", "passworD1", 389)
17+
.with("referral string", "uid=admin,dc=github,dc=com", "passworD1", options[:port])
2218
.returns(referral)
2319

2420
@chaser.search({})
2521
end
2622

2723
def test_creates_referral_with_default_port
28-
mock_connection = GitHub::Ldap.new({
29-
admin_user: "uid=admin,dc=github,dc=com",
30-
admin_password: "passworD1"
31-
})
32-
mock_connection.expects(:search).yields({
24+
@mock_connection.expects(:search).yields({
3325
search_referrals: ["ldap://dc1.ghe.local/CN=Maggie%20Mae,CN=Users,DC=dc4,DC=ghe,DC=local"]
3426
}).returns([])
3527

3628
stub_referral_connection = mock("GitHub::Ldap")
3729
stub_referral_connection.stubs(:search).returns([])
38-
GitHub::Ldap::ConnectionCache.expects(:get_connection).with(has_entry(port: 389)).returns(stub_referral_connection)
39-
chaser = GitHub::Ldap::ReferralChaser.new(mock_connection)
30+
GitHub::Ldap::ConnectionCache.expects(:get_connection).with(has_entry(port: options[:port])).returns(stub_referral_connection)
31+
chaser = GitHub::Ldap::ReferralChaser.new(@mock_connection)
4032
chaser.search({})
4133
end
4234

@@ -61,7 +53,7 @@ def test_creates_referral_for_first_referral_string
6153
"ldap://dc1.ghe.local/CN=Maggie%20Mae,CN=Users,DC=dc4,DC=ghe,DC=local",
6254
"uid=admin,dc=github,dc=com",
6355
"passworD1",
64-
389)
56+
options[:port])
6557
.returns(referral)
6658

6759
@chaser.search({})

0 commit comments

Comments
 (0)