activesambaldap 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/NEWS.en +9 -0
- data/NEWS.ja +10 -0
- data/README.en +310 -0
- data/README.ja +307 -0
- data/Rakefile +95 -0
- data/bin/asl-groupadd +70 -0
- data/bin/asl-groupdel +58 -0
- data/bin/asl-groupmod +133 -0
- data/bin/asl-groupshow +31 -0
- data/bin/asl-passwd +99 -0
- data/bin/asl-populate +96 -0
- data/bin/asl-purge +24 -0
- data/bin/asl-samba-computeradd +94 -0
- data/bin/asl-samba-groupadd +55 -0
- data/bin/asl-samba-groupdel +53 -0
- data/bin/asl-samba-groupmod +98 -0
- data/bin/asl-samba-useradd +98 -0
- data/bin/asl-samba-userdel +47 -0
- data/bin/asl-samba-usermod +92 -0
- data/bin/asl-useradd +263 -0
- data/bin/asl-userdel +75 -0
- data/bin/asl-usermod +335 -0
- data/bin/asl-usershow +31 -0
- data/lib/active_samba_ldap/account.rb +199 -0
- data/lib/active_samba_ldap/base.rb +126 -0
- data/lib/active_samba_ldap/command.rb +94 -0
- data/lib/active_samba_ldap/computer.rb +13 -0
- data/lib/active_samba_ldap/computer_account.rb +34 -0
- data/lib/active_samba_ldap/configuration.rb +322 -0
- data/lib/active_samba_ldap/dc.rb +17 -0
- data/lib/active_samba_ldap/entry.rb +80 -0
- data/lib/active_samba_ldap/group.rb +182 -0
- data/lib/active_samba_ldap/idmap.rb +17 -0
- data/lib/active_samba_ldap/ou.rb +18 -0
- data/lib/active_samba_ldap/populate.rb +254 -0
- data/lib/active_samba_ldap/samba_account.rb +200 -0
- data/lib/active_samba_ldap/samba_computer.rb +20 -0
- data/lib/active_samba_ldap/samba_group.rb +126 -0
- data/lib/active_samba_ldap/samba_user.rb +39 -0
- data/lib/active_samba_ldap/unix_id_pool.rb +41 -0
- data/lib/active_samba_ldap/user.rb +14 -0
- data/lib/active_samba_ldap/user_account.rb +30 -0
- data/lib/active_samba_ldap/version.rb +3 -0
- data/lib/active_samba_ldap.rb +29 -0
- data/lib/samba/encrypt.rb +86 -0
- data/misc/rd2html.rb +42 -0
- data/rails/plugin/active_samba_ldap/README +30 -0
- data/rails/plugin/active_samba_ldap/generators/scaffold_asl/scaffold_asl_generator.rb +28 -0
- data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/computer.rb +3 -0
- data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/dc.rb +3 -0
- data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/group.rb +3 -0
- data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/idmap.rb +3 -0
- data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/ldap.yml +24 -0
- data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/ou.rb +3 -0
- data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/samba_controller.rb +12 -0
- data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/samba_helper.rb +2 -0
- data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/samba_index.rhtml +17 -0
- data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/samba_populate.rhtml +15 -0
- data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/samba_purge.rhtml +10 -0
- data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/unix_id_pool.rb +3 -0
- data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/user.rb +3 -0
- data/rails/plugin/active_samba_ldap/init.rb +6 -0
- data/test/asl-test-utils.rb +276 -0
- data/test/command.rb +64 -0
- data/test/config.yaml.sample +17 -0
- data/test/run-test.rb +18 -0
- data/test/test-unit-ext/always-show-result.rb +28 -0
- data/test/test-unit-ext/priority.rb +159 -0
- data/test/test-unit-ext.rb +2 -0
- data/test/test_asl_groupadd.rb +69 -0
- data/test/test_asl_groupdel.rb +88 -0
- data/test/test_asl_groupmod.rb +256 -0
- data/test/test_asl_groupshow.rb +21 -0
- data/test/test_asl_passwd.rb +125 -0
- data/test/test_asl_populate.rb +92 -0
- data/test/test_asl_purge.rb +21 -0
- data/test/test_asl_useradd.rb +710 -0
- data/test/test_asl_userdel.rb +73 -0
- data/test/test_asl_usermod.rb +541 -0
- data/test/test_asl_usershow.rb +27 -0
- data/test/test_group.rb +21 -0
- data/test/test_password.rb +51 -0
- data/test/test_samba_encrypt.rb +36 -0
- data/test/test_user_home_directory.rb +43 -0
- metadata +177 -0
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'asl-test-utils'
|
2
|
+
|
3
|
+
class AslUserDelTest < Test::Unit::TestCase
|
4
|
+
include AslTestUtils
|
5
|
+
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
@command = File.join(@bin_dir, "asl-userdel")
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_run_as_normal_user
|
12
|
+
assert_equal([false, "", "need root authority.\n"],
|
13
|
+
run_command_as_normal_user("user-name"))
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_not_exist_user
|
17
|
+
assert_equal([false, "", "user 'not-exist' doesn't exist.\n"],
|
18
|
+
run_command("not-exist"))
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_exist_user
|
22
|
+
make_dummy_user do |user, password|
|
23
|
+
assert(File.exist?(user.home_directory))
|
24
|
+
assert_equal([true, "", ""], run_command(user.uid))
|
25
|
+
assert(!@user_class.exists?(user.uid))
|
26
|
+
assert(File.exist?(user.home_directory))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_exist_computer
|
31
|
+
make_dummy_computer do |computer, password|
|
32
|
+
assert(@computer_class.exists?(computer.uid))
|
33
|
+
assert_equal([true, "", ""],
|
34
|
+
run_command(computer.uid, '--computer-account'))
|
35
|
+
assert(!@computer_class.exists?(computer.uid))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_user_as_computer
|
40
|
+
make_dummy_user do |user, password|
|
41
|
+
assert_equal([false, "", "computer '#{user.uid}$' doesn't exist.\n"],
|
42
|
+
run_command(user.uid, "--computer-account"))
|
43
|
+
assert(@user_class.exists?(user.uid))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_computer_as_user
|
48
|
+
make_dummy_computer do |computer, password|
|
49
|
+
assert_equal([false, "", "user '#{computer.uid}' doesn't exist.\n"],
|
50
|
+
run_command(computer.uid))
|
51
|
+
assert(@computer_class.exists?(computer.uid))
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_belongs_to_group
|
56
|
+
make_dummy_user do |user, password|
|
57
|
+
assert(File.exist?(user.home_directory))
|
58
|
+
make_dummy_group do |group|
|
59
|
+
group.users << user
|
60
|
+
assert_equal([true, "", ""], run_command(user.uid))
|
61
|
+
end
|
62
|
+
assert(File.exist?(user.home_directory))
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_remove_home_directory
|
67
|
+
make_dummy_user do |user, password|
|
68
|
+
assert(File.exist?(user.home_directory))
|
69
|
+
assert_equal([true, "", ""], run_command("-r", user.uid))
|
70
|
+
assert(!File.exist?(user.home_directory))
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,541 @@
|
|
1
|
+
require 'asl-test-utils'
|
2
|
+
|
3
|
+
class AslUserModTest < Test::Unit::TestCase
|
4
|
+
include AslTestUtils
|
5
|
+
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
@command = File.join(@bin_dir, "asl-usermod")
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_not_exist_user
|
12
|
+
assert_equal([false, "", "user 'not-exist' doesn't exist.\n"],
|
13
|
+
run_command("not-exist"))
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_gecos
|
17
|
+
make_dummy_user do |user, password|
|
18
|
+
old_gecos = user.gecos
|
19
|
+
new_gecos = "New gecos"
|
20
|
+
assert_not_equal(old_gecos, new_gecos)
|
21
|
+
args = ["--gecos", new_gecos]
|
22
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
23
|
+
new_user = @user_class.find(user.uid)
|
24
|
+
assert_equal(new_gecos, new_user.gecos)
|
25
|
+
assert_equal(new_gecos, new_user.description)
|
26
|
+
assert_equal(new_gecos, new_user.display_name)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_home_directory
|
31
|
+
make_dummy_user do |user, password|
|
32
|
+
old_home_directory = user.home_directory
|
33
|
+
new_home_directory = "#{old_home_directory}.new"
|
34
|
+
args = ["--home-directory", new_home_directory]
|
35
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
36
|
+
new_user = @user_class.find(user.uid)
|
37
|
+
assert_equal(new_home_directory, new_user.home_directory)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_move_home_directory
|
42
|
+
make_dummy_user do |user, password|
|
43
|
+
begin
|
44
|
+
old_home_directory = user.home_directory
|
45
|
+
new_home_directory = "#{old_home_directory}.new"
|
46
|
+
assert(!File.exist?(new_home_directory))
|
47
|
+
args = ["--home-directory", new_home_directory, "--move-home-directory"]
|
48
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
49
|
+
new_user = @user_class.find(user.uid)
|
50
|
+
assert_equal(new_home_directory, new_user.home_directory)
|
51
|
+
assert(File.exist?(new_home_directory))
|
52
|
+
ensure
|
53
|
+
FileUtils.rm_rf(new_home_directory)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_rename
|
59
|
+
make_dummy_user do |user, password|
|
60
|
+
old_uid = user.uid
|
61
|
+
new_uid = "#{old_uid}-new"
|
62
|
+
|
63
|
+
ensure_delete_user(new_uid) do
|
64
|
+
assert(!@user_class.exists?(new_uid))
|
65
|
+
|
66
|
+
args = ["--rename", new_uid]
|
67
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
68
|
+
|
69
|
+
assert(!@user_class.exists?(old_uid))
|
70
|
+
assert(@user_class.exists?(new_uid))
|
71
|
+
|
72
|
+
new_user = @user_class.find(new_uid)
|
73
|
+
assert_equal(new_uid, new_user.uid)
|
74
|
+
assert_equal(new_uid, new_user.cn)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_uid_number
|
80
|
+
make_dummy_user do |user, password|
|
81
|
+
old_uid_number = user.uid_number
|
82
|
+
old_samba_sid = user.samba_sid
|
83
|
+
new_uid_number = old_uid_number.succ
|
84
|
+
|
85
|
+
old_rid = (2 * Integer(old_uid_number) + 1000).to_s
|
86
|
+
new_rid = (2 * Integer(new_uid_number) + 1000).to_s
|
87
|
+
new_samba_sid = old_samba_sid.sub(/#{Regexp.escape(old_rid)}$/, new_rid)
|
88
|
+
|
89
|
+
args = ["--uid", new_uid_number]
|
90
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
91
|
+
|
92
|
+
new_user = @user_class.find(user.uid)
|
93
|
+
assert_equal(new_uid_number, new_user.uid_number)
|
94
|
+
assert_equal(new_samba_sid, new_user.samba_sid)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_uid_number_non_unique
|
99
|
+
make_dummy_user do |user, password|
|
100
|
+
old_uid_number = user.uid_number
|
101
|
+
new_uid_number = old_uid_number.succ
|
102
|
+
make_dummy_user(:name => "#{user.uid}2",
|
103
|
+
:uid_number => new_uid_number) do |user2, password2|
|
104
|
+
old_samba_sid = user.samba_sid
|
105
|
+
old_rid = (2 * Integer(old_uid_number) + 1000).to_s
|
106
|
+
new_rid = (2 * Integer(new_uid_number) + 1000).to_s
|
107
|
+
new_samba_sid = old_samba_sid.sub(/#{Regexp.escape(old_rid)}$/, new_rid)
|
108
|
+
|
109
|
+
message = "uid number '#{new_uid_number}' already exists\n"
|
110
|
+
args = ["--uid", new_uid_number]
|
111
|
+
assert_asl_usermod_failed(user.uid, password, message, *args)
|
112
|
+
|
113
|
+
new_user = @user_class.find(user.uid)
|
114
|
+
assert_equal(old_uid_number, new_user.uid_number)
|
115
|
+
assert_equal(old_samba_sid, new_user.samba_sid)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_uid_number_allow_non_unique
|
121
|
+
make_dummy_user do |user, password|
|
122
|
+
old_uid_number = user.uid_number
|
123
|
+
new_uid_number = old_uid_number.succ
|
124
|
+
make_dummy_user(:name => "#{user.uid}2",
|
125
|
+
:uid_number => new_uid_number) do |user2, password2|
|
126
|
+
old_samba_sid = user.samba_sid
|
127
|
+
old_rid = (2 * Integer(old_uid_number) + 1000).to_s
|
128
|
+
new_rid = (2 * Integer(new_uid_number) + 1000).to_s
|
129
|
+
new_samba_sid = old_samba_sid.sub(/#{Regexp.escape(old_rid)}$/, new_rid)
|
130
|
+
|
131
|
+
args = ["--uid", new_uid_number, "--allow-non-unique-uid"]
|
132
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
133
|
+
|
134
|
+
new_user = @user_class.find(user.uid)
|
135
|
+
assert_equal(new_uid_number, new_user.uid_number)
|
136
|
+
assert_equal(new_samba_sid, new_user.samba_sid)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_gid_number
|
142
|
+
make_dummy_group do |group|
|
143
|
+
make_dummy_user(:gid_number => group.gid_number) do |user, password|
|
144
|
+
make_dummy_group do |new_group|
|
145
|
+
args = ["--gid", new_group.gid_number]
|
146
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
147
|
+
|
148
|
+
new_user = @user_class.find(user.uid)
|
149
|
+
assert_equal(new_group.gid_number, new_user.gid_number)
|
150
|
+
assert_equal(new_group.samba_sid,
|
151
|
+
new_user.samba_primary_group_sid)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def test_gid_number_not_exist
|
158
|
+
make_dummy_user do |user, password|
|
159
|
+
make_dummy_group do |group|
|
160
|
+
old_gid_number = user.gid_number
|
161
|
+
new_gid_number = group.gid_number
|
162
|
+
old_samba_primary_group_sid = user.samba_primary_group_sid
|
163
|
+
|
164
|
+
group.destroy
|
165
|
+
args = ["--gid", new_gid_number]
|
166
|
+
message = "gid number '#{new_gid_number}' doesn't exist\n"
|
167
|
+
assert_asl_usermod_failed(user.uid, password, message, *args)
|
168
|
+
|
169
|
+
new_user = @user_class.find(user.uid)
|
170
|
+
assert_equal(old_gid_number, new_user.gid_number)
|
171
|
+
assert_equal(old_samba_primary_group_sid,
|
172
|
+
new_user.samba_primary_group_sid)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def test_groups
|
178
|
+
make_dummy_group do |group1|
|
179
|
+
make_dummy_group do |group2|
|
180
|
+
make_dummy_group do |group3|
|
181
|
+
new_gid_number1 = group1.gid_number
|
182
|
+
new_gid_number2 = group2.gid_number
|
183
|
+
new_gid_number3 = group3.gid_number
|
184
|
+
new_gid_numbers = [new_gid_number1, new_gid_number2, new_gid_number3]
|
185
|
+
|
186
|
+
make_dummy_user do |user, password|
|
187
|
+
old_gid_number = user.gid_number
|
188
|
+
old_groups = @group_class.find(:all,
|
189
|
+
:attribute => "memberUid",
|
190
|
+
:value => user.uid)
|
191
|
+
|
192
|
+
args = ["--groups", new_gid_numbers.join(",")]
|
193
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
194
|
+
|
195
|
+
|
196
|
+
new_user = @user_class.find(user.uid)
|
197
|
+
new_groups = @group_class.find(:all,
|
198
|
+
:attribute => "memberUid",
|
199
|
+
:value => new_user.uid)
|
200
|
+
assert_equal([group1.cn,
|
201
|
+
group2.cn,
|
202
|
+
group3.cn].sort,
|
203
|
+
(new_groups.collect {|g| g.cn} -
|
204
|
+
old_groups.collect {|g| g.cn}).sort)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
def test_groups_no_merge
|
212
|
+
make_dummy_group do |group1|
|
213
|
+
make_dummy_group do |group2|
|
214
|
+
make_dummy_group do |group3|
|
215
|
+
new_gid_number1 = group1.gid_number
|
216
|
+
new_gid_number2 = group2.gid_number
|
217
|
+
new_gid_number3 = group3.gid_number
|
218
|
+
new_gid_numbers = [new_gid_number1, new_gid_number2, new_gid_number3]
|
219
|
+
make_dummy_user do |user, password|
|
220
|
+
old_gid_number = user.gid_number
|
221
|
+
old_groups = @group_class.find(:all,
|
222
|
+
:attribute => "memberUid",
|
223
|
+
:value => user.uid)
|
224
|
+
|
225
|
+
args = ["--groups", new_gid_numbers[0]]
|
226
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
227
|
+
|
228
|
+
new_user = @user_class.find(user.uid)
|
229
|
+
new_groups = @group_class.find(:all,
|
230
|
+
:attribute => "memberUid",
|
231
|
+
:value => new_user.uid)
|
232
|
+
assert_equal([group1.cn].sort,
|
233
|
+
(new_groups.collect {|g| g.cn} -
|
234
|
+
old_groups.collect {|g| g.cn}).sort)
|
235
|
+
|
236
|
+
|
237
|
+
args = ["--groups", new_gid_numbers[1..-1].join(","),
|
238
|
+
"--no-merge-groups"]
|
239
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
240
|
+
|
241
|
+
new_user = @user_class.find(user.uid)
|
242
|
+
new_groups = @group_class.find(:all,
|
243
|
+
:attribute => "memberUid",
|
244
|
+
:value => new_user.uid)
|
245
|
+
assert_equal([group2.cn, group3.cn].sort,
|
246
|
+
new_groups.collect {|g| g.cn}.sort)
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
def test_groups_not_exist
|
254
|
+
make_dummy_group do |group1|
|
255
|
+
make_dummy_group do |group2|
|
256
|
+
new_gid_number1 = group1.gid_number
|
257
|
+
new_gid_number2 = group2.gid_number
|
258
|
+
new_gid_numbers = [new_gid_number1, new_gid_number2]
|
259
|
+
|
260
|
+
group1.destroy
|
261
|
+
group2.destroy
|
262
|
+
|
263
|
+
make_dummy_user do |user, password|
|
264
|
+
old_gid_number = user.gid_number
|
265
|
+
|
266
|
+
assert(!@group_class.exists?(group1.cn))
|
267
|
+
|
268
|
+
old_groups = @group_class.find(:all,
|
269
|
+
:attribute => "memberUid",
|
270
|
+
:value => user.uid)
|
271
|
+
|
272
|
+
args = ["--groups", new_gid_numbers.join(",")]
|
273
|
+
message = "gid number '#{new_gid_numbers[0]}' doesn't exist\n"
|
274
|
+
assert_asl_usermod_failed(user.uid, password, message, *args)
|
275
|
+
|
276
|
+
new_user = @user_class.find(user.uid)
|
277
|
+
new_groups = @group_class.find(:all,
|
278
|
+
:attribute => "memberUid",
|
279
|
+
:value => new_user.uid)
|
280
|
+
assert_equal(old_groups.collect {|g| g.cn}.sort,
|
281
|
+
new_groups.collect {|g| g.cn}.sort)
|
282
|
+
end
|
283
|
+
end
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
def test_shell
|
288
|
+
make_dummy_user do |user, password|
|
289
|
+
old_shell = user.login_shell
|
290
|
+
new_shell = "/bin/zsh"
|
291
|
+
|
292
|
+
assert_not_equal(old_shell, new_shell)
|
293
|
+
|
294
|
+
args = ["--shell", new_shell]
|
295
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
296
|
+
|
297
|
+
new_user = @user_class.find(user.uid)
|
298
|
+
assert_equal(new_shell, new_user.login_shell)
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
def test_canonical_name
|
303
|
+
make_dummy_user do |user, password|
|
304
|
+
old_cn = user.cn
|
305
|
+
new_cn = "new-#{new_cn}"
|
306
|
+
|
307
|
+
args = ["--canonical-name", new_cn]
|
308
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
309
|
+
|
310
|
+
new_user = @user_class.find(user.uid)
|
311
|
+
assert_equal(new_cn, new_user.cn)
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
def test_surname
|
316
|
+
make_dummy_user do |user, password|
|
317
|
+
old_sn = user.sn
|
318
|
+
new_sn = "new-#{old_sn}"
|
319
|
+
|
320
|
+
args = ["--surname", new_sn]
|
321
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
322
|
+
|
323
|
+
new_user = @user_class.find(user.uid)
|
324
|
+
assert_equal(new_sn, new_user.sn)
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
def test_given_name
|
329
|
+
make_dummy_user do |user, password|
|
330
|
+
old_given_name = user.given_name
|
331
|
+
new_given_name = "new-#{old_given_name}"
|
332
|
+
|
333
|
+
args = ["--given-name", new_given_name]
|
334
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
335
|
+
|
336
|
+
new_user = @user_class.find(user.uid)
|
337
|
+
assert_equal(new_given_name, new_user.given_name)
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
341
|
+
def test_expire_date
|
342
|
+
make_dummy_user do |user, password|
|
343
|
+
old_expire_date = user.samba_kickoff_time
|
344
|
+
new_expire_date = Time.now + 60 * 24
|
345
|
+
|
346
|
+
unless old_expire_date.nil?
|
347
|
+
assert_not_equal(Time.at(old_expire_date.to_i), new_expire_date)
|
348
|
+
end
|
349
|
+
|
350
|
+
args = ["--expire-date", new_expire_date.iso8601]
|
351
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
352
|
+
|
353
|
+
new_user = @user_class.find(user.uid)
|
354
|
+
assert_equal(new_expire_date.to_i.to_s, new_user.samba_kickoff_time)
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
def test_can_change_password
|
359
|
+
make_dummy_user do |user, password|
|
360
|
+
unless user.can_change_password?
|
361
|
+
args = ["--can-change-password"]
|
362
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
363
|
+
new_user = @user_class.find(user.uid)
|
364
|
+
assert(new_user.can_change_password?)
|
365
|
+
end
|
366
|
+
|
367
|
+
args = ["--no-can-change-password"]
|
368
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
369
|
+
new_user = @user_class.find(user.uid)
|
370
|
+
assert(!new_user.can_change_password?)
|
371
|
+
|
372
|
+
args = ["--can-change-password"]
|
373
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
374
|
+
new_user = @user_class.find(user.uid)
|
375
|
+
assert(new_user.can_change_password?)
|
376
|
+
end
|
377
|
+
end
|
378
|
+
|
379
|
+
def test_must_change_password
|
380
|
+
make_dummy_user do |user, password|
|
381
|
+
unless user.must_change_password?
|
382
|
+
args = ["--must-change-password"]
|
383
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
384
|
+
new_user = @user_class.find(user.uid)
|
385
|
+
assert(new_user.must_change_password?)
|
386
|
+
end
|
387
|
+
|
388
|
+
args = ["--no-must-change-password"]
|
389
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
390
|
+
new_user = @user_class.find(user.uid)
|
391
|
+
assert(!new_user.must_change_password?)
|
392
|
+
|
393
|
+
args = ["--must-change-password"]
|
394
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
395
|
+
new_user = @user_class.find(user.uid)
|
396
|
+
assert(new_user.must_change_password?)
|
397
|
+
end
|
398
|
+
end
|
399
|
+
|
400
|
+
def test_samba_home_path
|
401
|
+
make_dummy_user do |user, password|
|
402
|
+
old_samba_home_path = user.samba_home_path
|
403
|
+
new_samba_home_path = "//PDC/NEW-HOME"
|
404
|
+
|
405
|
+
assert_not_equal(old_samba_home_path, new_samba_home_path)
|
406
|
+
|
407
|
+
args = ["--samba-home-path", new_samba_home_path]
|
408
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
409
|
+
|
410
|
+
new_user = @user_class.find(user.uid)
|
411
|
+
assert_equal(new_samba_home_path, new_user.samba_home_path)
|
412
|
+
end
|
413
|
+
end
|
414
|
+
|
415
|
+
def test_samba_home_drive
|
416
|
+
make_dummy_user do |user, password|
|
417
|
+
old_samba_home_drive = user.samba_home_drive
|
418
|
+
new_samba_home_drive = "X:"
|
419
|
+
|
420
|
+
assert_not_equal(old_samba_home_drive, new_samba_home_drive)
|
421
|
+
|
422
|
+
args = ["--samba-home-drive", new_samba_home_drive]
|
423
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
424
|
+
|
425
|
+
new_user = @user_class.find(user.uid)
|
426
|
+
assert_equal(new_samba_home_drive, new_user.samba_home_drive)
|
427
|
+
end
|
428
|
+
end
|
429
|
+
|
430
|
+
def test_samba_logon_script
|
431
|
+
make_dummy_user do |user, password|
|
432
|
+
old_samba_logon_script = user.samba_logon_script
|
433
|
+
new_samba_logon_script = "\\\\PDC\\scripts\\logon-new.bat"
|
434
|
+
|
435
|
+
assert_not_equal(old_samba_logon_script, new_samba_logon_script)
|
436
|
+
|
437
|
+
args = ["--samba-logon-script", new_samba_logon_script]
|
438
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
439
|
+
|
440
|
+
new_user = @user_class.find(user.uid)
|
441
|
+
assert_equal(new_samba_logon_script, new_user.samba_logon_script)
|
442
|
+
end
|
443
|
+
end
|
444
|
+
|
445
|
+
def test_samba_profile_path
|
446
|
+
make_dummy_user do |user, password|
|
447
|
+
old_samba_profile_path = user.samba_profile_path
|
448
|
+
new_samba_profile_path = "\\\\PDC\\profiles\\new-profile"
|
449
|
+
|
450
|
+
assert_not_equal(old_samba_profile_path, new_samba_profile_path)
|
451
|
+
|
452
|
+
args = ["--samba-profile-path", new_samba_profile_path]
|
453
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
454
|
+
|
455
|
+
new_user = @user_class.find(user.uid)
|
456
|
+
assert_equal(new_samba_profile_path, new_user.samba_profile_path)
|
457
|
+
end
|
458
|
+
end
|
459
|
+
|
460
|
+
def test_samba_account_flags
|
461
|
+
make_dummy_user do |user, password|
|
462
|
+
old_samba_account_flags = user.samba_acct_flags
|
463
|
+
new_samba_account_flags = "[UX]"
|
464
|
+
|
465
|
+
assert_not_equal(old_samba_account_flags, new_samba_account_flags)
|
466
|
+
|
467
|
+
args = ["--samba-account-flags", new_samba_account_flags]
|
468
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
469
|
+
|
470
|
+
new_user = @user_class.find(user.uid)
|
471
|
+
assert_equal(new_samba_account_flags, new_user.samba_acct_flags)
|
472
|
+
end
|
473
|
+
end
|
474
|
+
|
475
|
+
def test_enable
|
476
|
+
make_dummy_user do |user, password|
|
477
|
+
unless user.enabled?
|
478
|
+
args = ["--enable-user"]
|
479
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
480
|
+
new_user = @user_class.find(user.uid)
|
481
|
+
assert(new_user.enabled?)
|
482
|
+
assert(!new_user.disabled?)
|
483
|
+
end
|
484
|
+
|
485
|
+
args = ["--no-enable-user"]
|
486
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
487
|
+
new_user = @user_class.find(user.uid)
|
488
|
+
assert(!new_user.enabled?)
|
489
|
+
assert(new_user.disabled?)
|
490
|
+
|
491
|
+
args = ["--enable-user"]
|
492
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
493
|
+
new_user = @user_class.find(user.uid)
|
494
|
+
assert(new_user.enabled?)
|
495
|
+
assert(!new_user.disabled?)
|
496
|
+
end
|
497
|
+
end
|
498
|
+
|
499
|
+
def test_disable
|
500
|
+
make_dummy_user do |user, password|
|
501
|
+
unless user.disabled?
|
502
|
+
args = ["--disable-user"]
|
503
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
504
|
+
new_user = @user_class.find(user.uid)
|
505
|
+
assert(!new_user.enabled?)
|
506
|
+
assert(new_user.disabled?)
|
507
|
+
end
|
508
|
+
|
509
|
+
args = ["--no-disable-user"]
|
510
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
511
|
+
new_user = @user_class.find(user.uid)
|
512
|
+
assert(new_user.enabled?)
|
513
|
+
assert(!new_user.disabled?)
|
514
|
+
|
515
|
+
args = ["--disable-user"]
|
516
|
+
assert_asl_usermod_successfully(user.uid, password, *args)
|
517
|
+
new_user = @user_class.find(user.uid)
|
518
|
+
assert(!new_user.enabled?)
|
519
|
+
assert(new_user.disabled?)
|
520
|
+
end
|
521
|
+
end
|
522
|
+
|
523
|
+
private
|
524
|
+
def assert_asl_usermod_successfully(name, password, *args)
|
525
|
+
args << name
|
526
|
+
assert_equal([true, "Enter your password: \n", ""],
|
527
|
+
run_command_as_normal_user(*args) do |input, output|
|
528
|
+
output.puts password
|
529
|
+
output.puts password
|
530
|
+
end)
|
531
|
+
end
|
532
|
+
|
533
|
+
def assert_asl_usermod_failed(name, password, message, *args)
|
534
|
+
args << name
|
535
|
+
assert_equal([false, "Enter your password: \n", message],
|
536
|
+
run_command_as_normal_user(*args) do |input, output|
|
537
|
+
output.puts password
|
538
|
+
output.puts password
|
539
|
+
end)
|
540
|
+
end
|
541
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'asl-test-utils'
|
2
|
+
|
3
|
+
class AslUserShowTest < Test::Unit::TestCase
|
4
|
+
include AslTestUtils
|
5
|
+
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
@command = File.join(@bin_dir, "asl-usershow")
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_exist_user
|
12
|
+
make_dummy_user do |user, password|
|
13
|
+
user.class.establish_connection("reference")
|
14
|
+
begin
|
15
|
+
user = user.class.find(user.uid)
|
16
|
+
assert_equal([true, user.to_ldif, ""], run_command(user.uid))
|
17
|
+
ensure
|
18
|
+
user.class.establish_connection("update")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_not_exist_user
|
24
|
+
assert_equal([false, "", "user 'not-exist' doesn't exist.\n"],
|
25
|
+
run_command("not-exist"))
|
26
|
+
end
|
27
|
+
end
|
data/test/test_group.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'asl-test-utils'
|
2
|
+
|
3
|
+
class GroupTest < Test::Unit::TestCase
|
4
|
+
include AslTestUtils
|
5
|
+
|
6
|
+
priority :must
|
7
|
+
def test_builtin_group
|
8
|
+
assert_sid("#{@group_class.configuration[:sid]}-543", 543)
|
9
|
+
(544..552).each do |rid|
|
10
|
+
assert_sid("S-1-5-32-#{rid}", rid)
|
11
|
+
end
|
12
|
+
assert_sid("#{@group_class.configuration[:sid]}-553", 553)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
def assert_sid(expected, rid)
|
17
|
+
group = @group_class.new("XXX")
|
18
|
+
group.change_sid(rid)
|
19
|
+
assert_equal(expected, group.samba_sid)
|
20
|
+
end
|
21
|
+
end
|