sys-admin 1.5.4-x86-mingw32 → 1.5.5-x86-mingw32

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.
data/sys-admin.gemspec CHANGED
@@ -4,7 +4,7 @@ require 'rubygems'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'sys-admin'
7
- spec.version = '1.5.4'
7
+ spec.version = '1.5.5'
8
8
  spec.author = 'Daniel J. Berger'
9
9
  spec.license = 'Artistic 2.0'
10
10
  spec.email = 'djberg96@gmail.com'
@@ -16,6 +16,6 @@ end
16
16
 
17
17
  class TC_Sys_Admin_All < Test::Unit::TestCase
18
18
  def test_version
19
- assert_equal('1.5.4', Sys::Admin::VERSION)
19
+ assert_equal('1.5.5', Sys::Admin::VERSION)
20
20
  end
21
21
  end
@@ -13,321 +13,332 @@ gem 'test-unit'
13
13
  require 'test/unit'
14
14
  require 'sys/admin'
15
15
  require 'socket'
16
+ require 'etc'
16
17
  include Sys
17
18
 
18
19
  class TC_Sys_Admin_Win32 < Test::Unit::TestCase
19
- def self.startup
20
- @@host = Socket.gethostname
21
- end
20
+ def self.startup
21
+ @@host = Socket.gethostname
22
+ end
22
23
 
23
- def setup
24
- @user = User.new
25
- @user_name = 'Guest'
26
- @user_id = 501 # best guess, may fail
27
- @group = Group.new
28
- @group_name = 'Guests'
29
- @group_id = 546 # best guess, may fail
30
- end
24
+ def setup
25
+ @user = User.new
26
+ @user_name = 'Guest'
27
+ @user_id = 501 # best guess, may fail
28
+ @group = Group.new
29
+ @group_name = 'Guests'
30
+ @group_id = 546 # best guess, may fail
31
+ end
31
32
 
32
- # Admin singleton methods
33
+ # Admin singleton methods
33
34
 
34
- def test_01_add_user
35
- assert_respond_to(Admin, :add_user)
36
- assert_nothing_raised{
37
- Admin.add_user(:name => 'foo', :password => 'a1b2c3D4')
38
- }
39
- end
35
+ def test_01_add_user
36
+ assert_respond_to(Admin, :add_user)
37
+ assert_nothing_raised{
38
+ Admin.add_user(:name => 'foo', :password => 'a1b2c3D4')
39
+ }
40
+ end
40
41
 
41
- def test_02_config_user
42
- assert_respond_to(Admin, :configure_user)
43
- assert_nothing_raised{
44
- Admin.configure_user(
45
- :name => 'foo',
46
- :description => 'delete me',
47
- :fullname => 'fubar',
48
- :password => ['a1b2c3D4', 'd1c2b3A4']
49
- )
50
- }
51
- end
52
-
53
- def test_03_delete_user
54
- assert_respond_to(Admin, :delete_user)
55
- assert_nothing_raised{ Admin.delete_user('foo') }
56
- end
57
-
58
- def test_01_add_group
59
- assert_respond_to(Admin, :add_group)
60
- assert_nothing_raised{ Admin.add_group(:name => 'bar') }
61
- end
62
-
63
- def test_02_configure_group
64
- assert_respond_to(Admin, :configure_group)
65
- assert_nothing_raised{
66
- Admin.configure_group(:name => 'bar', :description => 'delete me')
67
- }
68
- end
69
-
70
- def test_03_delete_group
71
- assert_respond_to(Admin, :delete_group)
72
- assert_nothing_raised{ Admin.delete_group('bar') }
73
- end
74
-
75
- def test_get_login_basic
76
- assert_respond_to(Admin, :get_login)
77
- assert_nothing_raised{ Admin.get_login }
78
- end
42
+ def test_02_config_user
43
+ assert_respond_to(Admin, :configure_user)
44
+ assert_nothing_raised{
45
+ Admin.configure_user(
46
+ :name => 'foo',
47
+ :description => 'delete me',
48
+ :fullname => 'fubar',
49
+ :password => ['a1b2c3D4', 'd1c2b3A4']
50
+ )
51
+ }
52
+ end
53
+
54
+ def test_03_delete_user
55
+ assert_respond_to(Admin, :delete_user)
56
+ assert_nothing_raised{ Admin.delete_user('foo') }
57
+ end
79
58
 
