sys-admin 1.4.3-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
Binary file
@@ -0,0 +1,39 @@
1
+ require 'rubygems'
2
+
3
+ spec = Gem::Specification.new do |gem|
4
+ gem.name = 'sys-admin'
5
+ gem.version = '1.4.3'
6
+ gem.author = 'Daniel J. Berger'
7
+ gem.email = 'djberg96@gmail.com'
8
+ gem.homepage = 'http://www.rubyforge.org/projects/sysutils'
9
+ gem.platform = Gem::Platform::CURRENT
10
+ gem.summary = 'A unified, cross platform replacement for the "etc" package.'
11
+ gem.description = 'A unified, cross platform replacement for the "etc" package.'
12
+ gem.test_file = 'test/tc_admin.rb'
13
+ gem.has_rdoc = true
14
+ gem.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST']
15
+ gem.rubyforge_project = 'sysutils'
16
+
17
+ files = Dir["doc/*"] + Dir["examples/*"]
18
+ files += Dir["test/*"] + Dir["[A-Z]*"]
19
+
20
+ if RUBY_PLATFORM.match('mswin')
21
+ files += Dir["lib/sys/admin.rb"]
22
+ gem.required_ruby_version = '>= 1.8.2'
23
+ else
24
+ files += Dir["ext/**/*"]
25
+ gem.required_ruby_version = '>= 1.8.0'
26
+ gem.extensions = ['ext/extconf.rb']
27
+ gem.extra_rdoc_files << 'ext/sys/admin.c'
28
+ gem.require_path = 'lib'
29
+ end
30
+
31
+ files.delete_if{ |item| item.include?('CVS') }
32
+
33
+ gem.files = files
34
+ end
35
+
36
+ if $PROGRAM_NAME == __FILE__
37
+ Gem.manage_gems
38
+ Gem::Builder.new(spec).build
39
+ end
@@ -0,0 +1,39 @@
1
+ require 'rubygems'
2
+
3
+ spec = Gem::Specification.new do |gem|
4
+ gem.name = 'sys-admin'
5
+ gem.version = '1.4.3'
6
+ gem.author = 'Daniel J. Berger'
7
+ gem.email = 'djberg96@gmail.com'
8
+ gem.homepage = 'http://www.rubyforge.org/projects/sysutils'
9
+ gem.platform = Gem::Platform::RUBY
10
+ gem.summary = 'A unified, cross platform replacement for the "etc" package.'
11
+ gem.description = 'A unified, cross platform replacement for the "etc" package.'
12
+ gem.test_file = 'test/tc_admin.rb'
13
+ gem.has_rdoc = true
14
+ gem.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST']
15
+ gem.rubyforge_project = 'sysutils'
16
+
17
+ files = Dir["doc/*"] + Dir["examples/*"]
18
+ files += Dir["test/*"] + Dir["[A-Z]*"]
19
+
20
+ if RUBY_PLATFORM.match('mswin')
21
+ files += Dir["lib/sys/admin.rb"]
22
+ gem.required_ruby_version = '>= 1.8.2'
23
+ else
24
+ files += Dir["ext/**/*"]
25
+ gem.required_ruby_version = '>= 1.8.0'
26
+ gem.extensions = ['ext/extconf.rb']
27
+ gem.extra_rdoc_files << 'ext/sys/admin.c'
28
+ gem.require_path = 'lib'
29
+ end
30
+
31
+ files.delete_if{ |item| item.include?('CVS') }
32
+
33
+ gem.files = files
34
+ end
35
+
36
+ if $PROGRAM_NAME == __FILE__
37
+ Gem.manage_gems
38
+ Gem::Builder.new(spec).build
39
+ end
@@ -0,0 +1,14 @@
1
+ ###############################################################################
2
+ # tc_admin.rb
3
+ #
4
+ # This exists mostly for the sake of the gemspec, so that it calls the right
5
+ # test suite based on the platform.
6
+ ###############################################################################
7
+ $LOAD_PATH.unshift Dir.pwd
8
+ $LOAD_PATH.unshift Dir.pwd + "/test"
9
+
10
+ if File::ALT_SEPARATOR
11
+ require "tc_windows"
12
+ else
13
+ require "tc_unix"
14
+ end
@@ -0,0 +1,81 @@
1
+ ###############################################################################
2
+ # tc_unix.rb
3
+ #
4
+ # Test suite for the Unix version of sys-admin. This test should be run
5
+ # via the 'rake test' task.
6
+ ###############################################################################
7
+ require 'test/unit'
8
+ require 'sys/admin'
9
+ include Sys
10
+
11
+ class TC_Sys_Admin_Unix < Test::Unit::TestCase
12
+ def setup
13
+ @user = "nobody"
14
+ @userid = 0
15
+ @group = "sys"
16
+ @groupid = 3
17
+ end
18
+
19
+ def test_version
20
+ assert_equal('1.4.3', Admin::VERSION)
21
+ end
22
+
23
+ def test_get_login
24
+ assert_respond_to(Admin, :get_login)
25
+ assert_nothing_raised{ Admin.get_login }
26
+ assert_kind_of(String, Admin.get_login)
27
+ end
28
+
29
+ def test_get_user
30
+ assert_respond_to(Admin, :get_user)
31
+ assert_nothing_raised{ Admin.get_user(@user) }
32
+ assert_nothing_raised{ Admin.get_user(@userid) }
33
+ assert_kind_of(User, Admin.get_user(@user))
34
+ assert_kind_of(User, Admin.get_user(@userid))
35
+ assert_raises(Admin::Error){ Admin.get_user("foofoo") }
36
+ end
37
+
38
+ def test_users
39
+ assert_respond_to(Admin, :users)
40
+ assert_nothing_raised{ Admin.users }
41
+ assert_kind_of(Array, Admin.users)
42
+ assert_kind_of(User, Admin.users.first)
43
+ end
44
+
45
+ def test_users_block_form
46
+ array = []
47
+ assert_nothing_raised{ Admin.users{ |g| array << g } }
48
+ assert_equal(true, Admin.users.length == array.length)
49
+ assert_nothing_raised{ Admin.users{ |g| break } }
50
+ end
51
+
52
+ def test_get_group
53
+ assert_respond_to(Admin, :get_group)
54
+ assert_nothing_raised{ Admin.get_group(@group) }
55
+ assert_nothing_raised{ Admin.get_group(@groupid) }
56
+ assert_kind_of(Group, Admin.get_group(@group))
57
+ assert_kind_of(Group, Admin.get_group(@groupid))
58
+ assert_raises(Admin::Error){ Admin.get_group("foofoo") }
59
+ end
60
+
61
+ def test_groups
62
+ assert_respond_to(Admin, :groups)
63
+ assert_nothing_raised{ Admin.groups }
64
+ assert_kind_of(Array, Admin.groups)
65
+ assert_kind_of(Group, Admin.groups.first)
66
+ end
67
+
68
+ def test_groups_block_form
69
+ array = []
70
+ assert_nothing_raised{ Admin.groups{ |g| array << g } }
71
+ assert_equal(true, Admin.groups.length == array.length)
72
+ assert_nothing_raised{ Admin.groups{ |g| break } }
73
+ end
74
+
75
+ def teardown
76
+ @user = nil
77
+ @userid = nil
78
+ @group = nil
79
+ @groupid = nil
80
+ end
81
+ end
@@ -0,0 +1,303 @@
1
+ ###############################################################################
2
+ # tc_windows.rb
3
+ #
4
+ # Test suite for the Win32 version of sys-admin. Note that some of the tests
5
+ # are numbered to ensure a certain order. That way I can add test users
6
+ # before configuring or deleting them.
7
+ #
8
+ # It is assumed that this test will be run via the 'rake test' task.
9
+ ###############################################################################
10
+ require "test/unit"
11
+ require "sys/admin"
12
+ require "socket"
13
+ include Sys
14
+
15
+ class TC_Sys_Admin_Win32 < Test::Unit::TestCase
16
+ def setup
17
+ @host = Socket.gethostname
18
+ @user = User.new
19
+ @user_name = "guest"
20
+ @user_id = 501 # best guess, may fail
21
+ @group = Group.new
22
+ @group_name = "guests"
23
+ @group_id = 546 # best guess, may fail
24
+ end
25
+
26
+ def test_version
27
+ assert_equal('1.4.3', Admin::VERSION)
28
+ end
29
+
30
+ def test_01_add_local_user
31
+ assert_respond_to(Admin, :add_local_user)
32
+ assert_nothing_raised{ Admin.add_local_user("foo") }
33
+ end
34
+
35
+ def test_add_global_user
36
+ assert_respond_to(Admin, :add_global_user)
37
+ end
38
+
39
+ def test_02_config_local_user
40
+ assert_respond_to(Admin, :config_local_user)
41
+ assert_nothing_raised{
42
+ Admin.config_local_user("foo",{
43
+ :description => "delete me",
44
+ :fullname => "fubar"
45
+ })
46
+ }
47
+ end
48
+
49
+ def test_config_global_user
50
+ assert_respond_to(Admin, :config_global_user)
51
+ end
52
+
53
+ def test_03_delete_local_user
54
+ assert_respond_to(Admin, :delete_local_user)
55
+ assert_nothing_raised{ Admin.delete_local_user("foo") }
56
+ end
57
+
58
+ def test_delete_global_user
59
+ assert_respond_to(Admin, :delete_global_user)
60
+ end
61
+
62
+ def test_01_add_local_group
63
+ assert_respond_to(Admin, :add_local_group)
64
+ assert_nothing_raised{ Admin.add_local_group("bar") }
65
+ end
66
+
67
+ def test_add_global_group
68
+ assert_respond_to(Admin, :add_global_group)
69
+ end
70
+
71
+ def test_02_config_local_group
72
+ assert_respond_to(Admin, :config_local_group)
73
+ assert_nothing_raised{
74
+ Admin.config_local_group("bar",{:description=>"delete me"})
75
+ }
76
+ end
77
+
78
+ def test_config_global_group
79
+ assert_respond_to(Admin, :config_global_group)
80
+ end
81
+
82
+ def test_03_delete_local_group
83
+ assert_respond_to(Admin, :delete_local_group)
84
+ assert_nothing_raised{ Admin.delete_local_group("bar") }
85
+ end
86
+
87
+ def test_delete_global_group
88
+ assert_respond_to(Admin, :delete_global_group)
89
+ end
90
+
91
+ def test_get_login
92
+ assert_respond_to(Admin, :get_login)
93
+ assert_nothing_raised{ Admin.get_login }
94
+ assert_kind_of(String, Admin.get_login)
95
+ end
96
+
97
+ def test_get_user
98
+ assert_respond_to(Admin, :get_user)
99
+ assert_raises(ArgumentError){ Admin.get_user }
100
+ end
101
+
102
+ def test_get_user_local
103
+ assert_nothing_raised{ Admin.get_user(@user_name) }
104
+ assert_nothing_raised{ Admin.get_user(@user_id) }
105
+ assert_kind_of(User, Admin.get_user(@user_name))
106
+ assert_kind_of(User, Admin.get_user(@user_id))
107
+ end
108
+
109
+ def test_get_user_remote
110
+ assert_nothing_raised{ Admin.get_user(@user_name, @host) }
111
+ assert_nothing_raised{ Admin.get_user(@user_id, @host) }
112
+ assert_kind_of(User, Admin.get_user(@user_name, @host))
113
+ assert_kind_of(User, Admin.get_user(@user_id, @host))
114
+ end
115
+
116
+ def test_users
117
+ assert_respond_to(Admin, :users)
118
+ end
119
+
120
+ def test_users_local
121
+ assert_nothing_raised{ Admin.users }
122
+ assert_nothing_raised{ Admin.users{ |u| } }
123
+ assert_nothing_raised{ Admin.users(nil) }
124
+ assert_nothing_raised{ Admin.users(nil){ |u| } }
125
+ assert_kind_of(Array, Admin.users)
126
+ assert_kind_of(User, Admin.users.first)
127
+ end
128
+
129
+ def test_users_remote
130
+ assert_nothing_raised{ Admin.users(@host) }
131
+ assert_nothing_raised{ Admin.users(@host){ |u| } }
132
+ end
133
+
134
+ def test_user_instance_caption
135
+ assert_respond_to(@user, :caption)
136
+ assert_respond_to(@user, :caption=)
137
+ end
138
+
139
+ def test_user_instance_description
140
+ assert_respond_to(@user, :description)
141
+ assert_respond_to(@user, :description=)
142
+ end
143
+
144
+ def test_user_instance_domain
145
+ assert_respond_to(@user, :domain)
146
+ assert_respond_to(@user, :domain=)
147
+ end
148
+
149
+ def test_user_instance_password
150
+ assert_respond_to(@user, :password)
151
+ assert_respond_to(@user, :password=)
152
+ end
153
+
154
+ def test_user_instance_full_name
155
+ assert_respond_to(@user, :full_name)
156
+ assert_respond_to(@user, :full_name=)
157
+ end
158
+
159
+ def test_user_instance_name
160
+ assert_respond_to(@user, :name)
161
+ assert_respond_to(@user, :name=)
162
+ end
163
+
164
+ def test_user_instance_sid
165
+ assert_respond_to(@user, :sid)
166
+ assert_respond_to(@user, :sid=)
167
+ end
168
+
169
+ def test_user_instance_status
170
+ assert_respond_to(@user, :status)
171
+ assert_respond_to(@user, :status=)
172
+ end
173
+
174
+ def test_user_instance_disabled
175
+ assert_respond_to(@user, :disabled?)
176
+ assert_respond_to(@user, :disabled=)
177
+ end
178
+
179
+ def test_user_instance_local
180
+ assert_respond_to(@user, :local?)
181
+ assert_respond_to(@user, :local=)
182
+ end
183
+
184
+ def test_user_instance_lockout
185
+ assert_respond_to(@user, :lockout?)
186
+ assert_respond_to(@user, :lockout=)
187
+ end
188
+
189
+ def test_user_instance_password_changeable
190
+ assert_respond_to(@user, :password_changeable?)
191
+ assert_respond_to(@user, :password_changeable=)
192
+ end
193
+
194
+ def test_user_instance_password_expires
195
+ assert_respond_to(@user, :password_expires?)
196
+ assert_respond_to(@user, :password_expires=)
197
+ end
198
+
199
+ def test_user_instance_password_required
200
+ assert_respond_to(@user, :password_required?)
201
+ assert_respond_to(@user, :password_required=)
202
+ end
203
+
204
+ def test_user_instance_account_type
205
+ assert_respond_to(@user, :account_type)
206
+ assert_respond_to(@user, :account_type=)
207
+ end
208
+
209
+ def test_get_group
210
+ assert_respond_to(Admin, :get_group)
211
+ assert_raises(ArgumentError){ Admin.get_group }
212
+ end
213
+
214
+ def test_get_group_local
215
+ assert_nothing_raised{ Admin.get_group(@group_name) }
216
+ assert_kind_of(Group, Admin.get_group(@group_name))
217
+ assert_nothing_raised{ Admin.get_group(@group_id) }
218
+ assert_kind_of(Group, Admin.get_group(@group_id))
219
+ end
220
+
221
+ def test_get_group_remote
222
+ assert_nothing_raised{ Admin.get_group(@group_name, @host) }
223
+ assert_kind_of(Group, Admin.get_group(@group_name, @host))
224
+ end
225
+
226
+ def test_groups
227
+ assert_respond_to(Admin, :groups)
228
+ end
229
+
230
+ def test_groups_local
231
+ assert_nothing_raised{ Admin.groups }
232
+ assert_nothing_raised{ Admin.groups{ |g| } }
233
+ assert_kind_of(Array, Admin.groups)
234
+ assert_kind_of(Group, Admin.groups.first)
235
+ end
236
+
237
+ def test_groups_remote
238
+ assert_nothing_raised{ Admin.groups(@host) }
239
+ assert_nothing_raised{ Admin.groups(@host){ |g| } }
240
+ assert_kind_of(Array, Admin.groups(@host))
241
+ assert_kind_of(Group, Admin.groups(@host).first)
242
+ end
243
+
244
+ def test_group_instance_caption
245
+ assert_respond_to(@group, :caption)
246
+ assert_respond_to(@group, :caption=)
247
+ end
248
+
249
+ def test_group_instance_description
250
+ assert_respond_to(@group, :description)
251
+ assert_respond_to(@group, :description=)
252
+ end
253
+
254
+ def test_group_instance_domain
255
+ assert_respond_to(@group, :domain)
256
+ assert_respond_to(@group, :domain=)
257
+ end
258
+
259
+ def test_group_instance_install_date
260
+ assert_respond_to(@group, :install_date)
261
+ assert_respond_to(@group, :install_date=)
262
+ end
263
+
264
+ def test_group_instance_name
265
+ assert_respond_to(@group, :name)
266
+ assert_respond_to(@group, :name)
267
+ end
268
+
269
+ def test_group_instance_gid
270
+ assert_respond_to(@group, :gid)
271
+ assert_respond_to(@group, :gid=)
272
+ end
273
+
274
+ def test_group_instance_status
275
+ assert_respond_to(@group, :status)
276
+ assert_respond_to(@group, :status=)
277
+ end
278
+
279
+ def test_group_instance_sid
280
+ assert_respond_to(@group, :sid)
281
+ assert_respond_to(@group, :sid=)
282
+ end
283
+
284
+ def test_group_instance_sid_type
285
+ assert_respond_to(@group, :sid_type)
286
+ assert_respond_to(@group, :sid_type=)
287
+ end
288
+
289
+ def test_group_instance_local
290
+ assert_respond_to(@group, :local?)
291
+ assert_respond_to(@group, :local=)
292
+ end
293
+
294
+ def teardown
295
+ @host = nil
296
+ @user = nil
297
+ @user_name = nil
298
+ @user_id = nil
299
+ @group = nil
300
+ @group_name = nil
301
+ @group_id = nil
302
+ end
303
+ end