activesambaldap 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. data/NEWS.en +9 -0
  2. data/NEWS.ja +10 -0
  3. data/README.en +310 -0
  4. data/README.ja +307 -0
  5. data/Rakefile +95 -0
  6. data/bin/asl-groupadd +70 -0
  7. data/bin/asl-groupdel +58 -0
  8. data/bin/asl-groupmod +133 -0
  9. data/bin/asl-groupshow +31 -0
  10. data/bin/asl-passwd +99 -0
  11. data/bin/asl-populate +96 -0
  12. data/bin/asl-purge +24 -0
  13. data/bin/asl-samba-computeradd +94 -0
  14. data/bin/asl-samba-groupadd +55 -0
  15. data/bin/asl-samba-groupdel +53 -0
  16. data/bin/asl-samba-groupmod +98 -0
  17. data/bin/asl-samba-useradd +98 -0
  18. data/bin/asl-samba-userdel +47 -0
  19. data/bin/asl-samba-usermod +92 -0
  20. data/bin/asl-useradd +263 -0
  21. data/bin/asl-userdel +75 -0
  22. data/bin/asl-usermod +335 -0
  23. data/bin/asl-usershow +31 -0
  24. data/lib/active_samba_ldap/account.rb +199 -0
  25. data/lib/active_samba_ldap/base.rb +126 -0
  26. data/lib/active_samba_ldap/command.rb +94 -0
  27. data/lib/active_samba_ldap/computer.rb +13 -0
  28. data/lib/active_samba_ldap/computer_account.rb +34 -0
  29. data/lib/active_samba_ldap/configuration.rb +322 -0
  30. data/lib/active_samba_ldap/dc.rb +17 -0
  31. data/lib/active_samba_ldap/entry.rb +80 -0
  32. data/lib/active_samba_ldap/group.rb +182 -0
  33. data/lib/active_samba_ldap/idmap.rb +17 -0
  34. data/lib/active_samba_ldap/ou.rb +18 -0
  35. data/lib/active_samba_ldap/populate.rb +254 -0
  36. data/lib/active_samba_ldap/samba_account.rb +200 -0
  37. data/lib/active_samba_ldap/samba_computer.rb +20 -0
  38. data/lib/active_samba_ldap/samba_group.rb +126 -0
  39. data/lib/active_samba_ldap/samba_user.rb +39 -0
  40. data/lib/active_samba_ldap/unix_id_pool.rb +41 -0
  41. data/lib/active_samba_ldap/user.rb +14 -0
  42. data/lib/active_samba_ldap/user_account.rb +30 -0
  43. data/lib/active_samba_ldap/version.rb +3 -0
  44. data/lib/active_samba_ldap.rb +29 -0
  45. data/lib/samba/encrypt.rb +86 -0
  46. data/misc/rd2html.rb +42 -0
  47. data/rails/plugin/active_samba_ldap/README +30 -0
  48. data/rails/plugin/active_samba_ldap/generators/scaffold_asl/scaffold_asl_generator.rb +28 -0
  49. data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/computer.rb +3 -0
  50. data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/dc.rb +3 -0
  51. data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/group.rb +3 -0
  52. data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/idmap.rb +3 -0
  53. data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/ldap.yml +24 -0
  54. data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/ou.rb +3 -0
  55. data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/samba_controller.rb +12 -0
  56. data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/samba_helper.rb +2 -0
  57. data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/samba_index.rhtml +17 -0
  58. data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/samba_populate.rhtml +15 -0
  59. data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/samba_purge.rhtml +10 -0
  60. data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/unix_id_pool.rb +3 -0
  61. data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/user.rb +3 -0
  62. data/rails/plugin/active_samba_ldap/init.rb +6 -0
  63. data/test/asl-test-utils.rb +276 -0
  64. data/test/command.rb +64 -0
  65. data/test/config.yaml.sample +17 -0
  66. data/test/run-test.rb +18 -0
  67. data/test/test-unit-ext/always-show-result.rb +28 -0
  68. data/test/test-unit-ext/priority.rb +159 -0
  69. data/test/test-unit-ext.rb +2 -0
  70. data/test/test_asl_groupadd.rb +69 -0
  71. data/test/test_asl_groupdel.rb +88 -0
  72. data/test/test_asl_groupmod.rb +256 -0
  73. data/test/test_asl_groupshow.rb +21 -0
  74. data/test/test_asl_passwd.rb +125 -0
  75. data/test/test_asl_populate.rb +92 -0
  76. data/test/test_asl_purge.rb +21 -0
  77. data/test/test_asl_useradd.rb +710 -0
  78. data/test/test_asl_userdel.rb +73 -0
  79. data/test/test_asl_usermod.rb +541 -0
  80. data/test/test_asl_usershow.rb +27 -0
  81. data/test/test_group.rb +21 -0
  82. data/test/test_password.rb +51 -0
  83. data/test/test_samba_encrypt.rb +36 -0
  84. data/test/test_user_home_directory.rb +43 -0
  85. metadata +177 -0