80
- def test_get_login
81
- assert_kind_of(String, Admin.get_login)
82
- end
59
+ def test_01_add_group
60
+ assert_respond_to(Admin, :add_group)
61
+ assert_nothing_raised{ Admin.add_group(:name => 'bar') }
62
+ end
63
+
64
+ def test_02_configure_group
65
+ assert_respond_to(Admin, :configure_group)
66
+ assert_nothing_raised{
67
+ Admin.configure_group(:name => 'bar', :description => 'delete me')
68
+ }
69
+ end
70
+
71
+ def test_03_delete_group
72
+ assert_respond_to(Admin, :delete_group)
73
+ assert_nothing_raised{ Admin.delete_group('bar') }
74
+ end
75
+
76
+ def test_get_login_basic
77
+ assert_respond_to(Admin, :get_login)
78
+ assert_nothing_raised{ Admin.get_login }
79
+ end
83
80
 
84
- def test_get_login_expected_errors
85
- assert_raise(ArgumentError){ Admin.get_login('foo') }
86
- end
87
-
88
- def test_get_user_basic
89
- assert_respond_to(Admin, :get_user)
90
- end
91
-
92
- def test_get_user_by_string
93
- assert_nothing_raised{ Admin.get_user(@user_name, :localaccount => true) }
94
- assert_kind_of(User, Admin.get_user(@user_name, :localaccount => true))
95
- end
81
+ def test_get_login
82
+ assert_kind_of(String, Admin.get_login)
83
+ end
96
84
 
97
- def test_get_user_by_uid
98
- assert_nothing_raised{ Admin.get_user(@user_id, :localaccount => true) }
99
- assert_kind_of(User, Admin.get_user(@user_id, :localaccount => true))
100
- end
101
-
102
- def test_get_user_by_string_with_options
103
- options = {:host => @@host, :localaccount => true}
104
- assert_nothing_raised{ Admin.get_user(@user_name, options) }
105
- assert_kind_of(User, Admin.get_user(@user_name, options))
106
- end
85
+ def test_get_login_expected_errors
86
+ assert_raise(ArgumentError){ Admin.get_login('foo') }
87
+ end
88
+
89
+ def test_get_user_basic
90
+ assert_respond_to(Admin, :get_user)
91
+ end
107
92
 
108
- def test_get_user_by_uid_with_options
109
- options = {:host => @@host, :localaccount => true}
110
- assert_nothing_raised{ Admin.get_user(@user_id, options) }
111
- assert_kind_of(User, Admin.get_user(@user_id, options))
112
- end
93
+ def test_get_user_by_string
94
+ assert_nothing_raised{ Admin.get_user(@user_name, :localaccount => true) }
95
+ assert_kind_of(User, Admin.get_user(@user_name, :localaccount => true))
96
+ end
113
97
 
114
- def test_get_user_expected_errors
115
- assert_raises(ArgumentError){ Admin.get_user }
116
- end
117
-
118
- def test_users_basic
119
- assert_respond_to(Admin, :users)
120
- assert_nothing_raised{ Admin.users(:localaccount => true) }
121
- end
98
+ def test_get_user_by_uid
99
+ assert_nothing_raised{ Admin.get_user(@user_id, :localaccount => true) }
100
+ assert_kind_of(User, Admin.get_user(@user_id, :localaccount => true))
101
+ end
102
+
103
+ def test_get_user_by_string_with_options
104
+ options = {:host => @@host, :localaccount => true}
105
+ assert_nothing_raised{ Admin.get_user(@user_name, options) }
106
+ assert_kind_of(User, Admin.get_user(@user_name, options))
107
+ end
122
108
 
123
- def test_users
124
- assert_kind_of(Array, Admin.users(:localaccount => true))
125
- assert_kind_of(User, Admin.users(:localaccount => true).first)
126
- end
109
+ def test_get_user_by_uid_with_options
110
+ options = {:host => @@host, :localaccount => true}
111
+ assert_nothing_raised{ Admin.get_user(@user_id, options) }
112
+ assert_kind_of(User, Admin.get_user(@user_id, options))
113
+ end
127
114
 
128
- def test_users_with_block
129
- array = []
130
- assert_nothing_raised{
131
- Admin.users(:localaccount => true){ |u| array << u }
132
- }
133
- assert_kind_of(User, array[0])
134
- end
115
+ def test_get_user_with_no_options
116
+ assert_nothing_raised{ Admin.get_user(Etc.getlogin) }
117
+ assert_kind_of(User, Admin.get_user(Etc.getlogin))
118
+ end
135
119
 
