sys-admin 1.7.6 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGES.md +8 -0
- data/Gemfile +2 -3
- data/README.md +3 -0
- data/Rakefile +13 -16
- data/lib/linux/sys/admin.rb +0 -2
- data/lib/sys/admin.rb +1 -1
- data/lib/windows/sys/admin.rb +313 -295
- data/spec/sys_admin_unix_spec.rb +262 -0
- data/spec/sys_admin_windows_spec.rb +350 -0
- data/sys-admin.gemspec +11 -5
- data.tar.gz.sig +0 -0
- metadata +13 -13
- metadata.gz.sig +0 -0
- data/test/test_sys_admin.rb +0 -23
- data/test/test_sys_admin_unix.rb +0 -260
- data/test/test_sys_admin_windows.rb +0 -337
data/sys-admin.gemspec
CHANGED
@@ -3,26 +3,32 @@ require 'rubygems'
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = 'sys-admin'
|
6
|
-
spec.version = '1.
|
6
|
+
spec.version = '1.8.0'
|
7
7
|
spec.author = 'Daniel J. Berger'
|
8
8
|
spec.license = 'Apache-2.0'
|
9
9
|
spec.email = 'djberg96@gmail.com'
|
10
10
|
spec.homepage = 'http://www.github.com/djberg96/sys-admin'
|
11
11
|
spec.summary = 'A unified, cross platform replacement for the "etc" library.'
|
12
|
-
spec.
|
12
|
+
spec.test_files = Dir['spec/*.rb']
|
13
13
|
spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
|
14
14
|
spec.cert_chain = ['certs/djberg96_pub.pem']
|
15
15
|
|
16
|
+
spec.extra_rdoc_files = Dir['*.rdoc']
|
17
|
+
|
16
18
|
spec.add_dependency('ffi', '~> 1.1')
|
17
|
-
spec.add_dependency('win32-security', '~> 0.5') if Gem.win_platform?
|
18
19
|
|
19
|
-
|
20
|
+
if Gem.win_platform?
|
21
|
+
spec.platform = Gem::Platform.new(['universal', 'mingw32'])
|
22
|
+
spec.add_dependency('win32-security', '~> 0.5')
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.add_development_dependency('rspec', '~> 3.9')
|
20
26
|
spec.add_development_dependency('rake')
|
21
27
|
|
22
28
|
spec.metadata = {
|
23
29
|
'homepage_uri' => 'https://github.com/djberg96/sys-admin',
|
24
30
|
'bug_tracker_uri' => 'https://github.com/djberg96/sys-admin/issues',
|
25
|
-
'changelog_uri' => 'https://github.com/djberg96/sys-admin/blob/
|
31
|
+
'changelog_uri' => 'https://github.com/djberg96/sys-admin/blob/main/CHANGES.md',
|
26
32
|
'documentation_uri' => 'https://github.com/djberg96/sys-admin/wiki',
|
27
33
|
'source_code_uri' => 'https://github.com/djberg96/sys-admin',
|
28
34
|
'wiki_uri' => 'https://github.com/djberg96/sys-admin/wiki'
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sys-admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
|
36
36
|
WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2021-
|
38
|
+
date: 2021-08-26 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: ffi
|
@@ -52,19 +52,19 @@ dependencies:
|
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '1.1'
|
54
54
|
- !ruby/object:Gem::Dependency
|
55
|
-
name:
|
55
|
+
name: rspec
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
|
-
- - "
|
58
|
+
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
60
|
+
version: '3.9'
|
61
61
|
type: :development
|
62
62
|
prerelease: false
|
63
63
|
version_requirements: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
|
-
- - "
|
65
|
+
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
67
|
+
version: '3.9'
|
68
68
|
- !ruby/object:Gem::Dependency
|
69
69
|
name: rake
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
@@ -111,17 +111,16 @@ files:
|
|
111
111
|
- lib/sys/admin/custom.rb
|
112
112
|
- lib/unix/sys/admin.rb
|
113
113
|
- lib/windows/sys/admin.rb
|
114
|
+
- spec/sys_admin_unix_spec.rb
|
115
|
+
- spec/sys_admin_windows_spec.rb
|
114
116
|
- sys-admin.gemspec
|
115
|
-
- test/test_sys_admin.rb
|
116
|
-
- test/test_sys_admin_unix.rb
|
117
|
-
- test/test_sys_admin_windows.rb
|
118
117
|
homepage: http://www.github.com/djberg96/sys-admin
|
119
118
|
licenses:
|
120
119
|
- Apache-2.0
|
121
120
|
metadata:
|
122
121
|
homepage_uri: https://github.com/djberg96/sys-admin
|
123
122
|
bug_tracker_uri: https://github.com/djberg96/sys-admin/issues
|
124
|
-
changelog_uri: https://github.com/djberg96/sys-admin/blob/
|
123
|
+
changelog_uri: https://github.com/djberg96/sys-admin/blob/main/CHANGES.md
|
125
124
|
documentation_uri: https://github.com/djberg96/sys-admin/wiki
|
126
125
|
source_code_uri: https://github.com/djberg96/sys-admin
|
127
126
|
wiki_uri: https://github.com/djberg96/sys-admin/wiki
|
@@ -140,9 +139,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
139
|
- !ruby/object:Gem::Version
|
141
140
|
version: '0'
|
142
141
|
requirements: []
|
143
|
-
rubygems_version: 3.
|
142
|
+
rubygems_version: 3.1.4
|
144
143
|
signing_key:
|
145
144
|
specification_version: 4
|
146
145
|
summary: A unified, cross platform replacement for the "etc" library.
|
147
146
|
test_files:
|
148
|
-
-
|
147
|
+
- spec/sys_admin_unix_spec.rb
|
148
|
+
- spec/sys_admin_windows_spec.rb
|
metadata.gz.sig
CHANGED
Binary file
|
data/test/test_sys_admin.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
###############################################################################
|
2
|
-
# test_sys_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
|
-
require 'test-unit'
|
8
|
-
|
9
|
-
if File::ALT_SEPARATOR
|
10
|
-
require 'test_sys_admin_windows'
|
11
|
-
else
|
12
|
-
require 'test_sys_admin_unix'
|
13
|
-
end
|
14
|
-
|
15
|
-
class TC_Sys_Admin_All < Test::Unit::TestCase
|
16
|
-
test "version is set to expected value" do
|
17
|
-
assert_equal('1.7.6', Sys::Admin::VERSION)
|
18
|
-
end
|
19
|
-
|
20
|
-
test "version constant is frozen" do
|
21
|
-
assert_true(Sys::Admin::VERSION.frozen?)
|
22
|
-
end
|
23
|
-
end
|
data/test/test_sys_admin_unix.rb
DELETED
@@ -1,260 +0,0 @@
|
|
1
|
-
###############################################################################
|
2
|
-
# test_sys_admin_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
|
-
@user_id = 0
|
15
|
-
@group = 'sys'
|
16
|
-
@group_id = 3
|
17
|
-
end
|
18
|
-
|
19
|
-
## Admin singleton methods
|
20
|
-
|
21
|
-
test "get_login basic functionality" do
|
22
|
-
assert_respond_to(Admin, :get_login)
|
23
|
-
assert_nothing_raised{ Admin.get_login }
|
24
|
-
end
|
25
|
-
|
26
|
-
test "get_login returns a string" do
|
27
|
-
assert_kind_of(String, Admin.get_login)
|
28
|
-
assert_true(Admin.get_login.length > 0)
|
29
|
-
end
|
30
|
-
|
31
|
-
test "get_user basic functionality" do
|
32
|
-
assert_respond_to(Admin, :get_user)
|
33
|
-
assert_nothing_raised{ Admin.get_user(@user) }
|
34
|
-
assert_nothing_raised{ Admin.get_user(@user_id) }
|
35
|
-
end
|
36
|
-
|
37
|
-
test "get_user with a string argument works as expected" do
|
38
|
-
assert_kind_of(Admin::User, Admin.get_user(@user))
|
39
|
-
end
|
40
|
-
|
41
|
-
test "get_user with an integer argument works as expected" do
|
42
|
-
assert_kind_of(Admin::User, Admin.get_user(@user_id))
|
43
|
-
end
|
44
|
-
|
45
|
-
test "get_user requires one argument only" do
|
46
|
-
assert_raise(ArgumentError){ Admin.get_user }
|
47
|
-
assert_raise(ArgumentError){ Admin.get_user(@user, @user) }
|
48
|
-
end
|
49
|
-
|
50
|
-
test "get_user requires a string or integer argument" do
|
51
|
-
assert_raise(TypeError){ Admin.get_user([]) }
|
52
|
-
end
|
53
|
-
|
54
|
-
test "get_user raises an Error if the user cannot be found" do
|
55
|
-
assert_raise(Admin::Error){ Admin.get_user('foofoofoo') }
|
56
|
-
end
|
57
|
-
|
58
|
-
test "users basic functionality" do
|
59
|
-
assert_respond_to(Admin, :users)
|
60
|
-
assert_nothing_raised{ Admin.users }
|
61
|
-
end
|
62
|
-
|
63
|
-
test "users returns an array of User objects" do
|
64
|
-
users = Admin.users
|
65
|
-
assert_kind_of(Array, users)
|
66
|
-
assert_kind_of(Admin::User, users.first)
|
67
|
-
end
|
68
|
-
|
69
|
-
test "users does not accept any arguments" do
|
70
|
-
assert_raise(ArgumentError){ Admin.users(@user_id) }
|
71
|
-
end
|
72
|
-
|
73
|
-
test "get_group basic functionality" do
|
74
|
-
assert_respond_to(Admin, :get_group)
|
75
|
-
assert_nothing_raised{ Admin.get_group(@group) }
|
76
|
-
assert_nothing_raised{ Admin.get_group(@group_id) }
|
77
|
-
end
|
78
|
-
|
79
|
-
test "get_group accepts a string argument" do
|
80
|
-
assert_kind_of(Admin::Group, Admin.get_group(@group))
|
81
|
-
end
|
82
|
-
|
83
|
-
test "get_group accepts an integer argument" do
|
84
|
-
assert_kind_of(Admin::Group, Admin.get_group(@group_id))
|
85
|
-
end
|
86
|
-
|
87
|
-
test "get_group requires one argument only" do
|
88
|
-
assert_raise(ArgumentError){ Admin.get_group }
|
89
|
-
assert_raise(ArgumentError){ Admin.get_group(@group_id, @group_id) }
|
90
|
-
end
|
91
|
-
|
92
|
-
test "get_group raises a TypeError if an invalid type is passed" do
|
93
|
-
assert_raise(TypeError){ Admin.get_group([]) }
|
94
|
-
end
|
95
|
-
|
96
|
-
test "get_group raises an Error if the group cannot be found" do
|
97
|
-
assert_raise(Admin::Error){ Admin.get_group('foofoofoo') }
|
98
|
-
end
|
99
|
-
|
100
|
-
test "groups basic functionality" do
|
101
|
-
assert_respond_to(Admin, :groups)
|
102
|
-
assert_nothing_raised{ Admin.groups }
|
103
|
-
end
|
104
|
-
|
105
|
-
test "groups returns an array of Group objects" do
|
106
|
-
groups = Admin.groups
|
107
|
-
assert_kind_of(Array, groups)
|
108
|
-
assert_kind_of(Admin::Group, groups.first)
|
109
|
-
end
|
110
|
-
|
111
|
-
test "groups method does not accept any arguments" do
|
112
|
-
assert_raise(ArgumentError){ Admin.groups(@group_id) }
|
113
|
-
end
|
114
|
-
|
115
|
-
## User Tests
|
116
|
-
|
117
|
-
test "user.name behaves as expected" do
|
118
|
-
@user = Admin.get_user(@user_id)
|
119
|
-
assert_respond_to(@user, :name)
|
120
|
-
assert_kind_of(String, @user.name)
|
121
|
-
end
|
122
|
-
|
123
|
-
test "user.passwd behaves as expected" do
|
124
|
-
@user = Admin.get_user(@user_id)
|
125
|
-
assert_respond_to(@user, :passwd)
|
126
|
-
assert_kind_of(String, @user.passwd)
|
127
|
-
end
|
128
|
-
|
129
|
-
test "user.uid behaves as expected" do
|
130
|
-
@user = Admin.get_user(@user_id)
|
131
|
-
assert_respond_to(@user, :uid)
|
132
|
-
assert_kind_of(Integer, @user.uid)
|
133
|
-
end
|
134
|
-
|
135
|
-
test "user.gid behaves as expected" do
|
136
|
-
@user = Admin.get_user(@user_id)
|
137
|
-
assert_respond_to(@user, :gid)
|
138
|
-
assert_kind_of(Integer, @user.gid)
|
139
|
-
end
|
140
|
-
|
141
|
-
test "user.dir behaves as expected" do
|
142
|
-
@user = Admin.get_user(@user_id)
|
143
|
-
assert_respond_to(@user, :dir)
|
144
|
-
assert_kind_of(String, @user.dir)
|
145
|
-
end
|
146
|
-
|
147
|
-
test "user.shell behaves as expected" do
|
148
|
-
@user = Admin.get_user(@user_id)
|
149
|
-
assert_respond_to(@user, :shell)
|
150
|
-
assert_kind_of(String, @user.shell)
|
151
|
-
end
|
152
|
-
|
153
|
-
test "user.gecos behaves as expected" do
|
154
|
-
@user = Admin.get_user(@user_id)
|
155
|
-
assert_respond_to(@user, :gecos)
|
156
|
-
assert_kind_of([String, NilClass], @user.gecos)
|
157
|
-
end
|
158
|
-
|
159
|
-
test "user.quota behaves as expected" do
|
160
|
-
@user = Admin.get_user(@user_id)
|
161
|
-
assert_respond_to(@user, :quota)
|
162
|
-
assert_true([Integer, NilClass].include?(@user.quota.class))
|
163
|
-
end
|
164
|
-
|
165
|
-
test "user.age behaves as expected" do
|
166
|
-
@user = Admin.get_user(@user_id)
|
167
|
-
assert_respond_to(@user, :age)
|
168
|
-
assert_true([Integer, NilClass].include?(@user.age.class))
|
169
|
-
end
|
170
|
-
|
171
|
-
test "user.access behaves as expected" do
|
172
|
-
@user = Admin.get_user(@user_id)
|
173
|
-
assert_respond_to(@user, :access_class)
|
174
|
-
assert_true([String, NilClass].include?(@user.access_class.class))
|
175
|
-
end
|
176
|
-
|
177
|
-
test "user.comment behaves as expected" do
|
178
|
-
@user = Admin.get_user(@user_id)
|
179
|
-
assert_respond_to(@user, :comment)
|
180
|
-
assert_true([String, NilClass].include?(@user.comment.class))
|
181
|
-
end
|
182
|
-
|
183
|
-
test "user.expire behaves as expected" do
|
184
|
-
@user = Admin.get_user(@user_id)
|
185
|
-
assert_respond_to(@user, :expire)
|
186
|
-
assert_true([Time, NilClass].include?(@user.expire.class))
|
187
|
-
end
|
188
|
-
|
189
|
-
test "user.change behaves as expected" do
|
190
|
-
@user = Admin.get_user(@user_id)
|
191
|
-
assert_respond_to(@user, :change)
|
192
|
-
assert_true([Time, NilClass].include?(@user.change.class))
|
193
|
-
end
|
194
|
-
|
195
|
-
test "user.login_time behaves as expected" do
|
196
|
-
@user = Admin.get_user(@user_id)
|
197
|
-
assert_respond_to(@user, :login_time)
|
198
|
-
assert_true([Time, NilClass].include?(@user.login_time.class))
|
199
|
-
end
|
200
|
-
|
201
|
-
test "user.login_device behaves as expected" do
|
202
|
-
@user = Admin.get_user(@user_id)
|
203
|
-
assert_respond_to(@user, :login_device)
|
204
|
-
assert_true([String, NilClass].include?(@user.login_device.class))
|
205
|
-
end
|
206
|
-
|
207
|
-
test "user.login_host behaves as expected" do
|
208
|
-
@user = Admin.get_user(@user_id)
|
209
|
-
assert_respond_to(@user, :login_host)
|
210
|
-
assert_true([String, NilClass].include?(@user.login_host.class))
|
211
|
-
end
|
212
|
-
|
213
|
-
test "user.groups behaves as expected" do
|
214
|
-
@user = Admin.get_user(@user_id)
|
215
|
-
assert_respond_to(@user, :groups)
|
216
|
-
assert_kind_of(Array, @user.groups)
|
217
|
-
end
|
218
|
-
|
219
|
-
## Group Tests
|
220
|
-
|
221
|
-
test "group.name behaves as expected" do
|
222
|
-
@group = Admin.get_group(@group_id)
|
223
|
-
assert_respond_to(@group, :name)
|
224
|
-
assert_kind_of(String, @group.name)
|
225
|
-
end
|
226
|
-
|
227
|
-
test "group.gid behaves as expected" do
|
228
|
-
@group = Admin.get_group(@group_id)
|
229
|
-
assert_respond_to(@group, :gid)
|
230
|
-
assert_kind_of(Integer, @group.gid)
|
231
|
-
end
|
232
|
-
|
233
|
-
test "group.members behaves as expected" do
|
234
|
-
@group = Admin.get_group(@group_id)
|
235
|
-
assert_respond_to(@group, :members)
|
236
|
-
assert_kind_of(Array, @group.members)
|
237
|
-
end
|
238
|
-
|
239
|
-
test "group.passwd behaves as expected" do
|
240
|
-
@group = Admin.get_group(@group_id)
|
241
|
-
assert_respond_to(@group, :passwd)
|
242
|
-
assert_kind_of(String, @group.passwd)
|
243
|
-
end
|
244
|
-
|
245
|
-
## FFI
|
246
|
-
|
247
|
-
test "ffi functions are private" do
|
248
|
-
methods = Admin.methods(false).map{ |e| e.to_s }
|
249
|
-
assert_false(methods.include?('getlogin'))
|
250
|
-
assert_false(methods.include?('getlogin_r'))
|
251
|
-
assert_false(methods.include?('strerror'))
|
252
|
-
end
|
253
|
-
|
254
|
-
def teardown
|
255
|
-
@user = nil
|
256
|
-
@user_id = nil
|
257
|
-
@group = nil
|
258
|
-
@group_id = nil
|
259
|
-
end
|
260
|
-
end
|
@@ -1,337 +0,0 @@
|
|
1
|
-
###############################################################################
|
2
|
-
# test_sys_admin_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 'win32/security'
|
13
|
-
require 'socket'
|
14
|
-
include Sys
|
15
|
-
|
16
|
-
class TC_Sys_Admin_Win32 < Test::Unit::TestCase
|
17
|
-
def self.startup
|
18
|
-
@@host = Socket.gethostname
|
19
|
-
@@elevated = Win32::Security.elevated_security?
|
20
|
-
end
|
21
|
-
|
22
|
-
def setup
|
23
|
-
@user = User.new
|
24
|
-
@user_name = 'Guest'
|
25
|
-
@user_id = 501 # best guess, may fail
|
26
|
-
@group = Group.new
|
27
|
-
@group_name = 'Guests'
|
28
|
-
@group_id = 546 # best guess, may fail
|
29
|
-
end
|
30
|
-
|
31
|
-
# Admin singleton methods
|
32
|
-
|
33
|
-
def test_01_add_user
|
34
|
-
omit_unless(@@elevated)
|
35
|
-
assert_respond_to(Admin, :add_user)
|
36
|
-
assert_nothing_raised{
|
37
|
-
Admin.add_user(:name => 'foo', :password => 'a1b2c3D4')
|
38
|
-
}
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_02_config_user
|
42
|
-
omit_unless(@@elevated)
|
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 => 'd1c2b3A4'
|
50
|
-
)
|
51
|
-
}
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_06_delete_user
|
55
|
-
omit_unless(@@elevated)
|
56
|
-
assert_respond_to(Admin, :delete_user)
|
57
|
-
assert_nothing_raised{ Admin.delete_user('foo') }
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_01_add_group
|
61
|
-
omit_unless(@@elevated)
|
62
|
-
assert_respond_to(Admin, :add_group)
|
63
|
-
assert_nothing_raised{ Admin.add_group(:name => 'bar') }
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_02_configure_group
|
67
|
-
omit_unless(@@elevated)
|
68
|
-
assert_respond_to(Admin, :configure_group)
|
69
|
-
assert_nothing_raised{
|
70
|
-
Admin.configure_group(:name => 'bar', :description => 'delete me')
|
71
|
-
}
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_03_add_group_member
|
75
|
-
omit_unless(@@elevated)
|
76
|
-
assert_respond_to(Admin, :add_group_member)
|
77
|
-
assert_nothing_raised{ Admin.add_group_member('foo', 'bar') }
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_04_remove_group_member
|
81
|
-
omit_unless(@@elevated)
|
82
|
-
assert_respond_to(Admin, :remove_group_member)
|
83
|
-
assert_nothing_raised{ Admin.remove_group_member('foo', 'bar') }
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_05_delete_group
|
87
|
-
omit_unless(@@elevated)
|
88
|
-
assert_respond_to(Admin, :delete_group)
|
89
|
-
assert_nothing_raised{ Admin.delete_group('bar') }
|
90
|
-
end
|
91
|
-
|
92
|
-
test "get_login basic functionality" do
|
93
|
-
assert_respond_to(Admin, :get_login)
|
94
|
-
assert_nothing_raised{ Admin.get_login }
|
95
|
-
end
|
96
|
-
|
97
|
-
test "get_login returns a string" do
|
98
|
-
assert_kind_of(String, Admin.get_login)
|
99
|
-
assert_true(Admin.get_login.size > 0)
|
100
|
-
end
|
101
|
-
|
102
|
-
test "get_login does not accept any arguments" do
|
103
|
-
assert_raise(ArgumentError){ Admin.get_login('foo') }
|
104
|
-
end
|
105
|
-
|
106
|
-
test "get_user basic functionality" do
|
107
|
-
assert_respond_to(Admin, :get_user)
|
108
|
-
end
|
109
|
-
|
110
|
-
test "get_user with string argument works as expected" do
|
111
|
-
assert_nothing_raised{ Admin.get_user(@user_name, :localaccount => true) }
|
112
|
-
assert_kind_of(User, Admin.get_user(@user_name, :localaccount => true))
|
113
|
-
end
|
114
|
-
|
115
|
-
test "get user with integer argument works as expected" do
|
116
|
-
assert_nothing_raised{ Admin.get_user(@user_id, :localaccount => true) }
|
117
|
-
assert_kind_of(User, Admin.get_user(@user_id, :localaccount => true))
|
118
|
-
end
|
119
|
-
|
120
|
-
test "get_user method by string accepts a hash of options" do
|
121
|
-
options = {:host => @@host, :localaccount => true}
|
122
|
-
assert_nothing_raised{ Admin.get_user(@user_name, options) }
|
123
|
-
assert_kind_of(User, Admin.get_user(@user_name, options))
|
124
|
-
end
|
125
|
-
|
126
|
-
test "get_user method by uid accepts a hash of options" do
|
127
|
-
options = {:host => @@host, :localaccount => true}
|
128
|
-
assert_nothing_raised{ Admin.get_user(@user_id, options) }
|
129
|
-
assert_kind_of(User, Admin.get_user(@user_id, options))
|
130
|
-
end
|
131
|
-
|
132
|
-
test "get_user method requires an argument" do
|
133
|
-
assert_raises(ArgumentError){ Admin.get_user }
|
134
|
-
end
|
135
|
-
|
136
|
-
test "users method basic functionality" do
|
137
|
-
assert_respond_to(Admin, :users)
|
138
|
-
assert_nothing_raised{ Admin.users(:localaccount => true) }
|
139
|
-
end
|
140
|
-
|
141
|
-
test "users method returns an array of User objects" do
|
142
|
-
assert_kind_of(Array, Admin.users(:localaccount => true))
|
143
|
-
assert_kind_of(User, Admin.users(:localaccount => true).first)
|
144
|
-
end
|
145
|
-
|
146
|
-
test "get_group basic functionality" do
|
147
|
-
assert_respond_to(Admin, :get_group)
|
148
|
-
end
|
149
|
-
|
150
|
-
test "get_group method returns expected results with a string argument" do
|
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
|
154
|
-
|
155
|
-
test "get_group method returns expected results with an integer argument" do
|
156
|
-
assert_nothing_raised{ Admin.get_group(@group_id, :localaccount => true) }
|
157
|
-
assert_kind_of(Group, Admin.get_group(@group_id, :localaccount => true))
|
158
|
-
end
|
159
|
-
|
160
|
-
# TODO: Update
|
161
|
-
test "get_group method accepts a hash of options" do
|
162
|
-
assert_nothing_raised{ Admin.get_group(@group_name, :localaccount => true) }
|
163
|
-
assert_kind_of(Group, Admin.get_group(@group_name, :localaccount => true))
|
164
|
-
end
|
165
|
-
|
166
|
-
test "get_group method requires an argument" do
|
167
|
-
assert_raise(ArgumentError){ Admin.get_group }
|
168
|
-
end
|
169
|
-
|
170
|
-
test "get_groups method basic functionality" do
|
171
|
-
assert_respond_to(Admin, :groups)
|
172
|
-
assert_nothing_raised{ Admin.groups(:localaccount => true) }
|
173
|
-
end
|
174
|
-
|
175
|
-
test "get_groups method returns an array of Group objects" do
|
176
|
-
assert_kind_of(Array, Admin.groups(:localaccount => true))
|
177
|
-
assert_kind_of(Group, Admin.groups(:localaccount => true).first)
|
178
|
-
end
|
179
|
-
|
180
|
-
# User class
|
181
|
-
|
182
|
-
test "caption accessor for User class" do
|
183
|
-
assert_respond_to(@user, :caption)
|
184
|
-
assert_respond_to(@user, :caption=)
|
185
|
-
end
|
186
|
-
|
187
|
-
test "description accessor for User class" do
|
188
|
-
assert_respond_to(@user, :description)
|
189
|
-
assert_respond_to(@user, :description=)
|
190
|
-
end
|
191
|
-
|
192
|
-
test "domain accessor for User class" do
|
193
|
-
assert_respond_to(@user, :domain)
|
194
|
-
assert_respond_to(@user, :domain=)
|
195
|
-
end
|
196
|
-
|
197
|
-
test "password accessor for User class" do
|
198
|
-
assert_respond_to(@user, :password)
|
199
|
-
assert_respond_to(@user, :password=)
|
200
|
-
end
|
201
|
-
|
202
|
-
test "full_name accessor for User class" do
|
203
|
-
assert_respond_to(@user, :full_name)
|
204
|
-
assert_respond_to(@user, :full_name=)
|
205
|
-
end
|
206
|
-
|
207
|
-
test "name accessor for User class" do
|
208
|
-
assert_respond_to(@user, :name)
|
209
|
-
assert_respond_to(@user, :name=)
|
210
|
-
end
|
211
|
-
|
212
|
-
test "sid accessor for User class" do
|
213
|
-
assert_respond_to(@user, :sid)
|
214
|
-
assert_respond_to(@user, :sid=)
|
215
|
-
end
|
216
|
-
|
217
|
-
test "status accessor for User class" do
|
218
|
-
assert_respond_to(@user, :status)
|
219
|
-
assert_respond_to(@user, :status=)
|
220
|
-
end
|
221
|
-
|
222
|
-
test "disabled accessor for User class" do
|
223
|
-
assert_respond_to(@user, :disabled?)
|
224
|
-
assert_respond_to(@user, :disabled=)
|
225
|
-
end
|
226
|
-
|
227
|
-
test "local accessor for User class" do
|
228
|
-
assert_respond_to(@user, :local?)
|
229
|
-
assert_respond_to(@user, :local=)
|
230
|
-
end
|
231
|
-
|
232
|
-
test "lockout accessor for User class" do
|
233
|
-
assert_respond_to(@user, :lockout?)
|
234
|
-
assert_respond_to(@user, :lockout=)
|
235
|
-
end
|
236
|
-
|
237
|
-
test "password_changeable accessor for User class" do
|
238
|
-
assert_respond_to(@user, :password_changeable?)
|
239
|
-
assert_respond_to(@user, :password_changeable=)
|
240
|
-
end
|
241
|
-
|
242
|
-
test "password_expires accessor for User class" do
|
243
|
-
assert_respond_to(@user, :password_expires?)
|
244
|
-
assert_respond_to(@user, :password_expires=)
|
245
|
-
end
|
246
|
-
|
247
|
-
test "password_required accessor for User class" do
|
248
|
-
assert_respond_to(@user, :password_required?)
|
249
|
-
assert_respond_to(@user, :password_required=)
|
250
|
-
end
|
251
|
-
|
252
|
-
test "account_type accessor for User class" do
|
253
|
-
assert_respond_to(@user, :account_type)
|
254
|
-
assert_respond_to(@user, :account_type=)
|
255
|
-
end
|
256
|
-
|
257
|
-
test "uid accessor for User class" do
|
258
|
-
assert_respond_to(@user, :uid)
|
259
|
-
assert_respond_to(@user, :uid=)
|
260
|
-
end
|
261
|
-
|
262
|
-
test "dir accessor for User class" do
|
263
|
-
assert_respond_to(@user, :dir)
|
264
|
-
assert_respond_to(@user, :dir=)
|
265
|
-
end
|
266
|
-
|
267
|
-
test "dir method returns either a string or nil" do
|
268
|
-
assert_nothing_raised{ @user = Admin.get_user(@user_name, :localaccount => true) }
|
269
|
-
assert_kind_of([String, NilClass], @user.dir)
|
270
|
-
end
|
271
|
-
|
272
|
-
# Group class
|
273
|
-
|
274
|
-
test "caption accessor for Group class" do
|
275
|
-
assert_respond_to(@group, :caption)
|
276
|
-
assert_respond_to(@group, :caption=)
|
277
|
-
end
|
278
|
-
|
279
|
-
test "description accessor for Group class" do
|
280
|
-
assert_respond_to(@group, :description)
|
281
|
-
assert_respond_to(@group, :description=)
|
282
|
-
end
|
283
|
-
|
284
|
-
test "domain accessor for Group class" do
|
285
|
-
assert_respond_to(@group, :domain)
|
286
|
-
assert_respond_to(@group, :domain=)
|
287
|
-
end
|
288
|
-
|
289
|
-
test "install_date accessor for Group class" do
|
290
|
-
assert_respond_to(@group, :install_date)
|
291
|
-
assert_respond_to(@group, :install_date=)
|
292
|
-
end
|
293
|
-
|
294
|
-
test "name accessor for Group class" do
|
295
|
-
assert_respond_to(@group, :name)
|
296
|
-
assert_respond_to(@group, :name)
|
297
|
-
end
|
298
|
-
|
299
|
-
test "gid accessor for Group class" do
|
300
|
-
assert_respond_to(@group, :gid)
|
301
|
-
assert_respond_to(@group, :gid=)
|
302
|
-
end
|
303
|
-
|
304
|
-
test "status accessor for Group class" do
|
305
|
-
assert_respond_to(@group, :status)
|
306
|
-
assert_respond_to(@group, :status=)
|
307
|
-
end
|
308
|
-
|
309
|
-
test "sid accessor for Group class" do
|
310
|
-
assert_respond_to(@group, :sid)
|
311
|
-
assert_respond_to(@group, :sid=)
|
312
|
-
end
|
313
|
-
|
314
|
-
test "sid_type accessor for Group class" do
|
315
|
-
assert_respond_to(@group, :sid_type)
|
316
|
-
assert_respond_to(@group, :sid_type=)
|
317
|
-
end
|
318
|
-
|
319
|
-
test "local accessor for Group class" do
|
320
|
-
assert_respond_to(@group, :local?)
|
321
|
-
assert_respond_to(@group, :local=)
|
322
|
-
end
|
323
|
-
|
324
|
-
def teardown
|
325
|
-
@user = nil
|
326
|
-
@user_name = nil
|
327
|
-
@user_id = nil
|
328
|
-
@group = nil
|
329
|
-
@group_name = nil
|
330
|
-
@group_id = nil
|
331
|
-
end
|
332
|
-
|
333
|
-
def self.shutdown
|
334
|
-
@@host = nil
|
335
|
-
@@elevated = nil
|
336
|
-
end
|
337
|
-
end
|