3
3
class GitHubLdapReferralChaserTestCases < GitHub ::Ldap ::Test
4
4
5
5
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 )
11
7
@chaser = GitHub ::Ldap ::ReferralChaser . new ( @mock_connection )
12
8
end
13
9
@@ -18,25 +14,21 @@ def test_creates_referral_with_connection_credentials
18
14
referral . stubs ( :search ) . returns ( [ ] )
19
15
20
16
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 ] )
22
18
. returns ( referral )
23
19
24
20
@chaser . search ( { } )
25
21
end
26
22
27
23
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 ( {
33
25
search_referrals : [ "ldap://dc1.ghe.local/CN=Maggie%20Mae,CN=Users,DC=dc4,DC=ghe,DC=local" ]
34
26
} ) . returns ( [ ] )
35
27
36
28
stub_referral_connection = mock ( "GitHub::Ldap" )
37
29
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)
40
32
chaser . search ( { } )
41
33
end
42
34
@@ -61,7 +53,7 @@ def test_creates_referral_for_first_referral_string
61
53
"ldap://dc1.ghe.local/CN=Maggie%20Mae,CN=Users,DC=dc4,DC=ghe,DC=local" ,
62
54
"uid=admin,dc=github,dc=com" ,
63
55
"passworD1" ,
64
- 389 )
56
+ options [ :port ] )
65
57
. returns ( referral )
66
58
67
59
@chaser . search ( { } )
0 commit comments