ldap_fluff 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ldap_fluff might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/lib/ldap_fluff/active_directory.rb +10 -15
- data/lib/ldap_fluff/ad_member_service.rb +8 -8
- data/lib/ldap_fluff/config.rb +84 -11
- data/lib/ldap_fluff/freeipa.rb +9 -11
- data/lib/ldap_fluff/freeipa_member_service.rb +4 -3
- data/lib/ldap_fluff/ldap_fluff.rb +1 -4
- data/lib/ldap_fluff/posix.rb +8 -9
- data/lib/ldap_fluff/posix_member_service.rb +7 -11
- data/lib/ldap_fluff.rb +8 -8
- data/test/ad_member_services_test.rb +26 -18
- data/test/ad_test.rb +32 -29
- data/test/config_test.rb +2 -2
- data/test/ipa_member_services_test.rb +16 -9
- data/test/ipa_test.rb +28 -25
- data/test/ldap_test.rb +16 -15
- data/test/lib/ldap_test_helper.rb +2 -2
- data/test/posix_member_services_test.rb +2 -2
- data/test/posix_test.rb +25 -27
- metadata +53 -33
data/test/ad_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
require 'lib/ldap_test_helper'
|
2
2
|
|
3
|
-
class TestAD < MiniTest::
|
3
|
+
class TestAD < MiniTest::Test
|
4
4
|
include LdapTestHelper
|
5
5
|
|
6
6
|
def setup
|
@@ -11,128 +11,131 @@ class TestAD < MiniTest::Unit::TestCase
|
|
11
11
|
|
12
12
|
# default setup for service bind users
|
13
13
|
def service_bind
|
14
|
-
@ldap.expect(:auth, nil,
|
14
|
+
@ldap.expect(:auth, nil, %w(service@internet.com pass))
|
15
15
|
@ldap.expect(:bind, true)
|
16
16
|
@ad.ldap = @ldap
|
17
17
|
end
|
18
18
|
|
19
19
|
def basic_user
|
20
20
|
@md = MiniTest::Mock.new
|
21
|
-
@md.expect(:find_user_groups,
|
21
|
+
@md.expect(:find_user_groups, %w(bros), %w(john))
|
22
22
|
@ad.member_service = @md
|
23
23
|
end
|
24
24
|
|
25
25
|
def bigtime_user
|
26
26
|
@md = MiniTest::Mock.new
|
27
|
-
@md.expect(:find_user_groups,
|
27
|
+
@md.expect(:find_user_groups, %w(bros broskies), %w(john))
|
28
28
|
@ad.member_service = @md
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_good_bind
|
32
|
-
@ldap.expect(:auth, nil,
|
32
|
+
@ldap.expect(:auth, nil, %w(internet@internet.com password))
|
33
33
|
@ldap.expect(:bind, true)
|
34
34
|
@ad.ldap = @ldap
|
35
|
-
assert_equal
|
35
|
+
assert_equal(@ad.bind?("internet", "password"), true)
|
36
36
|
@ldap.verify
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_bad_bind
|
40
|
-
@ldap.expect(:auth, nil,
|
40
|
+
@ldap.expect(:auth, nil, %w(internet@internet.com password))
|
41
41
|
@ldap.expect(:bind, false)
|
42
42
|
@ad.ldap = @ldap
|
43
|
-
assert_equal
|
43
|
+
assert_equal(@ad.bind?("internet", "password"), false)
|
44
44
|
@ldap.verify
|
45
45
|
end
|
46
46
|
|
47
47
|
def test_groups
|
48
48
|
service_bind
|
49
49
|
basic_user
|
50
|
-
assert_equal
|
50
|
+
assert_equal(@ad.groups_for_uid('john'), %w(bros))
|
51
51
|
end
|
52
52
|
|
53
53
|
def test_bad_user
|
54
54
|
service_bind
|
55
55
|
@md = MiniTest::Mock.new
|
56
|
-
@md.expect(:find_user_groups, nil,
|
56
|
+
@md.expect(:find_user_groups, nil, %w(john))
|
57
57
|
def @md.find_user_groups(*args)
|
58
58
|
raise LdapFluff::ActiveDirectory::MemberService::UIDNotFoundException
|
59
59
|
end
|
60
60
|
@ad.member_service = @md
|
61
|
-
assert_equal
|
61
|
+
assert_equal(@ad.groups_for_uid('john'), [])
|
62
62
|
end
|
63
63
|
|
64
64
|
def test_bad_service_user
|
65
|
-
@ldap.expect(:auth, nil,
|
65
|
+
@ldap.expect(:auth, nil, %w(service@internet.com pass))
|
66
66
|
@ldap.expect(:bind, false)
|
67
67
|
@ad.ldap = @ldap
|
68
|
-
assert_raises(LdapFluff::ActiveDirectory::UnauthenticatedActiveDirectoryException)
|
68
|
+
assert_raises(LdapFluff::ActiveDirectory::UnauthenticatedActiveDirectoryException) do
|
69
|
+
@ad.groups_for_uid('john')
|
70
|
+
end
|
69
71
|
end
|
70
72
|
|
71
73
|
def test_is_in_groups
|
72
74
|
service_bind
|
73
75
|
basic_user
|
74
|
-
assert_equal
|
76
|
+
assert_equal(@ad.is_in_groups("john", %w(bros), false), true)
|
75
77
|
end
|
76
78
|
|
77
79
|
def test_is_some_groups
|
78
80
|
service_bind
|
79
81
|
basic_user
|
80
|
-
assert_equal
|
82
|
+
assert_equal(@ad.is_in_groups("john", %w(bros buds), false), true)
|
81
83
|
end
|
82
84
|
|
83
85
|
def test_isnt_in_all_groups
|
84
86
|
service_bind
|
85
87
|
basic_user
|
86
|
-
assert_equal
|
88
|
+
assert_equal(@ad.is_in_groups("john", %w(bros buds), true), false)
|
87
89
|
end
|
88
90
|
|
89
91
|
def test_isnt_in_groups
|
90
92
|
service_bind
|
91
93
|
basic_user
|
92
|
-
assert_equal
|
94
|
+
assert_equal(@ad.is_in_groups("john", %w(broskies), false), false)
|
93
95
|
end
|
94
96
|
|
95
97
|
def test_group_subset
|
96
98
|
service_bind
|
97
99
|
bigtime_user
|
98
|
-
assert_equal
|
100
|
+
assert_equal(@ad.is_in_groups("john", %w(broskies), true), true)
|
99
101
|
end
|
100
102
|
|
101
103
|
def test_user_exists
|
102
104
|
@md = MiniTest::Mock.new
|
103
|
-
@md.expect(:find_user, 'notnilluser',
|
105
|
+
@md.expect(:find_user, 'notnilluser', %w(john))
|
104
106
|
@ad.member_service = @md
|
105
107
|
service_bind
|
106
|
-
assert
|
108
|
+
assert(@ad.user_exists?('john'))
|
107
109
|
end
|
108
110
|
|
109
111
|
def test_missing_user
|
110
112
|
@md = MiniTest::Mock.new
|
111
|
-
@md.expect(:find_user, nil,
|
112
|
-
def @md.find_user
|
113
|
+
@md.expect(:find_user, nil, %w(john))
|
114
|
+
def @md.find_user(uid)
|
113
115
|
raise LdapFluff::ActiveDirectory::MemberService::UIDNotFoundException
|
114
116
|
end
|
115
117
|
@ad.member_service = @md
|
116
118
|
service_bind
|
117
|
-
|
119
|
+
refute(@ad.user_exists?('john'))
|
118
120
|
end
|
119
121
|
|
120
122
|
def test_group_exists
|
121
123
|
@md = MiniTest::Mock.new
|
122
|
-
@md.expect(:find_group, 'notnillgroup',
|
124
|
+
@md.expect(:find_group, 'notnillgroup', %w(broskies))
|
123
125
|
@ad.member_service = @md
|
124
126
|
service_bind
|
125
|
-
assert
|
127
|
+
assert(@ad.group_exists?('broskies'))
|
126
128
|
end
|
127
129
|
|
128
130
|
def test_missing_group
|
129
131
|
@md = MiniTest::Mock.new
|
130
|
-
@md.expect(:find_group, nil,
|
131
|
-
def @md.find_group
|
132
|
+
@md.expect(:find_group, nil, %w(broskies))
|
133
|
+
def @md.find_group(uid)
|
132
134
|
raise LdapFluff::ActiveDirectory::MemberService::GIDNotFoundException
|
133
135
|
end
|
134
136
|
@ad.member_service = @md
|
135
137
|
service_bind
|
136
|
-
|
138
|
+
refute(@ad.group_exists?('broskies'))
|
137
139
|
end
|
140
|
+
|
138
141
|
end
|
data/test/config_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
require 'lib/ldap_test_helper'
|
2
2
|
|
3
|
-
class TestIPAMemberService < MiniTest::
|
3
|
+
class TestIPAMemberService < MiniTest::Test
|
4
4
|
include LdapTestHelper
|
5
5
|
|
6
6
|
def setup
|
@@ -20,45 +20,52 @@ class TestIPAMemberService < MiniTest::Unit::TestCase
|
|
20
20
|
def test_find_user
|
21
21
|
basic_user
|
22
22
|
@ipams.ldap = @ldap
|
23
|
-
assert_equal
|
23
|
+
assert_equal(%w(group bros), @ipams.find_user_groups("john"))
|
24
24
|
@ldap.verify
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_missing_user
|
28
28
|
@ldap.expect(:search, nil, [:filter => ipa_name_filter("john")])
|
29
29
|
@ipams.ldap = @ldap
|
30
|
-
assert_raises(LdapFluff::FreeIPA::MemberService::UIDNotFoundException)
|
30
|
+
assert_raises(LdapFluff::FreeIPA::MemberService::UIDNotFoundException) do
|
31
|
+
@ipams.find_user_groups("john").data
|
32
|
+
end
|
31
33
|
@ldap.verify
|
32
34
|
end
|
33
35
|
|
34
36
|
def test_no_groups
|
35
37
|
@ldap.expect(:search, ['', { :memberof => [] }], [:filter => ipa_name_filter("john")])
|
36
38
|
@ipams.ldap = @ldap
|
37
|
-
assert_equal
|
39
|
+
assert_equal([], @ipams.find_user_groups('john'))
|
38
40
|
@ldap.verify
|
39
41
|
end
|
40
42
|
|
41
43
|
def test_find_good_user
|
42
44
|
basic_user
|
43
45
|
@ipams.ldap = @ldap
|
44
|
-
assert_equal
|
46
|
+
assert_equal(ipa_user_payload, @ipams.find_user('john'))
|
45
47
|
end
|
46
48
|
|
47
49
|
def test_find_missing_user
|
48
50
|
@ldap.expect(:search, nil, [:filter => ipa_name_filter("john")])
|
49
51
|
@ipams.ldap = @ldap
|
50
|
-
assert_raises(LdapFluff::FreeIPA::MemberService::UIDNotFoundException)
|
52
|
+
assert_raises(LdapFluff::FreeIPA::MemberService::UIDNotFoundException) do
|
53
|
+
@ipams.find_user('john')
|
54
|
+
end
|
51
55
|
end
|
52
56
|
|
53
57
|
def test_find_good_group
|
54
58
|
basic_group
|
55
59
|
@ipams.ldap = @ldap
|
56
|
-
assert_equal
|
60
|
+
assert_equal(ipa_group_payload, @ipams.find_group('broze'))
|
57
61
|
end
|
58
62
|
|
59
63
|
def test_find_missing_group
|
60
64
|
@ldap.expect(:search, nil, [:filter => ipa_group_filter("broze"), :base => @config.group_base])
|
61
65
|
@ipams.ldap = @ldap
|
62
|
-
assert_raises(LdapFluff::FreeIPA::MemberService::GIDNotFoundException)
|
66
|
+
assert_raises(LdapFluff::FreeIPA::MemberService::GIDNotFoundException) do
|
67
|
+
@ipams.find_group('broze')
|
68
|
+
end
|
63
69
|
end
|
70
|
+
|
64
71
|
end
|
data/test/ipa_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
require 'lib/ldap_test_helper'
|
2
2
|
|
3
|
-
class TestIPA < MiniTest::
|
3
|
+
class TestIPA < MiniTest::Test
|
4
4
|
include LdapTestHelper
|
5
5
|
|
6
6
|
def setup
|
@@ -18,13 +18,13 @@ class TestIPA < MiniTest::Unit::TestCase
|
|
18
18
|
|
19
19
|
def basic_user
|
20
20
|
@md = MiniTest::Mock.new
|
21
|
-
@md.expect(:find_user_groups,
|
21
|
+
@md.expect(:find_user_groups, %w(bros), %w(john))
|
22
22
|
@ipa.member_service = @md
|
23
23
|
end
|
24
24
|
|
25
25
|
def bigtime_user
|
26
26
|
@md = MiniTest::Mock.new
|
27
|
-
@md.expect(:find_user_groups,
|
27
|
+
@md.expect(:find_user_groups, %w(bros broskies), %w(john))
|
28
28
|
@ipa.member_service = @md
|
29
29
|
end
|
30
30
|
|
@@ -32,7 +32,7 @@ class TestIPA < MiniTest::Unit::TestCase
|
|
32
32
|
@ldap.expect(:auth, nil, [ipa_user_bind('internet'), "password"])
|
33
33
|
@ldap.expect(:bind, true)
|
34
34
|
@ipa.ldap = @ldap
|
35
|
-
assert_equal
|
35
|
+
assert_equal(@ipa.bind?("internet", "password"), true)
|
36
36
|
@ldap.verify
|
37
37
|
end
|
38
38
|
|
@@ -40,100 +40,103 @@ class TestIPA < MiniTest::Unit::TestCase
|
|
40
40
|
@ldap.expect(:auth, nil, [ipa_user_bind('internet'), "password"])
|
41
41
|
@ldap.expect(:bind, false)
|
42
42
|
@ipa.ldap = @ldap
|
43
|
-
assert_equal
|
43
|
+
assert_equal(@ipa.bind?("internet", "password"), false)
|
44
44
|
@ldap.verify
|
45
45
|
end
|
46
46
|
|
47
47
|
def test_groups
|
48
48
|
service_bind
|
49
49
|
basic_user
|
50
|
-
assert_equal
|
50
|
+
assert_equal(@ipa.groups_for_uid('john'), %w(bros))
|
51
51
|
end
|
52
52
|
|
53
53
|
def test_bad_user
|
54
54
|
service_bind
|
55
55
|
@md = MiniTest::Mock.new
|
56
|
-
@md.expect(:find_user_groups, nil,
|
56
|
+
@md.expect(:find_user_groups, nil, %w(john))
|
57
57
|
def @md.find_user_groups(*args)
|
58
58
|
raise LdapFluff::FreeIPA::MemberService::UIDNotFoundException
|
59
59
|
end
|
60
60
|
@ipa.member_service = @md
|
61
|
-
assert_equal
|
61
|
+
assert_equal(@ipa.groups_for_uid('john'), [])
|
62
62
|
end
|
63
63
|
|
64
64
|
def test_bad_service_user
|
65
65
|
@ldap.expect(:auth, nil, [ipa_user_bind('service'), "pass"])
|
66
66
|
@ldap.expect(:bind, false)
|
67
67
|
@ipa.ldap = @ldap
|
68
|
-
assert_raises(LdapFluff::FreeIPA::UnauthenticatedFreeIPAException)
|
68
|
+
assert_raises(LdapFluff::FreeIPA::UnauthenticatedFreeIPAException) do
|
69
|
+
@ipa.groups_for_uid('john')
|
70
|
+
end
|
69
71
|
end
|
70
72
|
|
71
73
|
def test_is_in_groups
|
72
74
|
service_bind
|
73
75
|
basic_user
|
74
|
-
assert_equal
|
76
|
+
assert_equal(@ipa.is_in_groups("john", %w(bros), false), true)
|
75
77
|
end
|
76
78
|
|
77
79
|
def test_is_some_groups
|
78
80
|
service_bind
|
79
81
|
basic_user
|
80
|
-
assert_equal
|
82
|
+
assert_equal(@ipa.is_in_groups("john", %w(bros buds), false), true)
|
81
83
|
end
|
82
84
|
|
83
85
|
def test_isnt_in_all_groups
|
84
86
|
service_bind
|
85
87
|
basic_user
|
86
|
-
assert_equal
|
88
|
+
assert_equal(@ipa.is_in_groups("john", %w(bros buds), true), false)
|
87
89
|
end
|
88
90
|
|
89
91
|
def test_isnt_in_groups
|
90
92
|
service_bind
|
91
93
|
basic_user
|
92
|
-
assert_equal
|
94
|
+
assert_equal(@ipa.is_in_groups("john", %w(broskies), false), false)
|
93
95
|
end
|
94
96
|
|
95
97
|
def test_group_subset
|
96
98
|
service_bind
|
97
99
|
bigtime_user
|
98
|
-
assert_equal
|
100
|
+
assert_equal(@ipa.is_in_groups('john', %w(broskies), true), true)
|
99
101
|
end
|
100
102
|
|
101
103
|
def test_user_exists
|
102
104
|
@md = MiniTest::Mock.new
|
103
|
-
@md.expect(:find_user, 'notnilluser',
|
105
|
+
@md.expect(:find_user, 'notnilluser', %w(john))
|
104
106
|
@ipa.member_service = @md
|
105
107
|
service_bind
|
106
|
-
assert
|
108
|
+
assert(@ipa.user_exists?('john'))
|
107
109
|
end
|
108
110
|
|
109
111
|
def test_missing_user
|
110
112
|
@md = MiniTest::Mock.new
|
111
|
-
@md.expect(:find_user, nil,
|
112
|
-
def @md.find_user
|
113
|
+
@md.expect(:find_user, nil, %w(john))
|
114
|
+
def @md.find_user(uid)
|
113
115
|
raise LdapFluff::FreeIPA::MemberService::UIDNotFoundException
|
114
116
|
end
|
115
117
|
@ipa.member_service = @md
|
116
118
|
service_bind
|
117
|
-
|
119
|
+
refute(@ipa.user_exists?('john'))
|
118
120
|
end
|
119
121
|
|
120
122
|
def test_group_exists
|
121
123
|
@md = MiniTest::Mock.new
|
122
|
-
@md.expect(:find_group, 'notnillgroup',
|
124
|
+
@md.expect(:find_group, 'notnillgroup', %w(broskies))
|
123
125
|
@ipa.member_service = @md
|
124
126
|
service_bind
|
125
|
-
assert
|
127
|
+
assert(@ipa.group_exists?('broskies'))
|
126
128
|
end
|
127
129
|
|
128
130
|
def test_missing_group
|
129
131
|
@md = MiniTest::Mock.new
|
130
|
-
@md.expect(:find_group, nil,
|
131
|
-
def @md.find_group
|
132
|
+
@md.expect(:find_group, nil, %w(broskies))
|
133
|
+
def @md.find_group(uid)
|
132
134
|
raise LdapFluff::FreeIPA::MemberService::GIDNotFoundException
|
133
135
|
end
|
134
136
|
@ipa.member_service = @md
|
135
137
|
service_bind
|
136
|
-
|
138
|
+
refute(@ipa.group_exists?('broskies'))
|
137
139
|
end
|
140
|
+
|
138
141
|
end
|
139
142
|
|
data/test/ldap_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
require 'lib/ldap_test_helper'
|
2
2
|
|
3
|
-
class TestLDAP < MiniTest::
|
3
|
+
class TestLDAP < MiniTest::Test
|
4
4
|
include LdapTestHelper
|
5
5
|
|
6
6
|
def setup
|
@@ -10,53 +10,54 @@ class TestLDAP < MiniTest::Unit::TestCase
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_bind
|
13
|
-
@ldap.expect(:bind?, true,
|
13
|
+
@ldap.expect(:bind?, true, %w(john password))
|
14
14
|
@fluff.ldap = @ldap
|
15
|
-
assert_equal
|
15
|
+
assert_equal(@fluff.authenticate?("john", "password"), true)
|
16
16
|
@ldap.verify
|
17
17
|
end
|
18
18
|
|
19
19
|
def test_groups
|
20
|
-
@ldap.expect(:groups_for_uid,
|
20
|
+
@ldap.expect(:groups_for_uid, %w(bros), %w(john))
|
21
21
|
@fluff.ldap = @ldap
|
22
|
-
assert_equal
|
22
|
+
assert_equal(@fluff.group_list('john'), %w(bros))
|
23
23
|
@ldap.verify
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_group_membership
|
27
|
-
@ldap.expect(:is_in_groups, false, ['john',
|
27
|
+
@ldap.expect(:is_in_groups, false, ['john', %w(broskies girlfriends), true])
|
28
28
|
@fluff.ldap = @ldap
|
29
|
-
assert_equal
|
29
|
+
assert_equal(@fluff.is_in_groups?('john', %w(broskies girlfriends)), false)
|
30
30
|
@ldap.verify
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_valid_user
|
34
|
-
@ldap.expect(:user_exists?, true,
|
34
|
+
@ldap.expect(:user_exists?, true, %w(john))
|
35
35
|
@fluff.ldap = @ldap
|
36
|
-
assert
|
36
|
+
assert(@fluff.valid_user?('john'))
|
37
37
|
@ldap.verify
|
38
38
|
end
|
39
39
|
|
40
40
|
def test_valid_group
|
41
|
-
@ldap.expect(:group_exists?, true,
|
41
|
+
@ldap.expect(:group_exists?, true, %w(broskies))
|
42
42
|
@fluff.ldap = @ldap
|
43
|
-
assert
|
43
|
+
assert(@fluff.valid_group?('broskies'))
|
44
44
|
@ldap.verify
|
45
45
|
end
|
46
46
|
|
47
47
|
def test_invalid_group
|
48
|
-
@ldap.expect(:group_exists?, false,
|
48
|
+
@ldap.expect(:group_exists?, false, %w(broskerinos))
|
49
49
|
@fluff.ldap = @ldap
|
50
|
-
|
50
|
+
refute(@fluff.valid_group?('broskerinos'))
|
51
51
|
@ldap.verify
|
52
52
|
end
|
53
53
|
|
54
54
|
def test_invalid_user
|
55
55
|
@ldap.expect(:user_exists?, false, ['johnny rotten'])
|
56
56
|
@fluff.ldap = @ldap
|
57
|
-
|
57
|
+
refute(@fluff.valid_user?('johnny rotten'))
|
58
58
|
@ldap.verify
|
59
59
|
end
|
60
|
+
|
60
61
|
end
|
61
62
|
|
62
63
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require 'ldap_fluff'
|
2
2
|
require 'ostruct'
|
3
3
|
require 'net/ldap'
|
4
4
|
require 'minitest/autorun'
|
@@ -20,7 +20,7 @@ module LdapTestHelper
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def config
|
23
|
-
@config ||=
|
23
|
+
@config ||= LdapFluff::Config.new config_hash
|
24
24
|
end
|
25
25
|
|
26
26
|
def ad_name_filter(name)
|
data/test/posix_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
require 'lib/ldap_test_helper'
|
2
2
|
|
3
|
-
class TestPosix < MiniTest::
|
3
|
+
class TestPosix < MiniTest::Test
|
4
4
|
include LdapTestHelper
|
5
5
|
|
6
6
|
def setup
|
@@ -11,88 +11,86 @@ class TestPosix < MiniTest::Unit::TestCase
|
|
11
11
|
|
12
12
|
def basic_user
|
13
13
|
@md = MiniTest::Mock.new
|
14
|
-
@md.expect(:find_user_groups,
|
14
|
+
@md.expect(:find_user_groups, %w(bros), %w(john))
|
15
15
|
@posix.member_service = @md
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_groups
|
19
19
|
basic_user
|
20
|
-
assert_equal
|
20
|
+
assert_equal(@posix.groups_for_uid("john"), %w(bros))
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_missing_user
|
24
24
|
@md = MiniTest::Mock.new
|
25
|
-
@md.expect(:find_user_groups, [],
|
25
|
+
@md.expect(:find_user_groups, [], %w(john))
|
26
26
|
@posix.member_service = @md
|
27
|
-
assert_equal
|
27
|
+
assert_equal([], @posix.groups_for_uid('john'))
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_isnt_in_groups
|
31
31
|
basic_user
|
32
32
|
@md = MiniTest::Mock.new
|
33
|
-
@md.expect(:times_in_groups, 0, ['john',
|
33
|
+
@md.expect(:times_in_groups, 0, ['john', %w(bros), true])
|
34
34
|
@posix.member_service = @md
|
35
|
-
assert_equal
|
35
|
+
assert_equal(@posix.is_in_groups('john', %w(bros), true), false)
|
36
36
|
end
|
37
37
|
|
38
38
|
def test_is_in_groups
|
39
39
|
basic_user
|
40
40
|
@md = MiniTest::Mock.new
|
41
|
-
@md.expect(:times_in_groups, 1, ['john',
|
41
|
+
@md.expect(:times_in_groups, 1, ['john', %w(bros), true])
|
42
42
|
@posix.member_service = @md
|
43
|
-
assert_equal
|
43
|
+
assert_equal(@posix.is_in_groups('john', %w(bros), true), true)
|
44
44
|
end
|
45
45
|
|
46
46
|
def test_is_in_no_groups
|
47
47
|
basic_user
|
48
|
-
assert_equal
|
48
|
+
assert_equal(@posix.is_in_groups('john', [], true), true)
|
49
49
|
end
|
50
50
|
|
51
51
|
def test_good_bind
|
52
|
-
@ldap.expect(:
|
53
|
-
@ldap.expect(:bind, true)
|
52
|
+
@ldap.expect(:bind_as, true, [:filter => "(uid=internet)", :password => "password"])
|
54
53
|
@posix.ldap = @ldap
|
55
|
-
assert_equal
|
54
|
+
assert_equal(@posix.bind?("internet", "password"), true)
|
56
55
|
end
|
57
56
|
|
58
57
|
def test_bad_bind
|
59
|
-
@ldap.expect(:
|
60
|
-
@ldap.expect(:bind, false)
|
58
|
+
@ldap.expect(:bind_as, false, [:filter => "(uid=internet)", :password => "password"])
|
61
59
|
@posix.ldap = @ldap
|
62
|
-
assert_equal
|
60
|
+
assert_equal(@posix.bind?("internet", "password"), false)
|
63
61
|
end
|
64
62
|
|
65
63
|
def test_user_exists
|
66
64
|
@md = MiniTest::Mock.new
|
67
|
-
@md.expect(:find_user, 'notnilluser',
|
65
|
+
@md.expect(:find_user, 'notnilluser', %w(john))
|
68
66
|
@posix.member_service = @md
|
69
|
-
assert
|
67
|
+
assert(@posix.user_exists?('john'))
|
70
68
|
end
|
71
69
|
|
72
70
|
def test_missing_user
|
73
71
|
@md = MiniTest::Mock.new
|
74
|
-
@md.expect(:find_user, nil,
|
75
|
-
def @md.find_user
|
72
|
+
@md.expect(:find_user, nil, %w(john))
|
73
|
+
def @md.find_user(uid)
|
76
74
|
raise LdapFluff::Posix::MemberService::UIDNotFoundException
|
77
75
|
end
|
78
76
|
@posix.member_service = @md
|
79
|
-
|
77
|
+
refute(@posix.user_exists?('john'))
|
80
78
|
end
|
81
79
|
|
82
80
|
def test_group_exists
|
83
81
|
@md = MiniTest::Mock.new
|
84
|
-
@md.expect(:find_group, 'notnillgroup',
|
82
|
+
@md.expect(:find_group, 'notnillgroup', %w(broskies))
|
85
83
|
@posix.member_service = @md
|
86
|
-
assert
|
84
|
+
assert(@posix.group_exists?('broskies'))
|
87
85
|
end
|
88
86
|
|
89
87
|
def test_missing_group
|
90
88
|
@md = MiniTest::Mock.new
|
91
|
-
@md.expect(:find_group, nil,
|
92
|
-
def @md.find_group
|
89
|
+
@md.expect(:find_group, nil, %w(broskies))
|
90
|
+
def @md.find_group(uid)
|
93
91
|
raise LdapFluff::Posix::MemberService::GIDNotFoundException
|
94
92
|
end
|
95
93
|
@posix.member_service = @md
|
96
|
-
|
94
|
+
refute(@posix.group_exists?('broskies'))
|
97
95
|
end
|
98
96
|
end
|