@@ -0,0 +1,88 @@
1
+ require 'asl-test-utils'
2
+
3
+ class AslGroupDelTest < Test::Unit::TestCase
4
+ include AslTestUtils
5
+
6
+ def setup
7
+ super
8
+ @command = File.join(@bin_dir, "asl-groupdel")
9
+ end
10
+
11
+ def test_run_as_normal_user
12
+ assert_equal([false, "", "need root authority.\n"],
13
+ run_command_as_normal_user("group-name"))
14
+ end
15
+
16
+ def test_not_exist_group
17
+ assert_equal([false, "", "group 'not-exist' doesn't exist.\n"],
18
+ run_command("not-exist"))
19
+ end
20
+
21
+ def test_exist_group
22
+ make_dummy_group do |group|
23
+ assert_equal([true, "", ""], run_command(group.cn))
24
+ end
25
+ end
26
+
27
+ def test_user_is_belonged_to
28
+ make_dummy_group do |group|
29
+ make_dummy_user do |user, password|
30
+ group.users << user
31
+ assert_equal([true, "", ""], run_command(group.cn))
32
+ end
33
+ end
34
+ end
35
+
36
+ def test_primary_group_of_user
37
+ make_dummy_group do |group|
38
+ make_dummy_user(:gid_number => group.gid_number) do |user, password|
39
+ message = "cannot destroy group '#{group.cn}' due to members "
40
+ message << "who belong to the group as primary group"
41
+ message << ": #{user.uid}\n"
42
+ assert_equal([false, "", message], run_command(group.cn))
43
+ end
44
+ end
45
+ end
46
+
47
+ def test_primary_group_of_user_with_force
48
+ make_dummy_group do |group|
49
+ make_dummy_user(:gid_number => group.gid_number) do |user, password|
50
+ message = "cannot change primary group from '#{group.cn}' "
51
+ message << "to other group due to no other belonged groups"
52
+ message << ": #{user.uid}\n"
53
+ assert_equal([false, "", message], run_command(group.cn, "--force"))
54
+ end
55
+ end
56
+ end
57
+
58
+ def test_primary_group_of_user_with_force_with_other_group
59
+ make_dummy_group do |group|
60
+ make_dummy_user(:gid_number => group.gid_number) do |user, password|
61
+ make_dummy_group do |group2|
62
+ group2.users << user
63
+ assert_equal(group.gid_number, user.gid_number)
64
+ assert_equal([true, "", ""], run_command(group.cn, "--force"))
65
+ user.reload
66
+ assert_equal(group2.gid_number, user.gid_number)
67
+ end
68
+ end
69
+ end
70
+ end
71
+
72
+ def test_primary_group_of_user_with_other_group
73
+ make_dummy_group do |group|
74
+ make_dummy_user(:gid_number => group.gid_number) do |user, password|
75
+ make_dummy_group do |group2|
76
+ group2.users << user
77
+ assert_equal(group.gid_number, user.gid_number)
78
+ message = "cannot destroy group '#{group.cn}' due to members "
79
+ message << "who belong to the group as primary group"
80
+ message << ": #{user.uid}\n"
81
+ assert_equal([false, "", message], run_command(group.cn))
82
+ user.reload
83
+ assert_equal(group.gid_number, user.gid_number)
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,256 @@
1
+ require 'asl-test-utils'
2
+
3
+ class AslGroupModTest < Test::Unit::TestCase
4
+ include AslTestUtils
5
+
6
+ def setup
7
+ super
8
+ @command = File.join(@bin_dir, "asl-groupmod")
9
+ end
10
+
11
+ def test_not_exist_group
12
+ assert_equal([false, "", "group 'not-exist' doesn't exist.\n"],
13
+ run_command("not-exist"))
14
+ end
15
+
16
+ def test_rename
17
+ make_dummy_group do |group|
18
+ old_cn = group.cn
19
+ new_cn = "#{old_cn}-new"
20
+ ensure_delete_group(new_cn) do
21
+ assert(!@group_class.exists?(new_cn))
22
+
23
+ args = ["--rename", new_cn]
24
+ assert_asl_groupmod_successfully(group.cn, *args)
25
+
26
+ assert(!@group_class.exists?(old_cn))
27
+ assert(@group_class.exists?(new_cn))
28
+ end
29
+ end
30
+ end
31
+
32
+ def test_rename_with_members
33
+ make_dummy_user do |user1, password1|
34
+ make_dummy_user do |user2, password2|
35
+ make_dummy_group do |group|
36
+ group.users.concat(user1, user2)
37
+
38
+ old_cn = group.cn
39
+ new_cn = "#{old_cn}-new"
40
+ ensure_delete_group(new_cn) do
41
+ assert(!@group_class.exists?(new_cn))
42
+
43
+ args = ["--rename", new_cn]
44
+ assert_asl_groupmod_successfully(group.cn, *args)
45
+
46
+ assert(!@group_class.exists?(old_cn))
47
+ assert(@group_class.exists?(new_cn))
48
+
49
+ members = []
50
+ new_group = @group_class.find(new_cn)
51
+ new_group.member_uid(true).each do |uid|
52
+ members.concat(@user_class.find(:all,
53
+ :attribute => "uid",
54
+ :value => uid))
55
+ end
56
+ assert_equal([user1.uid, user2.uid].sort,
57
+ members.collect {|m| m.uid}.sort)
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ def test_rename_with_members_primary
65
+ make_dummy_user do |user1, password1|
66
+ make_dummy_user do |user2, password2|
67
+ make_dummy_group do |group|
68
+ user1.primary_group = group
69
+ assert(user1.save)
70
+ user2.primary_group = group
71
+ assert(user2.save)
72
+
73
+ old_cn = group.cn
74
+ new_cn = "#{old_cn}-new"
75
+ ensure_delete_group(new_cn) do
76
+ assert(!@group_class.exists?(new_cn))
77
+
78
+ args = ["--rename", new_cn]
79
+ assert_asl_groupmod_successfully(group.cn, *args)
80
+
81
+ assert(!@group_class.exists?(old_cn))
82
+ assert(@group_class.exists?(new_cn))
83
+
84
+ new_group = @group_class.find(new_cn)
85
+ assert_equal(new_group.gid_number, user1.gid_number)
86
+ assert_equal(new_group.gid_number, user2.gid_number)
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
92
+
93
+ def test_gid_number
94
+ make_dummy_group do |group|
95
+ old_gid_number = group.gid_number
96
+ old_samba_sid = group.samba_sid
97
+ new_gid_number = old_gid_number.succ
98
+
99
+ old_rid = (2 * Integer(old_gid_number) + 1001).to_s
100
+ new_rid = (2 * Integer(new_gid_number) + 1001).to_s
101
+ new_samba_sid = old_samba_sid.sub(/#{Regexp.escape(old_rid)}$/, new_rid)
102
+
103
+ args = ["--gid", new_gid_number]
104
+ assert_asl_groupmod_successfully(group.cn, *args)
105
+
106
+ new_group = @group_class.find(group.cn)
107
+ assert_equal(new_gid_number, new_group.gid_number)
108
+ assert_equal(new_samba_sid, new_group.samba_sid)
109
+ end
110
+ end
111
+
112
+ def test_gid_number_non_unique
113
+ make_dummy_group do |group|
114
+ old_gid_number = group.gid_number
115
+ make_dummy_group do |group2|
116
+ new_gid_number = group2.gid_number
117
+
118
+ old_samba_sid = group.samba_sid
119
+ old_rid = (2 * Integer(old_gid_number) + 1001).to_s
120
+ new_rid = (2 * Integer(new_gid_number) + 1001).to_s
121
+ new_samba_sid = old_samba_sid.sub(/#{Regexp.escape(old_rid)}$/, new_rid)
122
+
123
+ message = "gid number '#{new_gid_number}' already exists\n"
124
+ args = ["--gid", new_gid_number]
125
+ assert_asl_groupmod_failed(group.cn, message, *args)
126
+
127
+ new_group = @group_class.find(group.cn)
128
+ assert_equal(old_gid_number, new_group.gid_number)
129
+ assert_equal(old_samba_sid, new_group.samba_sid)
130
+ end
131
+ end
132
+ end
133
+
134
+ def test_gid_number_allow_non_unique
135
+ make_dummy_group do |group|
136
+ old_gid_number = group.gid_number
137
+ make_dummy_group do |group2|
138
+ new_gid_number = group2.gid_number
139
+
140
+ old_samba_sid = group.samba_sid
141
+ old_rid = (2 * Integer(old_gid_number) + 1001).to_s
142
+ new_rid = (2 * Integer(new_gid_number) + 1001).to_s
143
+ new_samba_sid = old_samba_sid.sub(/#{Regexp.escape(old_rid)}$/, new_rid)
144
+
145
+ args = ["--gid", new_gid_number, "--allow-non-unique-gid"]
146
+ assert_asl_groupmod_successfully(group.cn, *args)
147
+
148
+ new_group = @group_class.find(group.cn)
149
+ assert_equal(new_gid_number, new_group.gid_number)
150
+ assert_equal(new_samba_sid, new_group.samba_sid)
151
+ end
152
+ end
153
+ end
154
+
155
+ def test_add_members
156
+ make_dummy_group do |group|
157
+ make_dummy_user do |user1, password1|
158
+ make_dummy_user do |user2, password2|
159
+ make_dummy_user do |user3, password3|
160
+ old_member_uids = group.member_uid(true)
161
+
162
+ new_members = [user1.uid, user2.uid]
163
+ args = ["--add-members", new_members.join(",")]
164
+ assert_asl_groupmod_successfully(group.cn, *args)
165
+
166
+ new_group = @group_class.find(group.cn)
167
+ new_member_uids = new_group.member_uid(true)
168
+
169
+ assert_equal(new_members.sort,
170
+ (new_member_uids - old_member_uids).sort)
171
+ end
172
+ end
173
+ end
174
+ end
175
+ end
176
+
177
+ def test_delete_members
178
+ make_dummy_group do |group|
179
+ make_dummy_user do |user1, password1|
180
+ make_dummy_user do |user2, password2|
181
+ make_dummy_user do |user3, password3|
182
+ group.users.concat(user1, user2, user3)
183
+
184
+ old_member_uids = group.member_uid(true)
185
+
186
+ members_to_delete = [user1.uid, user2.uid]
187
+ args = ["--delete-members", members_to_delete.join(",")]
188
+ assert_asl_groupmod_successfully(group.cn, *args)
189
+
190
+ new_group = @group_class.find(group.cn)
191
+ new_member_uids = new_group.member_uid(true)
192
+
193
+ assert_equal(members_to_delete.sort,
194
+ (old_member_uids - new_member_uids).sort)
195
+ end
196
+ end
197
+ end
198
+ end
199
+ end
200
+
201
+ def test_add_and_delete_members
202
+ make_dummy_group do |group|
203
+ make_dummy_user do |user1, password1|
204
+ make_dummy_user do |user2, password2|
205
+ make_dummy_user do |user3, password3|
206
+ group.users << user1
207
+
208
+ old_member_uids = group.member_uid(true)
209
+
210
+ new_members = [user2.uid, user3.uid]
211
+ args = ["--add-members", new_members.join(","),
212
+ "--delete-members", old_member_uids.join(",")]
213
+ assert_asl_groupmod_successfully(group.cn, *args)
214
+
215
+ new_group = @group_class.find(group.cn)
216
+ new_member_uids = new_group.member_uid(true)
217
+
218
+ assert_equal(new_members.sort,
219
+ (new_member_uids - old_member_uids).sort)
220
+ end
221
+ end
222
+ end
223
+ end
224
+ end
225
+
226
+ def test_duplicate_members
227
+ make_dummy_group do |group|
228
+ base = "there are duplicated members in adding and deleting members:"
229
+ assert_asl_groupmod_failed(group.cn,
230
+ "#{base} user\n",
231
+ "--add-members", "user",
232
+ "--delete-members", "user")
233
+
234
+ assert_asl_groupmod_failed(group.cn,
235
+ "#{base} user2\n",
236
+ "--add-members", "user1,user2,user3",
237
+ "--delete-members", "user2")
238
+
239
+ assert_asl_groupmod_failed(group.cn,
240
+ "#{base} user2, user3\n",
241
+ "--add-members", "user1,user2,user3",
242
+ "--delete-members", "user2,user3,user4")
243
+ end
244
+ end
245
+
246
+ private
247
+ def assert_asl_groupmod_successfully(name, *args)
248
+ args << name
249
+ assert_equal([true, "", ""], run_command(*args))
250
+ end
251
+
252
+ def assert_asl_groupmod_failed(name, message, *args)
253
+ args << name
254
+ assert_equal([false, "", message], run_command(*args))
255
+ end
256
+ end
@@ -0,0 +1,21 @@
1
+ require 'asl-test-utils'
2
+
3
+ class AslGroupShowTest < Test::Unit::TestCase
4
+ include AslTestUtils
5
+
6
+ def setup
7
+ super
8
+ @command = File.join(@bin_dir, "asl-groupshow")
9
+ end
10
+
11
+ def test_exist_group
12
+ make_dummy_group do |group|
13
+ assert_equal([true, group.to_ldif, ""], run_command(group.cn))
14
+ end
15
+ end
16
+
17
+ def test_not_exist_group
18
+ assert_equal([false, "", "group 'not-exist' doesn't exist.\n"],
19
+ run_command("not-exist"))
20
+ end
21
+ end
@@ -0,0 +1,125 @@
1
+ require 'asl-test-utils'
2
+
3
+ class AslPasswdTest < Test::Unit::TestCase
4
+ include AslTestUtils
5
+
6
+ def setup
7
+ super
8
+ @command = File.join(@bin_dir, "asl-passwd")
9
+ end
10
+
11
+ def test_unknown_user
12
+ assert_equal([false, "", "user 'unknown' doesn't exist.\n"],
13
+ run_command("unknown"))
14
+ end
15
+
16
+ def test_change_password
17
+ make_dummy_user do |user, password|
18
+ new_password = "new#{password}"
19
+
20
+ assert_samba_password(user, password)
21
+
22
+ assert_change_password_successfully(user.uid, password, new_password)
23
+
24
+ user.reload
25
+ assert_samba_password(user, new_password)
26
+
27
+ assert_change_password_with_wrong_current_password(user.uid, password)
28
+ user.reload
29
+ assert_samba_password(user, new_password)
30
+
31
+ assert_change_password_successfully(user.uid,
32
+ new_password, password)
33
+ user.reload
34
+ assert_samba_password(user, password)
35
+ end
36
+ end
37
+
38
+ def test_change_password_only_unix
39
+ make_dummy_user do |user, password|
40
+ new_password = "new#{password}"
41
+ args = ["--no-samba-password"]
42
+
43
+ assert_samba_password(user, password)
44
+
45
+ assert_change_password_successfully(user.uid,
46
+ password, new_password,
47
+ *args)
48
+ user.reload
49
+ assert_samba_password(user, password)
50
+
51
+ assert_change_password_with_wrong_current_password(user.uid,
52
+ password, *args)
53
+
54
+ assert_change_password_successfully(user.uid,
55
+ new_password, password, *args)
56
+ user.reload
57
+ assert_samba_password(user, password)
58
+ end
59
+ end
60
+
61
+ def test_change_password_only_samba
62
+ make_dummy_user do |user, password|
63
+ new_password = "new#{password}"
64
+ args = ["--no-unix-password"]
65
+
66
+ assert_samba_password(user, password)
67
+
68
+ assert_change_password_successfully(user.uid,
69
+ password, new_password, *args)
70
+ user.reload
71
+ assert_samba_password(user, new_password)
72
+
73
+ assert_change_password_with_wrong_current_password(user.uid,
74
+ new_password, *args)
75
+
76
+ assert_change_password_successfully(user.uid, password, password,
77
+ *args)
78
+ user.reload
79
+ assert_samba_password(user, password)
80
+ end
81
+ end
82
+
83
+ private
84
+ def change_password(name, old_password, new_password, *args)
85
+ run_command_as_normal_user(name, *args) do |input, output|
86
+ output.puts(old_password)
87
+ output.puts(new_password)
88
+ output.puts(new_password)
89
+ output.flush
90
+ end
91
+ end
92
+
93
+ def assert_samba_password(user, password)
94
+ _wrap_assertion do
95
+ assert_equal(Samba::Encrypt.lm_hash(password),
96
+ user.samba_lm_password)
97
+ assert_equal(Samba::Encrypt.ntlm_hash(password),
98
+ user.samba_nt_password)
99
+ end
100
+ end
101
+
102
+ def assert_change_password_successfully(name, old_password, new_password,
103
+ *args)
104
+ assert_equal([true,
105
+ [
106
+ "Enter your current password: ",
107
+ "New password: ",
108
+ "Retype new password: ",
109
+ ].join("\n") + "\n",
110
+ "",
111
+ ],
112
+ change_password(name, old_password, new_password, *args))
113
+ end
114
+
115
+ def assert_change_password_with_wrong_current_password(name, password, *args)
116
+ assert_equal([false,
117
+ "Enter your current password: \n",
118
+ "password isn't match\n",
119
+ ],
120
+ run_command_as_normal_user(name, *args) do |input, output|
121
+ output.puts(password)
122
+ output.flush
123
+ end)
124
+ end
125
+ end
@@ -0,0 +1,92 @@
1
+ require 'asl-test-utils'
2
+
3
+ class AslPopulateTest < Test::Unit::TestCase
4
+ include AslTestUtils
5
+
6
+ def setup
7
+ super
8
+ @command = File.join(@bin_dir, "asl-populate")
9
+ end
10
+
11
+ def test_run_as_normal_user
12
+ assert_equal([false, "", "need root authority.\n"],
13
+ run_command_as_normal_user)
14
+ end
15
+
16
+ def test_populate
17
+ ActiveSambaLdap::Base.purge
18
+ assert_equal([], ActiveSambaLdap::Base.search)
19
+ assert_asl_populate_successfully("Administrator")
20
+ base = ActiveSambaLdap::Base.base
21
+
22
+ results = ActiveSambaLdap::Base.search
23
+
24
+ config = ActiveSambaLdap::Base.configuration
25
+ users_suffix = config[:users_suffix]
26
+ groups_suffix = config[:groups_suffix]
27
+ computers_suffix = config[:computers_suffix]
28
+ idmap_suffix = config[:idmap_suffix]
29
+ domain = config[:samba_domain]
30
+ assert_equal([
31
+ nil,
32
+ users_suffix,
33
+ groups_suffix,
34
+ computers_suffix,
35
+ idmap_suffix,
36
+ "sambaDomainName=#{domain}",
37
+ "uid=Administrator,#{users_suffix}",
38
+ "uid=Guest,#{users_suffix}",
39
+ "cn=Users,#{groups_suffix}",
40
+ "cn=Account Operators,#{groups_suffix}",
41
+ "cn=Administrators,#{groups_suffix}",
42
+ "cn=Backup Operators,#{groups_suffix}",
43
+ "cn=Domain Admins,#{groups_suffix}",
44
+ "cn=Domain Computers,#{groups_suffix}",
45
+ "cn=Domain Guests,#{groups_suffix}",
46
+ "cn=Domain Users,#{groups_suffix}",
47
+ "cn=Guests,#{groups_suffix}",
48
+ "cn=Power Users,#{groups_suffix}",
49
+ "cn=Print Operators,#{groups_suffix}",
50
+ "cn=Replicators,#{groups_suffix}",
51
+ "cn=System Operators,#{groups_suffix}",
52
+ ].collect {|x| [x, base].compact.join(",")}.sort,
53
+ results.collect {|dn, attributes| dn}.sort)
54
+ end
55
+
56
+ def test_wrong_password
57
+ ActiveSambaLdap::Base.purge
58
+ assert_asl_populate_miss_match_password
59
+ end
60
+
61
+ private
62
+ def assert_asl_populate_successfully(password, name=nil, *args)
63
+ name ||= @user_class::DOMAIN_ADMIN_NAME
64
+ assert_equal([true,
65
+ [
66
+ "Password for #{name}: ",
67
+ "Retype password for #{name}: ",
68
+ ].join("\n") + "\n",
69
+ "",
70
+ ],
71
+ run_command(*args) do |input, output|
72
+ output.puts(password)
73
+ output.puts(password)
74
+ end)
75
+ end
76
+
77
+ def assert_asl_populate_miss_match_password(name=nil, *args)
78
+ name ||= @user_class::DOMAIN_ADMIN_NAME
79
+ password = "password"
80
+ assert_equal([false,
81
+ [
82
+ "Password for #{name}: ",
83
+ "Retype password for #{name}: ",
84
+ ].join("\n") + "\n",
85
+ "Passwords don't match.\n",
86
+ ],
87
+ run_command(*args) do |input, output|
88
+ output.puts(password)
89
+ output.puts(password + password.reverse)
90
+ end)
91
+ end
92
+ end
@@ -0,0 +1,21 @@
1
+ require 'asl-test-utils'
2
+
3
+ class AslPurgeTest < Test::Unit::TestCase
4
+ include AslTestUtils
5
+
6
+ def setup
7
+ super
8
+ @command = File.join(@bin_dir, "asl-purge")
9
+ end
10
+
11
+ def test_run_as_normal_user
12
+ assert_equal([false, "", "need root authority.\n"],
13
+ run_command_as_normal_user)
14
+ end
15
+
16
+ def test_populate
17
+ assert_not_equal([], ActiveSambaLdap::Base.search)
18
+ assert_equal([true, "", ""], run_command)
19
+ assert_equal([], ActiveSambaLdap::Base.search)
20
+ end
21
+ end