136
- def test_get_group_basic
137
- assert_respond_to(Admin, :get_group)
138
- end
139
-
140
- def test_get_group_by_name
141
- assert_nothing_raised{ Admin.get_group(@group_name, :localaccount => true) }
142
- assert_kind_of(Group, Admin.get_group(@group_name, :localaccount => true))
143
- end
120
+ def test_get_user_expected_errors
121
+ assert_raises(ArgumentError){ Admin.get_user }
122
+ end
123
+
124
+ def test_users_basic
125
+ assert_respond_to(Admin, :users)
126
+ assert_nothing_raised{ Admin.users(:localaccount => true) }
127
+ end
144
128
 
145
- def test_get_group_by_gid
146
- assert_nothing_raised{ Admin.get_group(@group_id, :localaccount => true) }
147
- assert_kind_of(Group, Admin.get_group(@group_id, :localaccount => true))
148
- end
149
-
150
- def test_get_group_with_options
151
- assert_nothing_raised{ Admin.get_group(@group_name, :localaccount => true) }
152
- assert_kind_of(Group, Admin.get_group(@group_name, :localaccount => true))
153
- end
129
+ def test_users
130
+ assert_kind_of(Array, Admin.users(:localaccount => true))
131
+ assert_kind_of(User, Admin.users(:localaccount => true).first)
132
+ end
154
133
 
155
- def test_get_group_expected_errors
156
- assert_raise(ArgumentError){ Admin.get_group }
157
- end
158
-
159
- def test_groups_basic
160
- assert_respond_to(Admin, :groups)
161
- assert_nothing_raised{ Admin.groups(:localaccount => true) }
162
- end
134
+ def test_users_with_block
135
+ array = []
136
+ assert_nothing_raised{
137
+ Admin.users(:localaccount => true){ |u| array << u }
138
+ }
139
+ assert_kind_of(User, array[0])
140
+ end
163
141
 
164
- def test_groups
165
- assert_kind_of(Array, Admin.groups(:localaccount => true))
166
- assert_kind_of(Group, Admin.groups(:localaccount => true).first)
167
- end
168
-
169
- def test_groups_with_block
170
- array = []
171
- assert_nothing_raised{
172
- Admin.groups(:localaccount => true){ |g| array << g }
173
- }
174
- assert_kind_of(Group, array[0])
175
- end
142
+ def test_get_group_basic
143
+ assert_respond_to(Admin, :get_group)
144
+ end
145
+
146
+ def test_get_group_by_name
147
+ assert_nothing_raised{ Admin.get_group(@group_name, :localaccount => true) }
148
+ assert_kind_of(Group, Admin.get_group(@group_name, :localaccount => true))
149
+ end
176
150
 
177
- # User class
178
-
179
- def test_user_instance_caption
180
- assert_respond_to(@user, :caption)
181
- assert_respond_to(@user, :caption=)
182
- end
183
-
184
- def test_user_instance_description
185
- assert_respond_to(@user, :description)
186
- assert_respond_to(@user, :description=)
187
- end
188
-
189
- def test_user_instance_domain
190
- assert_respond_to(@user, :domain)
191
- assert_respond_to(@user, :domain=)
192
- end
193
-
194
- def test_user_instance_password
195
- assert_respond_to(@user, :password)
196
- assert_respond_to(@user, :password=)
197
- end
198
-
199
- def test_user_instance_full_name
200
- assert_respond_to(@user, :full_name)
201
- assert_respond_to(@user, :full_name=)
202
- end
203
-
204
- def test_user_instance_name
205
- assert_respond_to(@user, :name)
206
- assert_respond_to(@user, :name=)
207
- end
208
-
209
- def test_user_instance_sid
210
- assert_respond_to(@user, :sid)
211
- assert_respond_to(@user, :sid=)
212
- end
213
-
214
- def test_user_instance_status
215
- assert_respond_to(@user, :status)
216
- assert_respond_to(@user, :status=)
217
- end
218
-
219
- def test_user_instance_disabled
220
- assert_respond_to(@user, :disabled?)
221
- assert_respond_to(@user, :disabled=)
222
- end
223
-
224
- def test_user_instance_local
225
- assert_respond_to(@user, :local?)
226
- assert_respond_to(@user, :local=)
227
- end
228
-
229
- def test_user_instance_lockout
230
- assert_respond_to(@user, :lockout?)
231
- assert_respond_to(@user, :lockout=)
232
- end
233
-
234
- def test_user_instance_password_changeable
235
- assert_respond_to(@user, :password_changeable?)
236
- assert_respond_to(@user, :password_changeable=)
237
- end
238
-
239
- def test_user_instance_password_expires
240
- assert_respond_to(@user, :password_expires?)
241
- assert_respond_to(@user, :password_expires=)
242
- end
243
-
244
- def test_user_instance_password_required
245
- assert_respond_to(@user, :password_required?)
246
- assert_respond_to(@user, :password_required=)
247
- end
248
-
249
- def test_user_instance_account_type
250
- assert_respond_to(@user, :account_type)
251
- assert_respond_to(@user, :account_type=)
252
- end
151
+ def test_get_group_by_gid
152
+ assert_nothing_raised{ Admin.get_group(@group_id, :localaccount => true) }
153
+ assert_kind_of(Group, Admin.get_group(@group_id, :localaccount => true))
154
+ end
155
+
156
+ def test_get_group_with_options
157
+ assert_nothing_raised{ Admin.get_group(@group_name, :localaccount => true) }
158
+ assert_kind_of(Group, Admin.get_group(@group_name, :localaccount => true))
159
+ end
253
160
 
