sys-admin 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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_win32"
12
+ else
13
+ require "tc_unix"
14
+ end
@@ -0,0 +1,78 @@
1
+ ###############################################################################
2
+ # tc_unix.rb
3
+ #
4
+ # Test suite for the Unix version of sys-admin.
5
+ ###############################################################################
6
+ base = File.basename(Dir.pwd)
7
+
8
+ if base == "test" || base =~ /sys-admin.*/
9
+ require "ftools"
10
+ Dir.chdir("..") if base == "test"
11
+ Dir.mkdir("sys") unless File.exists?("sys")
12
+ File.copy("admin.so","sys") if File.exists?("admin.so")
13
+ $LOAD_PATH.unshift(Dir.pwd)
14
+ end
15
+
16
+ require "test/unit"
17
+ require "sys/admin"
18
+ include Sys
19
+
20
+ class TC_Sys_Admin_Unix < Test::Unit::TestCase
21
+ def setup
22
+ @user = "nobody"
23
+ @userid = 0
24
+ @group = "sys"
25
+ @groupid = 3
26
+ end
27
+
28
+ def test_version
29
+ assert_equal("1.3.1", Admin::VERSION)
30
+ end
31
+
32
+ def test_get_login
33
+ assert_respond_to(Admin, :get_login)
34
+ assert_nothing_raised{ Admin.get_login }
35
+ assert_kind_of(String, Admin.get_login)
36
+ end
37
+
38
+ def test_get_user
39
+ assert_respond_to(Admin, :get_user)
40
+ assert_nothing_raised{ Admin.get_user(@user) }
41
+ assert_nothing_raised{ Admin.get_user(@userid) }
42
+ assert_kind_of(User, Admin.get_user(@user))
43
+ assert_kind_of(User, Admin.get_user(@userid))
44
+ assert_raises(AdminError){ Admin.get_user("foofoo") }
45
+ end
46
+
47
+ def test_users
48
+ assert_respond_to(Admin, :users)
49
+ assert_nothing_raised{ Admin.users }
50
+ assert_nothing_raised{ Admin.users{ |g| } }
51
+ assert_kind_of(Array, Admin.users)
52
+ assert_kind_of(User, Admin.users.first)
53
+ end
54
+
55
+ def test_get_group
56
+ assert_respond_to(Admin, :get_group)
57
+ assert_nothing_raised{ Admin.get_group(@group) }
58
+ assert_nothing_raised{ Admin.get_group(@groupid) }
59
+ assert_kind_of(Group, Admin.get_group(@group))
60
+ assert_kind_of(Group, Admin.get_group(@groupid))
61
+ assert_raises(AdminError){ Admin.get_group("foofoo") }
62
+ end
63
+
64
+ def test_groups
65
+ assert_respond_to(Admin, :groups)
66
+ assert_nothing_raised{ Admin.groups }
67
+ assert_nothing_raised{ Admin.groups{ |g| } }
68
+ assert_kind_of(Array, Admin.groups)
69
+ assert_kind_of(Group, Admin.groups.first)
70
+ end
71
+
72
+ def teardown
73
+ @user = nil
74
+ @userid = nil
75
+ @group = nil
76
+ @groupid = nil
77
+ end
78
+ end
@@ -0,0 +1,248 @@
1
+ ###############################################################################
2
+ # tc_win32.rb
3
+ #
4
+ # Test suite for the Win32 version of sys-admin.
5
+ ###############################################################################
6
+ base = File.basename(Dir.pwd)
7
+
8
+ if base == "test" || base =~ /sys-admin.*/
9
+ require "ftools"
10
+ Dir.chdir("..") if base == "test"
11
+ Dir.mkdir("sys") unless File.exists?("sys")
12
+ File.copy("lib/sys/win32.rb","sys/admin.rb")
13
+ $LOAD_PATH.unshift(Dir.pwd)
14
+ end
15
+
16
+ require "test/unit"
17
+ require "sys/admin"
18
+ require "socket"
19
+ include Sys
20
+
21
+ class TC_Sys_Admin_Win32 < Test::Unit::TestCase
22
+ def setup
23
+ @host = Socket.gethostname
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
31
+
32
+ def test_version
33
+ assert_equal("1.3.1", Admin::VERSION)
34
+ end
35
+
36
+ def test_get_login
37
+ assert_respond_to(Admin, :get_login)
38
+ assert_nothing_raised{ Admin.get_login }
39
+ assert_kind_of(String, Admin.get_login)
40
+ end
41
+
42
+ def test_get_user
43
+ assert_respond_to(Admin, :get_user)
44
+ assert_raises(ArgumentError){ Admin.get_user }
45
+ end
46
+
47
+ def test_get_user_local
48
+ assert_nothing_raised{ Admin.get_user(@user_name) }
49
+ assert_nothing_raised{ Admin.get_user(@user_id) }
50
+ assert_kind_of(User, Admin.get_user(@user_name))
51
+ assert_kind_of(User, Admin.get_user(@user_id))
52
+ end
53
+
54
+ def test_get_user_remote
55
+ assert_nothing_raised{ Admin.get_user(@user_name, @host) }
56
+ assert_nothing_raised{ Admin.get_user(@user_id, @host) }
57
+ assert_kind_of(User, Admin.get_user(@user_name, @host))
58
+ assert_kind_of(User, Admin.get_user(@user_id, @host))
59
+ end
60
+
61
+ def test_users
62
+ assert_respond_to(Admin, :users)
63
+ end
64
+
65
+ def test_users_local
66
+ assert_nothing_raised{ Admin.users }
67
+ assert_nothing_raised{ Admin.users{ |u| } }
68
+ assert_nothing_raised{ Admin.users(nil) }
69
+ assert_nothing_raised{ Admin.users(nil){ |u| } }
70
+ assert_kind_of(Array, Admin.users)
71
+ assert_kind_of(User, Admin.users.first)
72
+ end
73
+
74
+ def test_users_remote
75
+ assert_nothing_raised{ Admin.users(@host) }
76
+ assert_nothing_raised{ Admin.users(@host){ |u| } }
77
+ end
78
+
79
+ def test_user_instance_caption
80
+ assert_respond_to(@user, :caption)
81
+ assert_respond_to(@user, :caption=)
82
+ end
83
+
84
+ def test_user_instance_description
85
+ assert_respond_to(@user, :description)
86
+ assert_respond_to(@user, :description=)
87
+ end
88
+
89
+ def test_user_instance_domain
90
+ assert_respond_to(@user, :domain)
91
+ assert_respond_to(@user, :domain=)
92
+ end
93
+
94
+ def test_user_instance_password
95
+ assert_respond_to(@user, :password)
96
+ assert_respond_to(@user, :password=)
97
+ end
98
+
99
+ def test_user_instance_full_name
100
+ assert_respond_to(@user, :full_name)
101
+ assert_respond_to(@user, :full_name=)
102
+ end
103
+
104
+ def test_user_instance_name
105
+ assert_respond_to(@user, :name)
106
+ assert_respond_to(@user, :name=)
107
+ end
108
+
109
+ def test_user_instance_sid
110
+ assert_respond_to(@user, :sid)
111
+ assert_respond_to(@user, :sid=)
112
+ end
113
+
114
+ def test_user_instance_status
115
+ assert_respond_to(@user, :status)
116
+ assert_respond_to(@user, :status=)
117
+ end
118
+
119
+ def test_user_instance_disabled
120
+ assert_respond_to(@user, :disabled?)
121
+ assert_respond_to(@user, :disabled=)
122
+ end
123
+
124
+ def test_user_instance_local
125
+ assert_respond_to(@user, :local?)
126
+ assert_respond_to(@user, :local=)
127
+ end
128
+
129
+ def test_user_instance_lockout
130
+ assert_respond_to(@user, :lockout?)
131
+ assert_respond_to(@user, :lockout=)
132
+ end
133
+
134
+ def test_user_instance_password_changeable
135
+ assert_respond_to(@user, :password_changeable?)
136
+ assert_respond_to(@user, :password_changeable=)
137
+ end
138
+
139
+ def test_user_instance_password_expires
140
+ assert_respond_to(@user, :password_expires?)
141
+ assert_respond_to(@user, :password_expires=)
142
+ end
143
+
144
+ def test_user_instance_password_required
145
+ assert_respond_to(@user, :password_required?)
146
+ assert_respond_to(@user, :password_required=)
147
+ end
148
+
149
+ def test_user_instance_account_type
150
+ assert_respond_to(@user, :account_type)
151
+ assert_respond_to(@user, :account_type=)
152
+ end
153
+
154
+ def test_get_group
155
+ assert_respond_to(Admin, :get_group)
156
+ assert_raises(ArgumentError){ Admin.get_group }
157
+ end
158
+
159
+ def test_get_group_local
160
+ assert_nothing_raised{ Admin.get_group(@group_name) }
161
+ assert_kind_of(Group, Admin.get_group(@group_name))
162
+ assert_nothing_raised{ Admin.get_group(@group_id) }
163
+ assert_kind_of(Group, Admin.get_group(@group_id))
164
+ end
165
+
166
+ def test_get_group_remote
167
+ assert_nothing_raised{ Admin.get_group(@group_name, @host) }
168
+ assert_kind_of(Group, Admin.get_group(@group_name, @host))
169
+ end
170
+
171
+ def test_groups
172
+ assert_respond_to(Admin, :groups)
173
+ end
174
+
175
+ def test_groups_local
176
+ assert_nothing_raised{ Admin.groups }
177
+ assert_nothing_raised{ Admin.groups{ |g| } }
178
+ assert_kind_of(Array, Admin.groups)
179
+ assert_kind_of(Group, Admin.groups.first)
180
+ end
181
+
182
+ def test_groups_remote
183
+ assert_nothing_raised{ Admin.groups(@host) }
184
+ assert_nothing_raised{ Admin.groups(@host){ |g| } }
185
+ assert_kind_of(Array, Admin.groups(@host))
186
+ assert_kind_of(Group, Admin.groups(@host).first)
187
+ end
188
+
189
+ def test_group_instance_caption
190
+ assert_respond_to(@group, :caption)
191
+ assert_respond_to(@group, :caption=)
192
+ end
193
+
194
+ def test_group_instance_description
195
+ assert_respond_to(@group, :description)
196
+ assert_respond_to(@group, :description=)
197
+ end
198
+
199
+ def test_group_instance_domain
200
+ assert_respond_to(@group, :domain)
201
+ assert_respond_to(@group, :domain=)
202
+ end
203
+
204
+ def test_group_instance_install_date
205
+ assert_respond_to(@group, :install_date)
206
+ assert_respond_to(@group, :install_date=)
207
+ end
208
+
209
+ def test_group_instance_name
210
+ assert_respond_to(@group, :name)
211
+ assert_respond_to(@group, :name)
212
+ end
213
+
214
+ def test_group_instance_gid
215
+ assert_respond_to(@group, :gid)
216
+ assert_respond_to(@group, :gid=)
217
+ end
218
+
219
+ def test_group_instance_status
220
+ assert_respond_to(@group, :status)
221
+ assert_respond_to(@group, :status=)
222
+ end
223
+
224
+ def test_group_instance_sid
225
+ assert_respond_to(@group, :sid)
226
+ assert_respond_to(@group, :sid=)
227
+ end
228
+
229
+ def test_group_instance_sid_type
230
+ assert_respond_to(@group, :sid_type)
231
+ assert_respond_to(@group, :sid_type=)
232
+ end
233
+
234
+ def test_group_instance_local
235
+ assert_respond_to(@group, :local?)
236
+ assert_respond_to(@group, :local=)
237
+ end
238
+
239
+ def teardown
240
+ @host = nil
241
+ @user = nil
242
+ @user_name = nil
243
+ @user_id = nil
244
+ @group = nil
245
+ @group_name = nil
246
+ @group_id = nil
247
+ end
248
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.0
3
+ specification_version: 1
4
+ name: sys-admin
5
+ version: !ruby/object:Gem::Version
6
+ version: 1.3.1
7
+ date: 2006-08-01 00:00:00 -06:00
8
+ summary: A unified, cross platform replacement for the "etc" package.
9
+ require_paths:
10
+ - lib
11
+ email: djberg96@gmail.com
12
+ homepage: http://www.rubyforge.org/projects/sysutils
13
+ rubyforge_project: sysutils
14
+ description: A unified, cross platform replacement for the "etc" package.
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.8.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Daniel J. Berger
31
+ files:
32
+ - examples/groups.rb
33
+ - examples/users.rb
34
+ - lib/sys/unix.c
35
+ - lib/sys/unix.h
36
+ - lib/sys/win32.orig
37
+ - test/tc_unix.rb
38
+ - test/tc_win32.rb
39
+ - test/tc_admin.rb
40
+ - README
41
+ - CHANGES
42
+ - MANIFEST
43
+ test_files:
44
+ - test/tc_admin.rb
45
+ rdoc_options: []
46
+
47
+ extra_rdoc_files:
48
+ - CHANGES
49
+ - README
50
+ executables: []
51
+
52
+ extensions:
53
+ - extconf.rb
54
+ requirements: []
55
+
56
+ dependencies: []
57
+