radum 0.0.1

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.
@@ -0,0 +1,220 @@
1
+ require 'test/unit'
2
+ require 'radum'
3
+
4
+ # This tests the AD class.
5
+ class TC_Ad < Test::Unit::TestCase
6
+ def setup
7
+ @ad1a = RADUM::AD.new :root => "dc=vmware,dc=local", :password => "test1a"
8
+ @ad1b = RADUM::AD.new :root => "dc=vmware, dc=local", :password => "test1b"
9
+ @ad1c = RADUM::AD.new :root => "DC=VMWARE,DC=LOCAL", :password => "test1c"
10
+ @ad2 = RADUM::AD.new :root => "dc=vmware,dc=com", :password => "test2"
11
+ @c1_ad1a = RADUM::Container.new :name => "ou=People", :directory => @ad1a
12
+ @c2_ad2 = RADUM::Container.new :name => "ou=Staff,ou=People",
13
+ :directory => @ad2
14
+ # These objects are to test AD#remove_container and AD#destroy_container.
15
+ @rm_cn1 = RADUM::Container.new :name => "ou=rm", :directory => @ad1a
16
+ @rm_cn2 = RADUM::Container.new :name => "ou=no", :directory => @ad1a
17
+ @rm_wg1 = RADUM::Group.new :name => "wg1", :container => @rm_cn1
18
+ @rm_wg2 = RADUM::Group.new :name => "wg2", :container => @rm_cn2
19
+ @rm_wg2.add_group @rm_wg1
20
+ @rm_wg3 = RADUM::Group.new :name => "wg3", :container => @rm_cn2
21
+ @rm_ug1 = RADUM::UNIXGroup.new :name => "ug1", :container => @rm_cn1,
22
+ :gid => 1000
23
+ @rm_ug2 = RADUM::UNIXGroup.new :name => "ug2", :container => @rm_cn2,
24
+ :gid => 1001
25
+ @rm_ug3 = RADUM::UNIXGroup.new :name => "ug3", :container => @rm_cn2,
26
+ :gid => 1002
27
+ @rm_wu1 = RADUM::User.new :username => "wu1", :container => @rm_cn1,
28
+ :primary_group => @rm_wg2
29
+ @rm_wu1.add_group @rm_wg1
30
+ @rm_wu1.add_group @rm_wg3
31
+ @rm_wu2 = RADUM::User.new :username => "wu2", :container => @rm_cn2,
32
+ :primary_group => @rm_wg2
33
+ @rm_wu2.add_group @rm_wg1
34
+ @rm_wu2.add_group @rm_wg3
35
+ @rm_uu1 = RADUM::UNIXUser.new :username => "uu1", :container => @rm_cn1,
36
+ :primary_group => @rm_ug3, :uid => 1000,
37
+ :unix_main_group => @rm_ug2,
38
+ :shell => '/bin/bash',
39
+ :home_directory => '/home/uu1'
40
+ @rm_uu2 = RADUM::UNIXUser.new :username => "uu2", :container => @rm_cn2,
41
+ :primary_group => @rm_wg2, :uid => 1001,
42
+ :unix_main_group => @rm_ug2,
43
+ :shell => '/bin/bash',
44
+ :home_directory => '/home/uu2'
45
+ @rm_uu2.add_group @rm_wg1
46
+ end
47
+
48
+ def test_equal
49
+ assert(@ad1a == @ad1a, "Should be equal")
50
+ end
51
+
52
+ def test_equal_domain
53
+ assert(@ad1a.domain == @ad1c.domain, "Should be equal domain attribute")
54
+ end
55
+
56
+ def test_not_equal
57
+ assert(@ad1a != @ad2, "Should not be equal")
58
+ end
59
+
60
+ def test_add_container_different_directory_exception
61
+ assert_raise RuntimeError do
62
+ @ad1a.add_container @c2_ad2
63
+ end
64
+ end
65
+
66
+ def test_add_container
67
+ assert_block("Should have added exactly one container") do
68
+ # Containers add themselves to directories on initialization, so this
69
+ # would be an attempt to add a second time. We want to be totally certain,
70
+ # so the add is done a third time anyway. Note that the cn=Users container
71
+ # is added automatically and we did add a second and third one in testing
72
+ # initialization, so the count should be 4.
73
+ @ad1a.add_container @c1_ad1a
74
+ @ad1a.add_container @c1_ad1a
75
+ @ad1a.containers.length == 4
76
+ end
77
+ end
78
+
79
+ def test_remove_container_ad_removed_flag_set
80
+ assert_block("Should have set removed container ad_removed flag") do
81
+ @ad1a.remove_container @c1_ad1a
82
+ @c1_ad1a.removed? == true
83
+ end
84
+ end
85
+
86
+ def test_remove_container_false
87
+ # We don't want to see the actual warning messages.
88
+ RADUM::logger.default_level = RADUM::LOG_NONE
89
+ assert(@ad1a.remove_container(@rm_cn2) == false,
90
+ "Should not have removed container")
91
+ end
92
+
93
+ def test_remove_container_effects
94
+ rm_cn1_users = @rm_cn1.users.clone
95
+ rm_cn1_groups = @rm_cn1.groups.clone
96
+ assert(@ad1a.remove_container(@rm_cn1) == true,
97
+ "Should have removed container")
98
+
99
+ @rm_cn1.removed_users.each do |user|
100
+ assert(rm_cn1_users.include?(user) == true,
101
+ "User should be in removed_users array for container")
102
+ end
103
+
104
+ assert(@rm_cn1.users.length == 0, "Container should have no users")
105
+
106
+ @rm_cn1.removed_groups.each do |group|
107
+ assert(rm_cn1_groups.include?(group) == true,
108
+ "Group should be in removed_groups array for container")
109
+ end
110
+
111
+ assert(@rm_cn1.groups.length == 0, "Container should have no groups")
112
+
113
+ @ad1a.users.each do |user|
114
+ assert(rm_cn1_users.include?(user) == false,
115
+ "User should not be in users array for container")
116
+ assert(@rm_cn1.removed_users.include?(user) == false,
117
+ "User should not be in removed_users array for container")
118
+
119
+ # Make sure each user sees the removed groups correctly.
120
+ rm_cn1_groups.each do |group|
121
+ assert(user.groups.include?(group) == false,
122
+ "User should not have group in groups array")
123
+ end
124
+ end
125
+
126
+ @ad1a.groups.each do |group|
127
+ assert(rm_cn1_groups.include?(group) == false,
128
+ "Group should not be in groups array for container")
129
+ assert(@rm_cn1.removed_groups.include?(group) == false,
130
+ "Group should not be in removed_groups array for container")
131
+
132
+ # Make sure each group sees the removed users correctly.
133
+ rm_cn1_users.each do |user|
134
+ assert(group.users.include?(user) == false,
135
+ "Group should not have user in users array")
136
+ end
137
+
138
+ # Make sure each group sees the removed groups correctly.
139
+ rm_cn1_groups.each do |group|
140
+ assert(group.groups.include?(group) == false,
141
+ "Group should not have group in groups array")
142
+ end
143
+ end
144
+
145
+ # Manually check @rm_cn2 objects to make sure they see all removed objects
146
+ # in their removed_groups and removed_users arrays.
147
+ assert(@rm_wg2.removed_groups.include?(@rm_wg1) == true,
148
+ "wg1 should be in wg2's removed_groups array")
149
+ assert(@rm_ug2.removed_users.include?(@rm_uu1) == true,
150
+ "uu1 should be in ug2's removed_users array")
151
+ assert(@rm_wg3.removed_users.include?(@rm_wu1) == true,
152
+ "wu1 should be in wg3's removed_users array")
153
+ assert(@rm_wu2.removed_groups.include?(@rm_wg1) == true,
154
+ "wg1 should be in wu2's removed_groups array")
155
+ assert(@rm_uu2.removed_groups.include?(@rm_wg1) == true,
156
+ "wg1 should be in uu2's removed_groups array")
157
+ end
158
+
159
+ def test_destroy_container_false
160
+ # We don't want to see the actual warning messages.
161
+ RADUM::logger.default_level = RADUM::LOG_NONE
162
+ assert(@ad1a.destroy_container(@rm_cn2) == false,
163
+ "Should not have destroyed container")
164
+ end
165
+
166
+ def test_destroy_container_effects
167
+ rm_cn1_users = @rm_cn1.users.clone
168
+ rm_cn1_groups = @rm_cn1.groups.clone
169
+ assert(@ad1a.destroy_container(@rm_cn1) == true,
170
+ "Should have removed container")
171
+
172
+ assert(@rm_cn1.users.length == 0, "Container should have no users")
173
+ assert(@rm_cn1.removed_users.length == 0,
174
+ "Container should have no removed users")
175
+ assert(@rm_cn1.groups.length == 0, "Container should have no groups")
176
+ assert(@rm_cn1.removed_groups.length == 0,
177
+ "Container should have no removed groups")
178
+
179
+ @ad1a.users.each do |user|
180
+ assert(rm_cn1_users.include?(user) == false,
181
+ "User should not be in users array for container")
182
+
183
+ # Make sure each user sees the removed groups correctly.
184
+ rm_cn1_groups.each do |group|
185
+ assert(user.groups.include?(group) == false,
186
+ "User should not have group in groups array")
187
+ end
188
+ end
189
+
190
+ @ad1a.groups.each do |group|
191
+ assert(rm_cn1_groups.include?(group) == false,
192
+ "Group should not be in groups array for container")
193
+
194
+ # Make sure each group sees the removed users correctly.
195
+ rm_cn1_users.each do |user|
196
+ assert(group.users.include?(user) == false,
197
+ "Group should not have user in users array")
198
+ end
199
+
200
+ # Make sure each group sees the removed groups correctly.
201
+ rm_cn1_groups.each do |group|
202
+ assert(group.groups.include?(group) == false,
203
+ "Group should not have group in groups array")
204
+ end
205
+ end
206
+
207
+ # Manually check @rm_cn2 objects to make sure they see all removed objects
208
+ # in their removed_groups and removed_users arrays.
209
+ assert(@rm_wg2.removed_groups.include?(@rm_wg1) == false,
210
+ "wg1 should not be in wg2's removed_groups array")
211
+ assert(@rm_ug2.removed_users.include?(@rm_uu1) == false,
212
+ "uu1 should not be in ug2's removed_users array")
213
+ assert(@rm_wg3.removed_users.include?(@rm_wu1) == false,
214
+ "wu1 should not be in wg3's removed_users array")
215
+ assert(@rm_wu2.removed_groups.include?(@rm_wg1) == false,
216
+ "wg1 should not be in wu2's removed_groups array")
217
+ assert(@rm_uu2.removed_groups.include?(@rm_wg1) == false,
218
+ "wg1 should not be in uu2's removed_groups array")
219
+ end
220
+ end
@@ -0,0 +1,205 @@
1
+ require 'test/unit'
2
+ require 'radum'
3
+
4
+ # This tests the Container class.
5
+ class TC_Container < Test::Unit::TestCase
6
+ def setup
7
+ @ad1 = RADUM::AD.new :root => "dc=vmware,dc=local", :password => "test1"
8
+ @ad2 = RADUM::AD.new :root => "dc=vmware,dc=com", :password => "test2"
9
+ @c1_ad1 = RADUM::Container.new :name => "ou=People", :directory => @ad1
10
+ @c2_ad1 = RADUM::Container.new :name => "ou=Staff, ou=People",
11
+ :directory => @ad1
12
+ @c3_ad1 = RADUM::Container.new :name => "cn=Test", :directory => @ad1
13
+ @c4_ad2 = RADUM::Container.new :name => "cn=Test", :directory => @ad2
14
+ @g1_c1_ad1 = RADUM::Group.new :name => "staff", :container => @c1_ad1
15
+ @g2_c4_ad2 = RADUM::Group.new :name => "enable", :container => @c4_ad2
16
+ @g3_c3_ad1 = RADUM::Group.new :name => "test", :container => @c3_ad1
17
+ @u1_c1_ad1 = RADUM::User.new :username => "user", :container=> @c1_ad1,
18
+ :primary_group => @g1_c1_ad1
19
+ @u2_c4_ad2 = RADUM::User.new :username => "user", :container => @c4_ad2,
20
+ :primary_group => @g2_c4_ad2
21
+ @u3_c3_ad1 = RADUM::User.new :username => "remove", :container => @c3_ad1,
22
+ :primary_group => @g1_c1_ad1
23
+ end
24
+
25
+ def test_removed_flag_false
26
+ assert(@c1_ad1.removed? == false, "ad_removed flag should be false")
27
+ end
28
+
29
+ def test_no_spaces
30
+ assert(@c2_ad1.name.split(/\s+/).length == 1,
31
+ "Should be no spaces in name")
32
+ end
33
+
34
+ def test_equal_exception
35
+ assert_raise RuntimeError do
36
+ RADUM::Container.new :name => "ou=People", :directory => @ad1
37
+ end
38
+ end
39
+
40
+ def test_equal_case_insensitive_exception
41
+ assert_raise RuntimeError do
42
+ RADUM::Container.new :name => "ou=people", :directory => @ad1
43
+ end
44
+ end
45
+
46
+ def test_equal_spaces_exception
47
+ assert_raise RuntimeError do
48
+ RADUM::Container.new :name => "ou=Staff,ou=People", :directory => @ad1
49
+ end
50
+ end
51
+
52
+ def test_not_equal
53
+ assert(@c1_ad1 != @c3_ad1, "Should not be equal")
54
+ end
55
+
56
+ def test_not_equal_different_directory
57
+ assert(@c3_ad1 != @c4_ad2, "Should not be equal")
58
+ end
59
+
60
+ def test_add_user
61
+ assert_block("Should have added exactly one user") do
62
+ # Users add themselves to containers on initialization, so this would be
63
+ # an attempt to add a second time. We want to be totally certain, so the
64
+ # add is done a third time anyway.
65
+ @c1_ad1.add_user @u1_c1_ad1
66
+ @c1_ad1.add_user @u1_c1_ad1
67
+ @c1_ad1.users.length == 1
68
+ end
69
+ end
70
+
71
+ def test_add_user_removed_flag_manually_set
72
+ assert_block("Should have added exactly one user") do
73
+ # Users add themselves to containers on initialization, so this would be
74
+ # an attempt to add a second time. We want to be totally certain, so the
75
+ # add is done a third time anyway.
76
+ @c1_ad1.add_user @u1_c1_ad1
77
+ @u1_c1_ad1.set_removed
78
+ @c1_ad1.add_user @u1_c1_ad1
79
+ @c1_ad1.users.length == 1
80
+ end
81
+ end
82
+
83
+ def test_add_user_different_container_exception
84
+ assert_raise RuntimeError do
85
+ @c1_ad1.add_user @u2_c4_ad2
86
+ end
87
+ end
88
+
89
+ def test_remove_user_different_container_exception
90
+ assert_raise RuntimeError do
91
+ @c1_ad1.remove_user @u3_c3_ad1
92
+ end
93
+ end
94
+
95
+ def test_remove_user_removed_flag_set
96
+ assert_block("Should have set removed user removed flag") do
97
+ @c1_ad1.remove_user @u1_c1_ad1
98
+ @u1_c1_ad1.removed? == true
99
+ end
100
+ end
101
+
102
+ def test_add_group
103
+ assert_block("Should have added exactly one group") do
104
+ # Groups add themselves to containers on initialization, so this would be
105
+ # an attempt to add a second time. We want to be totally certain, so the
106
+ # add is done a third time anyway.
107
+ @c1_ad1.add_group @g1_c1_ad1
108
+ @c1_ad1.add_group @g1_c1_ad1
109
+ @c1_ad1.groups.length == 1
110
+ end
111
+ end
112
+
113
+ def test_add_group_removed_flag_manually_set
114
+ assert_block("Should have added exactly one group") do
115
+ # Groups add themselves to containers on initialization, so this would be
116
+ # an attempt to add a second time. We want to be totally certain, so the
117
+ # add is done a third time anyway.
118
+ @c1_ad1.add_group @g1_c1_ad1
119
+ @g1_c1_ad1.set_removed
120
+ @c1_ad1.add_group @g1_c1_ad1
121
+ @c1_ad1.groups.length == 1
122
+ end
123
+ end
124
+
125
+ def test_add_group_different_container_exception
126
+ assert_raise RuntimeError do
127
+ # You have to remove a group from its container so that its removed flag
128
+ # is set or the other container will ignore it.
129
+ @c4_ad2.remove_group @g2_c4_ad2
130
+ @c1_ad1.add_group @g2_c4_ad2
131
+ end
132
+ end
133
+
134
+ def test_remove_group_different_container_exception
135
+ assert_raise RuntimeError do
136
+ @c1_ad1.remove_group @g3_c3_ad1
137
+ end
138
+ end
139
+
140
+ def test_remove_primary_group_exception
141
+ assert_raise RuntimeError do
142
+ @c1_ad1.remove_group @g1_c1_ad1
143
+ end
144
+ end
145
+
146
+ def test_remove_unix_main_group_exception
147
+ assert_raise RuntimeError do
148
+ foo = RADUM::UNIXGroup.new :name => "bar", :container => @c3_ad1,
149
+ :gid => 1000
150
+ RADUM::UNIXUser.new :username => "foo", :container => @c3_ad1,
151
+ :primary_group => @g1_c1_ad1, :uid => 1001,
152
+ :unix_main_group => foo, :shell => "/bin/bash",
153
+ :home_directory => "/home/foo", :nis_domain => "test",
154
+ :disabled => false, :rid => 1002
155
+ @c3_ad1.remove_group foo
156
+ end
157
+ end
158
+
159
+ def test_remove_group_removed_flag_set
160
+ assert_block("Should have set removed group removed flag") do
161
+ @c3_ad1.remove_group @g3_c3_ad1
162
+ @g3_c3_ad1.removed? == true
163
+ end
164
+ end
165
+
166
+ def test_rid_uid_gid_added_to_container_directory
167
+ assert_block("Should have added UID and GID to directory") do
168
+ bar = RADUM::UNIXGroup.new :name => "bar", :container => @c3_ad1,
169
+ :gid => 1001
170
+ RADUM::UNIXUser.new :username => "foo", :container => @c3_ad1,
171
+ :primary_group => @g1_c1_ad1, :uid => 1000,
172
+ :unix_main_group => bar, :shell => "/bin/bash",
173
+ :home_directory => "/home/foo",
174
+ :nis_domain => "test", :disabled => false,
175
+ :rid => 1002
176
+ @ad1.uids.find { |uid| uid == 1000 } &&
177
+ @ad1.gids.find { |gid| gid == 1001 } &&
178
+ @ad1.rids.find { |rid| rid == 1002 }
179
+ end
180
+ end
181
+
182
+ def test_rid_uid_gid_removed_from_container_directory
183
+ assert_block("Should have removed UID and GID from directory") do
184
+ bar = RADUM::UNIXGroup.new :name => "bar", :container => @c3_ad1,
185
+ :gid => 1000
186
+ foo = RADUM::UNIXUser.new :username => "foo", :container => @c3_ad1,
187
+ :primary_group => @g1_c1_ad1, :uid => 1001,
188
+ :unix_main_group => bar, :shell => "/bin/bash",
189
+ :home_directory => "/home/foo",
190
+ :nis_domain => "test", :disabled => false,
191
+ :rid => 1002
192
+ @c3_ad1.remove_user foo
193
+ @c3_ad1.remove_group bar
194
+ ! (@ad1.uids.find { |uid| uid == 1000 } ||
195
+ @ad1.gids.find { |gid| gid == 1001 } ||
196
+ @ad1.rids.find { |rid| rid == 1002 })
197
+ end
198
+ end
199
+
200
+ def test_container_with_organizational_unit_exception
201
+ assert_raise RuntimeError do
202
+ RADUM::Container.new :name => "ou=foo,cn=bar", :directory => @ad1
203
+ end
204
+ end
205
+ end
@@ -0,0 +1,161 @@
1
+ require 'test/unit'
2
+ require 'radum'
3
+
4
+ # This tests the Group and UNIXGroup classes.
5
+ class TC_Group < Test::Unit::TestCase
6
+ def setup
7
+ @ad1 = RADUM::AD.new :root => "dc=vmware,dc=local", :password => "test1"
8
+ @ad2 = RADUM::AD.new :root => "dc=vmware,dc=com", :password => "test2"
9
+ @c1_ad1 = RADUM::Container.new :name => "ou=People", :directory => @ad1
10
+ @c2_ad1 = RADUM::Container.new :name => "ou=Staff,ou=People",
11
+ :directory => @ad1
12
+ @c3_ad2 = RADUM::Container.new :name => "ou=People", :directory => @ad2
13
+ @g1_c1_ad1 = RADUM::Group.new :name => "staff", :container => @c1_ad1,
14
+ :rid => 1722
15
+ @g2_c3_ad2 = RADUM::Group.new :name => "staff", :container => @c3_ad2,
16
+ :rid => 1722
17
+ @g4_c1_ad1 = RADUM::Group.new :name => "primary", :container => @c1_ad1
18
+ @g5_c3_ad2 = RADUM::Group.new :name => "priamry", :container => @c3_ad2
19
+ @ug1_c1_ad1 = RADUM::UNIXGroup.new :name => "class", :container => @c1_ad1,
20
+ :gid => 1001
21
+ @u1_c1_ad1 = RADUM::User.new :username => "user1", :container => @c1_ad1,
22
+ :primary_group => @g4_c1_ad1
23
+ @u2_c3_ad2 = RADUM::User.new :username => "user2", :container => @c3_ad2,
24
+ :primary_group => @g5_c3_ad2
25
+ @uu1_c1_ad1 = RADUM::UNIXUser.new :username => "user3",
26
+ :container => @c1_ad1,
27
+ :primary_group => @g4_c1_ad1,
28
+ :uid => 1000,
29
+ :unix_main_group => @ug1_c1_ad1,
30
+ :shell => "/bin/bash",
31
+ :home_directory => "/home/user"
32
+ end
33
+
34
+ def test_removed_flag_false
35
+ assert_block("Removed flags should be false.") do
36
+ @g1_c1_ad1.removed? == false && @ug1_c1_ad1.removed? == false
37
+ end
38
+ end
39
+
40
+ def test_duplicate_rid_exception
41
+ assert_raise RuntimeError do
42
+ RADUM::Group.new :name => "test", :container => @c1_ad1, :rid => 1722
43
+ end
44
+ end
45
+
46
+ def test_duplicate_gid_exception
47
+ assert_raise RuntimeError do
48
+ RADUM::UNIXGroup.new :name => "foo", :container => @c1_ad1, :gid => 1001
49
+ end
50
+ end
51
+
52
+ def test_equal_exception
53
+ assert_raise RuntimeError do
54
+ RADUM::Group.new :name => "staff", :container => @c1_ad1
55
+ end
56
+ end
57
+
58
+ def test_equal_name_case_exception
59
+ assert_raise RuntimeError do
60
+ RADUM::Group.new :name => "Staff", :container => @c1_ad1
61
+ end
62
+ end
63
+
64
+ def test_equal_container_difference_exception
65
+ assert_raise RuntimeError do
66
+ RADUM::Group.new :name => "staff", :container => @c2_ad1
67
+ end
68
+ end
69
+
70
+ def test_not_equal_ad
71
+ assert(@g1_c1_ad1 != @g2_c3_ad2, "Should not be equal")
72
+ end
73
+
74
+ def test_not_equal_group_unix_group
75
+ assert(@g1_c1_ad1 != @ug1_c1_ad1, "Should not be equal")
76
+ end
77
+
78
+ def test_add_user
79
+ assert_block("Should have added exactly one user") do
80
+ @g1_c1_ad1.add_user @u1_c1_ad1
81
+ @g1_c1_ad1.add_user @u1_c1_ad1
82
+ @g1_c1_ad1.users.length == 1
83
+ end
84
+ end
85
+
86
+ def test_add_user_different_directory_exception
87
+ assert_raise RuntimeError do
88
+ @g1_c1_ad1.add_user @u2_c3_ad2
89
+ end
90
+ end
91
+
92
+ def test_add_user_primary_group_exception
93
+ assert_raise RuntimeError do
94
+ @g4_c1_ad1.add_user @u1_c1_ad1
95
+ end
96
+ end
97
+
98
+ def test_group_added_to_container
99
+ assert_block("Group should have been automatically added to container") do
100
+ @c1_ad1.groups.find do |group|
101
+ group == @g1_c1_ad1
102
+ end
103
+ end
104
+ end
105
+
106
+ def test_add_user_group_added_to_user
107
+ assert_block("User should have group when added to group") do
108
+ @g1_c1_ad1.add_user @u1_c1_ad1
109
+ @u1_c1_ad1.groups.find do |group|
110
+ group == @g1_c1_ad1
111
+ end
112
+ end
113
+ end
114
+
115
+ def test_remove_user_group_removed_from_user
116
+ assert_block("User should have removed group when removed from group") do
117
+ @g1_c1_ad1.add_user @u1_c1_ad1
118
+ @g1_c1_ad1.remove_user @u1_c1_ad1
119
+ ! @u1_c1_ad1.groups.find do |group|
120
+ group == @g1_c1_ad1
121
+ end
122
+ end
123
+ end
124
+
125
+ def test_remove_user_main_unix_group_exception
126
+ assert_raise RuntimeError do
127
+ @ug1_c1_ad1.remove_user @uu1_c1_ad1
128
+ end
129
+ end
130
+
131
+ def test_add_group_self_exception
132
+ assert_raise RuntimeError do
133
+ @g1_c1_ad1.add_group @g1_c1_ad1
134
+ end
135
+ end
136
+
137
+ def test_add_group_other_directory_exception
138
+ assert_raise RuntimeError do
139
+ @g1_c1_ad1.add_group @g2_c3_ad2
140
+ end
141
+ end
142
+
143
+ def test_add_group
144
+ assert_block("Group should have added another group") do
145
+ @g1_c1_ad1.add_group @ug1_c1_ad1
146
+ @g1_c1_ad1.groups.find do |group|
147
+ group == @ug1_c1_ad1
148
+ end
149
+ end
150
+ end
151
+
152
+ def test_remove_group
153
+ assert_block("Group should have been removed") do
154
+ @g1_c1_ad1.add_group @ug1_c1_ad1
155
+ @g1_c1_ad1.remove_group @ug1_c1_ad1
156
+ ! @g1_c1_ad1.groups.find do |group|
157
+ group == @ug1_c1_ad1
158
+ end
159
+ end
160
+ end
161
+ end