254
- def test_user_instance_uid
255
- assert_respond_to(@user, :uid)
256
- assert_respond_to(@user, :uid=)
257
- end
258
-
259
- def test_user_dir_basic
260
- assert_respond_to(@user, :dir)
261
- assert_respond_to(@user, :dir=)
262
- end
263
-
264
- def test_user_dir
265
- assert_nothing_raised{ @user = Admin.get_user(@user_name, :localaccount => true) }
266
- assert_kind_of([String, NilClass], @user.dir)
267
- end
268
-
269
- # Group class
270
-
271
- def test_group_instance_caption
272
- assert_respond_to(@group, :caption)
273
- assert_respond_to(@group, :caption=)
274
- end
275
-
276
- def test_group_instance_description
277
- assert_respond_to(@group, :description)
278
- assert_respond_to(@group, :description=)
279
- end
280
-
281
- def test_group_instance_domain
282
- assert_respond_to(@group, :domain)
283
- assert_respond_to(@group, :domain=)
284
- end
285
-
286
- def test_group_instance_install_date
287
- assert_respond_to(@group, :install_date)
288
- assert_respond_to(@group, :install_date=)
289
- end
290
-
291
- def test_group_instance_name
292
- assert_respond_to(@group, :name)
293
- assert_respond_to(@group, :name)
294
- end
295
-
296
- def test_group_instance_gid
297
- assert_respond_to(@group, :gid)
298
- assert_respond_to(@group, :gid=)
299
- end
300
-
301
- def test_group_instance_status
302
- assert_respond_to(@group, :status)
303
- assert_respond_to(@group, :status=)
304
- end
305
-
306
- def test_group_instance_sid
307
- assert_respond_to(@group, :sid)
308
- assert_respond_to(@group, :sid=)
309
- end
310
-
311
- def test_group_instance_sid_type
312
- assert_respond_to(@group, :sid_type)
313
- assert_respond_to(@group, :sid_type=)
314
- end
315
-
316
- def test_group_instance_local
317
- assert_respond_to(@group, :local?)
318
- assert_respond_to(@group, :local=)
319
- end
161
+ def test_get_group_with_no_options
162
+ assert_nothing_raised{ Admin.get_group("Administrators") }
163
+ assert_kind_of(Group, Admin.get_group("Administrators"))
164
+ end
165
+
166
+ def test_get_group_expected_errors
167
+ assert_raise(ArgumentError){ Admin.get_group }
168
+ end
169
+
170
+ def test_groups_basic
171
+ assert_respond_to(Admin, :groups)
172
+ assert_nothing_raised{ Admin.groups(:localaccount => true) }
173
+ end
174
+
175
+ def test_groups
176
+ assert_kind_of(Array, Admin.groups(:localaccount => true))
177
+ assert_kind_of(Group, Admin.groups(:localaccount => true).first)
178
+ end
179
+
180
+ def test_groups_with_block
181
+ array = []
182
+ assert_nothing_raised{
183
+ Admin.groups(:localaccount => true){ |g| array << g }
184
+ }
185
+ assert_kind_of(Group, array[0])
186
+ end
187
+
188
+ # User class
189
+
190
+ def test_user_instance_caption
191
+ assert_respond_to(@user, :caption)
192
+ assert_respond_to(@user, :caption=)
193
+ end
194
+
195
+ def test_user_instance_description
196
+ assert_respond_to(@user, :description)
197
+ assert_respond_to(@user, :description=)
198
+ end
199
+
200
+ def test_user_instance_domain
201
+ assert_respond_to(@user, :domain)
202
+ assert_respond_to(@user, :domain=)
203
+ end
204
+
205
+ def test_user_instance_password
206
+ assert_respond_to(@user, :password)
207
+ assert_respond_to(@user, :password=)
208
+ end
209
+
210
+ def test_user_instance_full_name
211
+ assert_respond_to(@user, :full_name)
212
+ assert_respond_to(@user, :full_name=)
213
+ end
214
+
215
+ def test_user_instance_name
216
+ assert_respond_to(@user, :name)
217
+ assert_respond_to(@user, :name=)
218
+ end
219
+
220
+ def test_user_instance_sid
221
+ assert_respond_to(@user, :sid)
222
+ assert_respond_to(@user, :sid=)
223
+ end
224
+
225
+ def test_user_instance_status
226
+ assert_respond_to(@user, :status)
227
+ assert_respond_to(@user, :status=)
228
+ end
229
+
230
+ def test_user_instance_disabled
231
+ assert_respond_to(@user, :disabled?)
232
+ assert_respond_to(@user, :disabled=)
233
+ end
234
+
235
+ def test_user_instance_local
236
+ assert_respond_to(@user, :local?)
237
+ assert_respond_to(@user, :local=)
238
+ end
239
+
240
+ def test_user_instance_lockout
241
+ assert_respond_to(@user, :lockout?)
242
+ assert_respond_to(@user, :lockout=)
243
+ end
244
+
245
+ def test_user_instance_password_changeable
246
+ assert_respond_to(@user, :password_changeable?)
247
+ assert_respond_to(@user, :password_changeable=)
248
+ end
249
+
250
+ def test_user_instance_password_expires
251
+ assert_respond_to(@user, :password_expires?)
252
+ assert_respond_to(@user, :password_expires=)
253
+ end
254
+
255
+ def test_user_instance_password_required
256
+ assert_respond_to(@user, :password_required?)
257
+ assert_respond_to(@user, :password_required=)
258
+ end
259
+
260
+ def test_user_instance_account_type
261
+ assert_respond_to(@user, :account_type)
262
+ assert_respond_to(@user, :account_type=)
263
+ end
264
+
265
+ def test_user_instance_uid
266
+ assert_respond_to(@user, :uid)
267
+ assert_respond_to(@user, :uid=)
268
+ end
269
+
270
+ def test_user_dir_basic
271
+ assert_respond_to(@user, :dir)
272
+ assert_respond_to(@user, :dir=)
273
+ end
274
+
275
+ def test_user_dir
276
+ assert_nothing_raised{ @user = Admin.get_user(@user_name, :localaccount => true) }
277
+ assert_kind_of([String, NilClass], @user.dir)
278
+ end
279
+
280
+ # Group class
281
+
282
+ def test_group_instance_caption
283
+ assert_respond_to(@group, :caption)
284
+ assert_respond_to(@group, :caption=)
285
+ end
286
+
287
+ def test_group_instance_description
288
+ assert_respond_to(@group, :description)
289
+ assert_respond_to(@group, :description=)
290
+ end
291
+
292
+ def test_group_instance_domain
293
+ assert_respond_to(@group, :domain)
294
+ assert_respond_to(@group, :domain=)
295
+ end
296
+
297
+ def test_group_instance_install_date
298
+ assert_respond_to(@group, :install_date)
299
+ assert_respond_to(@group, :install_date=)
300
+ end
301
+
302
+ def test_group_instance_name
303
+ assert_respond_to(@group, :name)
304
+ assert_respond_to(@group, :name)
305
+ end
306
+
307
+ def test_group_instance_gid
308
+ assert_respond_to(@group, :gid)
309
+ assert_respond_to(@group, :gid=)
310
+ end
311
+
312
+ def test_group_instance_status
313
+ assert_respond_to(@group, :status)
314
+ assert_respond_to(@group, :status=)
315
+ end
316
+
317
+ def test_group_instance_sid
318
+ assert_respond_to(@group, :sid)
319
+ assert_respond_to(@group, :sid=)
320
+ end
321
+
322
+ def test_group_instance_sid_type
323
+ assert_respond_to(@group, :sid_type)
324
+ assert_respond_to(@group, :sid_type=)
325
+ end
326
+
327
+ def test_group_instance_local
328
+ assert_respond_to(@group, :local?)
329
+ assert_respond_to(@group, :local=)
330
+ end
320
331
 
321
- def teardown
322
- @user = nil
323
- @user_name = nil
324
- @user_id = nil
325
- @group = nil
326
- @group_name = nil
327
- @group_id = nil
328
- end
332
+ def teardown
333
+ @user = nil
334
+ @user_name = nil
335
+ @user_id = nil
336
+ @group = nil
337
+ @group_name = nil
338
+ @group_id = nil
339
+ end
329
340
 
330
- def self.shutdown
331
- @@host = nil
332
- end
341
+ def self.shutdown
342
+ @@host = nil
343
+ end
333
344
  end