ldap_fluff 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +7 -1
- data/lib/ldap_fluff/active_directory.rb +5 -7
- data/lib/ldap_fluff/ad_member_service.rb +38 -16
- data/lib/ldap_fluff/config.rb +5 -5
- data/lib/ldap_fluff/error.rb +0 -1
- data/lib/ldap_fluff/freeipa.rb +4 -7
- data/lib/ldap_fluff/freeipa_member_service.rb +1 -4
- data/lib/ldap_fluff/freeipa_netgroup_member_service.rb +0 -2
- data/lib/ldap_fluff/generic.rb +9 -9
- data/lib/ldap_fluff/generic_member_service.rb +2 -4
- data/lib/ldap_fluff/ldap_fluff.rb +9 -9
- data/lib/ldap_fluff/posix.rb +9 -10
- data/lib/ldap_fluff/posix_member_service.rb +1 -3
- data/lib/ldap_fluff/posix_netgroup_member_service.rb +0 -2
- data/test/ad_member_services_test.rb +19 -4
- data/test/ad_test.rb +22 -23
- data/test/config_test.rb +5 -5
- data/test/ipa_member_services_test.rb +2 -3
- data/test/ipa_netgroup_member_services_test.rb +0 -1
- data/test/ipa_test.rb +16 -18
- data/test/ldap_test.rb +8 -11
- data/test/lib/ldap_test_helper.rb +21 -18
- data/test/posix_member_services_test.rb +5 -5
- data/test/posix_netgroup_member_services_test.rb +5 -5
- data/test/posix_test.rb +17 -17
- metadata +13 -13
@@ -2,7 +2,6 @@ require 'net/ldap'
|
|
2
2
|
|
3
3
|
# handles the naughty bits of posix ldap
|
4
4
|
class LdapFluff::Posix::MemberService < LdapFluff::GenericMemberService
|
5
|
-
|
6
5
|
def initialize(ldap, config)
|
7
6
|
@attr_login = (config.attr_login || 'memberuid')
|
8
7
|
super
|
@@ -41,7 +40,7 @@ class LdapFluff::Posix::MemberService < LdapFluff::GenericMemberService
|
|
41
40
|
filters[1..(filters.size - 1)].each do |gfilter|
|
42
41
|
filter = (all ? filter & gfilter : filter | gfilter)
|
43
42
|
end
|
44
|
-
|
43
|
+
filter
|
45
44
|
end
|
46
45
|
end
|
47
46
|
|
@@ -50,5 +49,4 @@ class LdapFluff::Posix::MemberService < LdapFluff::GenericMemberService
|
|
50
49
|
|
51
50
|
class GIDNotFoundException < LdapFluff::Error
|
52
51
|
end
|
53
|
-
|
54
52
|
end
|
@@ -2,7 +2,6 @@ require 'net/ldap'
|
|
2
2
|
|
3
3
|
# handles the naughty bits of posix ldap
|
4
4
|
class LdapFluff::Posix::NetgroupMemberService < LdapFluff::Posix::MemberService
|
5
|
-
|
6
5
|
# return list of group CNs for a user
|
7
6
|
def find_user_groups(uid)
|
8
7
|
groups = []
|
@@ -12,5 +11,4 @@ class LdapFluff::Posix::NetgroupMemberService < LdapFluff::Posix::MemberService
|
|
12
11
|
end
|
13
12
|
groups
|
14
13
|
end
|
15
|
-
|
16
14
|
end
|
@@ -11,6 +11,7 @@ class TestADMemberService < MiniTest::Test
|
|
11
11
|
|
12
12
|
def basic_user
|
13
13
|
@ldap.expect(:search, ad_user_payload, [:filter => ad_name_filter("john")])
|
14
|
+
@ldap.expect(:search, [{ :domainfunctionality => ['5'] }], [:base => "", :scope => 0, :attributes => ['domainFunctionality']])
|
14
15
|
@ldap.expect(:search, ad_parent_payload(1), [:base => ad_group_dn, :scope => 0, :attributes => ['memberof']])
|
15
16
|
end
|
16
17
|
|
@@ -20,7 +21,7 @@ class TestADMemberService < MiniTest::Test
|
|
20
21
|
|
21
22
|
def nest_deep(n)
|
22
23
|
# add all the expects
|
23
|
-
1.upto(n-1) do |i|
|
24
|
+
1.upto(n - 1) do |i|
|
24
25
|
@ldap.expect(:search, ad_parent_payload(i + 1), [:base => ad_group_dn("bros#{i}"), :scope => 0, :attributes => ['memberof']])
|
25
26
|
end
|
26
27
|
# terminate or we loop FOREVER
|
@@ -39,11 +40,19 @@ class TestADMemberService < MiniTest::Test
|
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
43
|
+
def transitive_user
|
44
|
+
ad_transitive_payload = [{ 'msds-memberoftransitive' => [ad_group_dn("bros#1"), ad_group_dn("bros#2"), ad_group_dn("bros#3"), ad_group_dn("bros#4"), ad_group_dn("bros#5")] }]
|
45
|
+
|
46
|
+
@ldap.expect(:search, ad_user_payload('john'), [:filter => ad_name_filter("john")])
|
47
|
+
@ldap.expect(:search, [{ :domainfunctionality => ['6'] }], [:base => "", :scope => 0, :attributes => ['domainFunctionality']])
|
48
|
+
@ldap.expect(:search, ad_transitive_payload, [:base => ad_user_dn("john"), :scope => 0, :attributes => ['msds-memberOfTransitive']])
|
49
|
+
end
|
50
|
+
|
42
51
|
def test_find_user
|
43
52
|
basic_user
|
44
53
|
@ldap.expect(:search, [], [:base => ad_group_dn('bros1'), :scope => 0, :attributes => ['memberof']])
|
45
54
|
@adms.ldap = @ldap
|
46
|
-
assert_equal(%w
|
55
|
+
assert_equal(%w[group bros1], @adms.find_user_groups("john"))
|
47
56
|
@ldap.verify
|
48
57
|
end
|
49
58
|
|
@@ -53,7 +62,7 @@ class TestADMemberService < MiniTest::Test
|
|
53
62
|
# now make 'bros1' be memberof 'group' again
|
54
63
|
@ldap.expect(:search, ad_user_payload, [:base => ad_group_dn('bros1'), :scope => 0, :attributes => ['memberof']])
|
55
64
|
@adms.ldap = @ldap
|
56
|
-
assert_equal(%w
|
65
|
+
assert_equal(%w[group bros1], @adms.find_user_groups("john"))
|
57
66
|
@ldap.verify
|
58
67
|
end
|
59
68
|
|
@@ -82,6 +91,13 @@ class TestADMemberService < MiniTest::Test
|
|
82
91
|
@ldap.verify
|
83
92
|
end
|
84
93
|
|
94
|
+
def test_transitive_groups
|
95
|
+
transitive_user
|
96
|
+
@adms.ldap = @ldap
|
97
|
+
assert_equal(5, @adms.find_user_groups('john').size)
|
98
|
+
@ldap.verify
|
99
|
+
end
|
100
|
+
|
85
101
|
def test_nil_payload
|
86
102
|
assert_equal([], @adms._groups_from_ldap_data(nil))
|
87
103
|
end
|
@@ -160,5 +176,4 @@ class TestADMemberService < MiniTest::Test
|
|
160
176
|
entry = Net::LDAP::Entry.new('Example User')
|
161
177
|
assert_nil(@adms.get_login_from_entry(entry))
|
162
178
|
end
|
163
|
-
|
164
179
|
end
|
data/test/ad_test.rb
CHANGED
@@ -5,12 +5,12 @@ class TestAD < MiniTest::Test
|
|
5
5
|
|
6
6
|
def setup
|
7
7
|
super
|
8
|
-
@ad
|
8
|
+
@ad = LdapFluff::ActiveDirectory.new(@config)
|
9
9
|
end
|
10
10
|
|
11
11
|
# default setup for service bind users
|
12
12
|
def service_bind
|
13
|
-
@ldap.expect(:auth, nil, %w
|
13
|
+
@ldap.expect(:auth, nil, %w[service pass])
|
14
14
|
super
|
15
15
|
end
|
16
16
|
|
@@ -37,7 +37,7 @@ class TestAD < MiniTest::Test
|
|
37
37
|
@md = MiniTest::Mock.new
|
38
38
|
user_result = MiniTest::Mock.new
|
39
39
|
user_result.expect(:dn, ad_user_dn('Internet User'))
|
40
|
-
@md.expect(:find_user, [user_result], %w
|
40
|
+
@md.expect(:find_user, [user_result], %w[internet])
|
41
41
|
@ad.member_service = @md
|
42
42
|
service_bind
|
43
43
|
@ldap.expect(:auth, nil, [ad_user_dn('Internet User'), "password"])
|
@@ -47,7 +47,7 @@ class TestAD < MiniTest::Test
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def test_bad_bind
|
50
|
-
@ldap.expect(:auth, nil, %w
|
50
|
+
@ldap.expect(:auth, nil, %w[EXAMPLE\\internet password])
|
51
51
|
@ldap.expect(:bind, false)
|
52
52
|
@ad.ldap = @ldap
|
53
53
|
assert_equal(@ad.bind?("EXAMPLE\\internet", "password"), false)
|
@@ -57,14 +57,14 @@ class TestAD < MiniTest::Test
|
|
57
57
|
def test_groups
|
58
58
|
service_bind
|
59
59
|
basic_user
|
60
|
-
assert_equal(@ad.groups_for_uid('john'), %w
|
60
|
+
assert_equal(@ad.groups_for_uid('john'), %w[bros])
|
61
61
|
end
|
62
62
|
|
63
63
|
def test_bad_user
|
64
64
|
service_bind
|
65
65
|
md = MiniTest::Mock.new
|
66
|
-
md.expect(:find_user_groups, nil, %w
|
67
|
-
def md.find_user_groups(*
|
66
|
+
md.expect(:find_user_groups, nil, %w[john])
|
67
|
+
def md.find_user_groups(*_args)
|
68
68
|
raise LdapFluff::ActiveDirectory::MemberService::UIDNotFoundException
|
69
69
|
end
|
70
70
|
@ad.member_service = md
|
@@ -72,7 +72,7 @@ class TestAD < MiniTest::Test
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def test_bad_service_user
|
75
|
-
@ldap.expect(:auth, nil, %w
|
75
|
+
@ldap.expect(:auth, nil, %w[service pass])
|
76
76
|
@ldap.expect(:bind, false)
|
77
77
|
@ad.ldap = @ldap
|
78
78
|
assert_raises(LdapFluff::ActiveDirectory::UnauthenticatedException) do
|
@@ -83,39 +83,39 @@ class TestAD < MiniTest::Test
|
|
83
83
|
def test_is_in_groups
|
84
84
|
service_bind
|
85
85
|
basic_user
|
86
|
-
assert_equal(@ad.is_in_groups("john", %w
|
86
|
+
assert_equal(@ad.is_in_groups("john", %w[bros], false), true)
|
87
87
|
end
|
88
88
|
|
89
89
|
def test_is_some_groups
|
90
90
|
service_bind
|
91
91
|
basic_user
|
92
|
-
assert_equal(@ad.is_in_groups("john", %w
|
92
|
+
assert_equal(@ad.is_in_groups("john", %w[bros buds], false), true)
|
93
93
|
end
|
94
94
|
|
95
95
|
def test_isnt_in_all_groups
|
96
96
|
service_bind
|
97
97
|
basic_user
|
98
|
-
assert_equal(@ad.is_in_groups("john", %w
|
98
|
+
assert_equal(@ad.is_in_groups("john", %w[bros buds], true), false)
|
99
99
|
end
|
100
100
|
|
101
101
|
def test_isnt_in_groups
|
102
102
|
service_bind
|
103
103
|
basic_user
|
104
|
-
assert_equal(@ad.is_in_groups("john", %w
|
104
|
+
assert_equal(@ad.is_in_groups("john", %w[broskies], false), false)
|
105
105
|
end
|
106
106
|
|
107
107
|
def test_group_subset
|
108
108
|
service_bind
|
109
109
|
bigtime_user
|
110
|
-
assert_equal(@ad.is_in_groups("john", %w
|
110
|
+
assert_equal(@ad.is_in_groups("john", %w[broskies], true), true)
|
111
111
|
end
|
112
112
|
|
113
113
|
def test_subgroups_in_groups_are_ignored
|
114
|
-
group
|
114
|
+
group = Net::LDAP::Entry.new('foremaners')
|
115
115
|
md = MiniTest::Mock.new
|
116
116
|
2.times { md.expect(:find_group, [group], ['foremaners']) }
|
117
117
|
2.times { service_bind }
|
118
|
-
def md.find_by_dn(
|
118
|
+
def md.find_by_dn(_dn)
|
119
119
|
raise LdapFluff::ActiveDirectory::MemberService::UIDNotFoundException
|
120
120
|
end
|
121
121
|
@ad.member_service = md
|
@@ -125,7 +125,7 @@ class TestAD < MiniTest::Test
|
|
125
125
|
|
126
126
|
def test_user_exists
|
127
127
|
md = MiniTest::Mock.new
|
128
|
-
md.expect(:find_user, 'notnilluser', %w
|
128
|
+
md.expect(:find_user, 'notnilluser', %w[john])
|
129
129
|
@ad.member_service = md
|
130
130
|
service_bind
|
131
131
|
assert(@ad.user_exists?('john'))
|
@@ -133,8 +133,8 @@ class TestAD < MiniTest::Test
|
|
133
133
|
|
134
134
|
def test_missing_user
|
135
135
|
md = MiniTest::Mock.new
|
136
|
-
md.expect(:find_user, nil, %w
|
137
|
-
def md.find_user(
|
136
|
+
md.expect(:find_user, nil, %w[john])
|
137
|
+
def md.find_user(_uid)
|
138
138
|
raise LdapFluff::ActiveDirectory::MemberService::UIDNotFoundException
|
139
139
|
end
|
140
140
|
@ad.member_service = md
|
@@ -144,7 +144,7 @@ class TestAD < MiniTest::Test
|
|
144
144
|
|
145
145
|
def test_group_exists
|
146
146
|
md = MiniTest::Mock.new
|
147
|
-
md.expect(:find_group, 'notnillgroup', %w
|
147
|
+
md.expect(:find_group, 'notnillgroup', %w[broskies])
|
148
148
|
@ad.member_service = md
|
149
149
|
service_bind
|
150
150
|
assert(@ad.group_exists?('broskies'))
|
@@ -152,8 +152,8 @@ class TestAD < MiniTest::Test
|
|
152
152
|
|
153
153
|
def test_missing_group
|
154
154
|
md = MiniTest::Mock.new
|
155
|
-
md.expect(:find_group, nil, %w
|
156
|
-
def md.find_group(
|
155
|
+
md.expect(:find_group, nil, %w[broskies])
|
156
|
+
def md.find_group(_uid)
|
157
157
|
raise LdapFluff::ActiveDirectory::MemberService::GIDNotFoundException
|
158
158
|
end
|
159
159
|
@ad.member_service = md
|
@@ -194,7 +194,7 @@ class TestAD < MiniTest::Test
|
|
194
194
|
nested_group[:cn] = ['katellers']
|
195
195
|
nested_group[:objectclass] = ['organizationalunit']
|
196
196
|
nested_group[:memberof] = ['CN=foremaners,DC=corp,DC=windows,DC=com']
|
197
|
-
nested_user[:objectclass]
|
197
|
+
nested_user[:objectclass] = ['person']
|
198
198
|
|
199
199
|
md = MiniTest::Mock.new
|
200
200
|
2.times { md.expect(:find_group, [group], ['foremaners']) }
|
@@ -208,5 +208,4 @@ class TestAD < MiniTest::Test
|
|
208
208
|
assert_equal @ad.users_for_gid('foremaners'), ['testuser']
|
209
209
|
md.verify
|
210
210
|
end
|
211
|
-
|
212
211
|
end
|
data/test/config_test.rb
CHANGED
@@ -4,27 +4,27 @@ class ConfigTest < MiniTest::Test
|
|
4
4
|
include LdapTestHelper
|
5
5
|
|
6
6
|
def test_unsupported_type
|
7
|
-
assert_raises(LdapFluff::Config::ConfigError) { LdapFluff.new(config_hash.update
|
7
|
+
assert_raises(LdapFluff::Config::ConfigError) { LdapFluff.new(config_hash.update(:server_type => 'inactive_directory')) }
|
8
8
|
end
|
9
9
|
|
10
10
|
def test_load_posix
|
11
|
-
ldap = LdapFluff.new(config_hash.update
|
11
|
+
ldap = LdapFluff.new(config_hash.update(:server_type => 'posix'))
|
12
12
|
assert_instance_of LdapFluff::Posix, ldap.ldap
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_load_ad
|
16
|
-
ldap = LdapFluff.new(config_hash.update
|
16
|
+
ldap = LdapFluff.new(config_hash.update(:server_type => 'active_directory'))
|
17
17
|
assert_instance_of LdapFluff::ActiveDirectory, ldap.ldap
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_load_free_ipa
|
21
|
-
ldap = LdapFluff.new(config_hash.update
|
21
|
+
ldap = LdapFluff.new(config_hash.update(:server_type => 'free_ipa'))
|
22
22
|
assert_instance_of LdapFluff::FreeIPA, ldap.ldap
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_instrumentation_service
|
26
26
|
is = Object.new
|
27
|
-
net_ldap = LdapFluff.new(config_hash.update
|
27
|
+
net_ldap = LdapFluff.new(config_hash.update(:instrumentation_service => is)).ldap.ldap
|
28
28
|
assert_equal is, net_ldap.send(:instrumentation_service)
|
29
29
|
end
|
30
30
|
end
|
@@ -19,7 +19,7 @@ class TestIPAMemberService < MiniTest::Test
|
|
19
19
|
def test_find_user
|
20
20
|
basic_user
|
21
21
|
@ipams.ldap = @ldap
|
22
|
-
assert_equal(%w
|
22
|
+
assert_equal(%w[group bros], @ipams.find_user_groups("john"))
|
23
23
|
@ldap.verify
|
24
24
|
end
|
25
25
|
|
@@ -35,7 +35,7 @@ class TestIPAMemberService < MiniTest::Test
|
|
35
35
|
def test_no_groups
|
36
36
|
entry = Net::LDAP::Entry.new
|
37
37
|
entry['memberof'] = []
|
38
|
-
@ldap.expect(:search, [
|
38
|
+
@ldap.expect(:search, [Net::LDAP::Entry.new, entry], [:filter => ipa_name_filter("john")])
|
39
39
|
@ipams.ldap = @ldap
|
40
40
|
assert_equal([], @ipams.find_user_groups('john'))
|
41
41
|
@ldap.verify
|
@@ -68,5 +68,4 @@ class TestIPAMemberService < MiniTest::Test
|
|
68
68
|
@ipams.find_group('broze')
|
69
69
|
end
|
70
70
|
end
|
71
|
-
|
72
71
|
end
|
data/test/ipa_test.rb
CHANGED
@@ -19,7 +19,7 @@ class TestIPA < MiniTest::Test
|
|
19
19
|
@md = MiniTest::Mock.new
|
20
20
|
user_result = MiniTest::Mock.new
|
21
21
|
user_result.expect(:dn, ipa_user_bind('internet'))
|
22
|
-
@md.expect(:find_user, [user_result], %w
|
22
|
+
@md.expect(:find_user, [user_result], %w[internet])
|
23
23
|
@ipa.member_service = @md
|
24
24
|
service_bind
|
25
25
|
@ldap.expect(:auth, nil, [ipa_user_bind('internet'), "password"])
|
@@ -48,14 +48,14 @@ class TestIPA < MiniTest::Test
|
|
48
48
|
def test_groups
|
49
49
|
service_bind
|
50
50
|
basic_user
|
51
|
-
assert_equal(@ipa.groups_for_uid('john'), %w
|
51
|
+
assert_equal(@ipa.groups_for_uid('john'), %w[bros])
|
52
52
|
end
|
53
53
|
|
54
54
|
def test_bad_user
|
55
55
|
service_bind
|
56
56
|
@md = MiniTest::Mock.new
|
57
|
-
@md.expect(:find_user_groups, nil, %w
|
58
|
-
def @md.find_user_groups(*
|
57
|
+
@md.expect(:find_user_groups, nil, %w[john])
|
58
|
+
def @md.find_user_groups(*_args)
|
59
59
|
raise LdapFluff::FreeIPA::MemberService::UIDNotFoundException
|
60
60
|
end
|
61
61
|
@ipa.member_service = @md
|
@@ -74,42 +74,42 @@ class TestIPA < MiniTest::Test
|
|
74
74
|
def test_is_in_groups
|
75
75
|
service_bind
|
76
76
|
basic_user
|
77
|
-
assert_equal(@ipa.is_in_groups("john", %w
|
77
|
+
assert_equal(@ipa.is_in_groups("john", %w[bros], false), true)
|
78
78
|
end
|
79
79
|
|
80
80
|
def test_is_some_groups
|
81
81
|
service_bind
|
82
82
|
basic_user
|
83
|
-
assert_equal(@ipa.is_in_groups("john", %w
|
83
|
+
assert_equal(@ipa.is_in_groups("john", %w[bros buds], false), true)
|
84
84
|
end
|
85
85
|
|
86
86
|
def test_is_in_all_groupss
|
87
87
|
service_bind
|
88
88
|
bigtime_user
|
89
|
-
assert_equal(true, @ipa.is_in_groups("john", %w
|
89
|
+
assert_equal(true, @ipa.is_in_groups("john", %w[broskies bros], true))
|
90
90
|
end
|
91
91
|
|
92
92
|
def test_isnt_in_all_groups
|
93
93
|
service_bind
|
94
94
|
basic_user
|
95
|
-
assert_equal(@ipa.is_in_groups("john", %w
|
95
|
+
assert_equal(@ipa.is_in_groups("john", %w[bros buds], true), false)
|
96
96
|
end
|
97
97
|
|
98
98
|
def test_isnt_in_groups
|
99
99
|
service_bind
|
100
100
|
basic_user
|
101
|
-
assert_equal(@ipa.is_in_groups("john", %w
|
101
|
+
assert_equal(@ipa.is_in_groups("john", %w[broskies], false), false)
|
102
102
|
end
|
103
103
|
|
104
104
|
def test_group_subset
|
105
105
|
service_bind
|
106
106
|
bigtime_user
|
107
|
-
assert_equal(@ipa.is_in_groups('john', %w
|
107
|
+
assert_equal(@ipa.is_in_groups('john', %w[broskies], true), true)
|
108
108
|
end
|
109
109
|
|
110
110
|
def test_user_exists
|
111
111
|
@md = MiniTest::Mock.new
|
112
|
-
@md.expect(:find_user, 'notnilluser', %w
|
112
|
+
@md.expect(:find_user, 'notnilluser', %w[john])
|
113
113
|
@ipa.member_service = @md
|
114
114
|
service_bind
|
115
115
|
assert(@ipa.user_exists?('john'))
|
@@ -117,8 +117,8 @@ class TestIPA < MiniTest::Test
|
|
117
117
|
|
118
118
|
def test_missing_user
|
119
119
|
@md = MiniTest::Mock.new
|
120
|
-
@md.expect(:find_user, nil, %w
|
121
|
-
def @md.find_user(
|
120
|
+
@md.expect(:find_user, nil, %w[john])
|
121
|
+
def @md.find_user(_uid)
|
122
122
|
raise LdapFluff::FreeIPA::MemberService::UIDNotFoundException
|
123
123
|
end
|
124
124
|
@ipa.member_service = @md
|
@@ -128,7 +128,7 @@ class TestIPA < MiniTest::Test
|
|
128
128
|
|
129
129
|
def test_group_exists
|
130
130
|
@md = MiniTest::Mock.new
|
131
|
-
@md.expect(:find_group, 'notnillgroup', %w
|
131
|
+
@md.expect(:find_group, 'notnillgroup', %w[broskies])
|
132
132
|
@ipa.member_service = @md
|
133
133
|
service_bind
|
134
134
|
assert(@ipa.group_exists?('broskies'))
|
@@ -136,8 +136,8 @@ class TestIPA < MiniTest::Test
|
|
136
136
|
|
137
137
|
def test_missing_group
|
138
138
|
@md = MiniTest::Mock.new
|
139
|
-
@md.expect(:find_group, nil, %w
|
140
|
-
def @md.find_group(
|
139
|
+
@md.expect(:find_group, nil, %w[broskies])
|
140
|
+
def @md.find_group(_uid)
|
141
141
|
raise LdapFluff::FreeIPA::MemberService::GIDNotFoundException
|
142
142
|
end
|
143
143
|
@ipa.member_service = @md
|
@@ -162,6 +162,4 @@ class TestIPA < MiniTest::Test
|
|
162
162
|
assert_equal @ipa.users_for_gid('foremaners'), ['testuser']
|
163
163
|
md.verify
|
164
164
|
end
|
165
|
-
|
166
165
|
end
|
167
|
-
|
data/test/ldap_test.rb
CHANGED
@@ -9,42 +9,42 @@ class TestLDAP < MiniTest::Test
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def test_bind
|
12
|
-
@ldap.expect(:bind?, true, %w
|
12
|
+
@ldap.expect(:bind?, true, %w[john password])
|
13
13
|
@fluff.ldap = @ldap
|
14
14
|
assert_equal(@fluff.authenticate?("john", "password"), true)
|
15
15
|
@ldap.verify
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_groups
|
19
|
-
@ldap.expect(:groups_for_uid, %w
|
19
|
+
@ldap.expect(:groups_for_uid, %w[bros], %w[john])
|
20
20
|
@fluff.ldap = @ldap
|
21
|
-
assert_equal(@fluff.group_list('john'), %w
|
21
|
+
assert_equal(@fluff.group_list('john'), %w[bros])
|
22
22
|
@ldap.verify
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_group_membership
|
26
|
-
@ldap.expect(:is_in_groups, false, ['john', %w
|
26
|
+
@ldap.expect(:is_in_groups, false, ['john', %w[broskies girlfriends], true])
|
27
27
|
@fluff.ldap = @ldap
|
28
|
-
assert_equal(@fluff.is_in_groups?('john', %w
|
28
|
+
assert_equal(@fluff.is_in_groups?('john', %w[broskies girlfriends]), false)
|
29
29
|
@ldap.verify
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_valid_user
|
33
|
-
@ldap.expect(:user_exists?, true, %w
|
33
|
+
@ldap.expect(:user_exists?, true, %w[john])
|
34
34
|
@fluff.ldap = @ldap
|
35
35
|
assert(@fluff.valid_user?('john'))
|
36
36
|
@ldap.verify
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_valid_group
|
40
|
-
@ldap.expect(:group_exists?, true, %w
|
40
|
+
@ldap.expect(:group_exists?, true, %w[broskies])
|
41
41
|
@fluff.ldap = @ldap
|
42
42
|
assert(@fluff.valid_group?('broskies'))
|
43
43
|
@ldap.verify
|
44
44
|
end
|
45
45
|
|
46
46
|
def test_invalid_group
|
47
|
-
@ldap.expect(:group_exists?, false, %w
|
47
|
+
@ldap.expect(:group_exists?, false, %w[broskerinos])
|
48
48
|
@fluff.ldap = @ldap
|
49
49
|
refute(@fluff.valid_group?('broskerinos'))
|
50
50
|
@ldap.verify
|
@@ -56,7 +56,4 @@ class TestLDAP < MiniTest::Test
|
|
56
56
|
refute(@fluff.valid_user?('johnny rotten'))
|
57
57
|
@ldap.verify
|
58
58
|
end
|
59
|
-
|
60
59
|
end
|
61
|
-
|
62
|
-
|