sys-admin 1.8.0-universal-mingw32 → 1.8.2-universal-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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGES.md +14 -1
- data/MANIFEST.md +4 -3
- data/README.md +7 -0
- data/Rakefile +5 -4
- data/lib/bsd/sys/admin.rb +28 -24
- data/lib/darwin/sys/admin.rb +37 -19
- data/lib/linux/sys/admin.rb +18 -14
- data/lib/sunos/sys/admin.rb +16 -12
- data/lib/sys/admin/common.rb +5 -4
- data/lib/sys/admin/custom.rb +6 -3
- data/lib/sys/admin.rb +7 -1
- data/lib/sys-admin.rb +2 -0
- data/lib/unix/sys/admin.rb +6 -6
- data/lib/windows/sys/admin.rb +77 -81
- data/spec/spec_helper.rb +22 -0
- data/spec/sys_admin_shared.rb +15 -0
- data/spec/sys_admin_unix_spec.rb +59 -56
- data/spec/sys_admin_windows_spec.rb +80 -90
- data/sys-admin.gemspec +11 -7
- data.tar.gz.sig +0 -0
- metadata +36 -2
- metadata.gz.sig +0 -0
data/spec/sys_admin_unix_spec.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
###############################################################################
|
2
4
|
# sys_admin_unix_rspec.rb
|
3
5
|
#
|
4
6
|
# Test suite for the Unix version of sys-admin. This test should be run
|
5
7
|
# via the 'rake spec' task.
|
6
8
|
###############################################################################
|
7
|
-
require '
|
8
|
-
require 'sys/admin'
|
9
|
+
require 'spec_helper'
|
9
10
|
|
10
11
|
RSpec.describe Sys::Admin, :unix do
|
11
12
|
let(:user) { 'nobody' }
|
@@ -13,237 +14,239 @@ RSpec.describe Sys::Admin, :unix do
|
|
13
14
|
let(:group) { 'sys' }
|
14
15
|
let(:group_id) { 3 }
|
15
16
|
|
16
|
-
context
|
17
|
-
describe
|
18
|
-
example
|
17
|
+
context 'singleton methods' do
|
18
|
+
describe 'get_login' do
|
19
|
+
example 'get_login basic functionality' do
|
19
20
|
expect(described_class).to respond_to(:get_login)
|
20
21
|
expect{ described_class.get_login }.not_to raise_error
|
21
22
|
end
|
22
23
|
|
23
|
-
example
|
24
|
+
example 'get_login returns a string' do
|
24
25
|
expect(described_class.get_login).to be_kind_of(String)
|
25
26
|
expect(described_class.get_login.length).to be > 0
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
29
|
-
describe
|
30
|
-
example
|
30
|
+
describe 'get_user' do
|
31
|
+
example 'get_user basic functionality' do
|
31
32
|
expect(described_class).to respond_to(:get_user)
|
32
33
|
expect{ described_class.get_user(user) }.not_to raise_error
|
33
34
|
expect{ described_class.get_user(user_id) }.not_to raise_error
|
34
35
|
end
|
35
36
|
|
36
|
-
example
|
37
|
+
example 'get_user with a string argument works as expected' do
|
37
38
|
expect(described_class.get_user(user)).to be_kind_of(Sys::Admin::User)
|
38
39
|
end
|
39
40
|
|
40
|
-
example
|
41
|
+
example 'get_user with an integer argument works as expected' do
|
41
42
|
expect(described_class.get_user(user_id)).to be_kind_of(Sys::Admin::User)
|
42
43
|
end
|
43
44
|
|
44
|
-
example
|
45
|
+
example 'get_user requires at least one argument' do
|
45
46
|
expect{ described_class.get_user }.to raise_error(ArgumentError)
|
46
|
-
expect{ described_class.get_user(user, user) }.to raise_error(ArgumentError)
|
47
47
|
end
|
48
48
|
|
49
|
-
example
|
49
|
+
example 'get_user requires a string or integer argument' do
|
50
50
|
expect{ described_class.get_user([]) }.to raise_error(TypeError)
|
51
51
|
end
|
52
52
|
|
53
|
-
example
|
53
|
+
example 'get_user raises an Error if the user cannot be found' do
|
54
54
|
expect{ described_class.get_user('foofoofoo') }.to raise_error(Sys::Admin::Error)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
describe
|
59
|
-
example
|
58
|
+
describe 'users' do
|
59
|
+
example 'users basic functionality' do
|
60
60
|
expect(described_class).to respond_to(:users)
|
61
61
|
expect{ described_class.users }.not_to raise_error
|
62
62
|
end
|
63
63
|
|
64
|
-
example
|
64
|
+
example 'users returns an array of User objects' do
|
65
65
|
users = described_class.users
|
66
66
|
expect(users).to be_kind_of(Array)
|
67
67
|
expect(users).to all(be_kind_of(Sys::Admin::User))
|
68
68
|
end
|
69
69
|
|
70
|
-
example
|
71
|
-
|
70
|
+
example 'users accepts an optional lastlog argument on darwin', :darwin => true do
|
71
|
+
users = described_class.users(:lastlog => false)
|
72
|
+
expect(users).to be_kind_of(Array)
|
73
|
+
expect(users).to all(be_kind_of(Sys::Admin::User))
|
74
|
+
expect(users.first.login_time).to be_nil
|
72
75
|
end
|
73
76
|
end
|
74
77
|
|
75
|
-
describe
|
76
|
-
example
|
78
|
+
describe 'get_group' do
|
79
|
+
example 'get_group basic functionality' do
|
77
80
|
expect(described_class).to respond_to(:get_group)
|
78
81
|
expect{ described_class.get_group(group) }.not_to raise_error
|
79
82
|
expect{ described_class.get_group(group_id) }.not_to raise_error
|
80
83
|
end
|
81
84
|
|
82
|
-
example
|
85
|
+
example 'get_group accepts a string argument' do
|
83
86
|
expect(described_class.get_group(group)).to be_kind_of(Sys::Admin::Group)
|
84
87
|
end
|
85
88
|
|
86
|
-
example
|
89
|
+
example 'get_group accepts an integer argument' do
|
87
90
|
expect(described_class.get_group(group_id)).to be_kind_of(Sys::Admin::Group)
|
88
91
|
end
|
89
92
|
|
90
|
-
example
|
93
|
+
example 'get_group requires one argument only' do
|
91
94
|
expect{ described_class.get_group }.to raise_error(ArgumentError)
|
92
95
|
expect{ described_class.get_group(group_id, group_id) }.to raise_error(ArgumentError)
|
93
96
|
end
|
94
97
|
|
95
|
-
example
|
98
|
+
example 'get_group raises a TypeError if an invalid type is passed' do
|
96
99
|
expect{ described_class.get_group([]) }.to raise_error(TypeError)
|
97
100
|
end
|
98
101
|
|
99
|
-
example
|
102
|
+
example 'get_group raises an Error if the group cannot be found' do
|
100
103
|
expect{ described_class.get_group('foofoofoo') }.to raise_error(Sys::Admin::Error)
|
101
104
|
end
|
102
105
|
end
|
103
106
|
|
104
|
-
describe
|
105
|
-
example
|
107
|
+
describe 'groups' do
|
108
|
+
example 'groups basic functionality' do
|
106
109
|
expect(described_class).to respond_to(:groups)
|
107
110
|
expect{ described_class.groups }.not_to raise_error
|
108
111
|
end
|
109
112
|
|
110
|
-
example
|
113
|
+
example 'groups returns an array of Group objects' do
|
111
114
|
groups = described_class.groups
|
112
115
|
expect(groups).to be_kind_of(Array)
|
113
116
|
expect(groups).to all(be_kind_of(Sys::Admin::Group))
|
114
117
|
end
|
115
118
|
|
116
|
-
example
|
119
|
+
example 'groups method does not accept any arguments' do
|
117
120
|
expect{ described_class.groups(group_id) }.to raise_error(ArgumentError)
|
118
121
|
end
|
119
122
|
end
|
120
123
|
end
|
121
124
|
|
122
|
-
context
|
123
|
-
describe
|
124
|
-
example
|
125
|
+
context 'instance methods' do
|
126
|
+
describe 'User instance methods' do
|
127
|
+
example 'user.name behaves as expected' do
|
125
128
|
user = described_class.get_user(user_id)
|
126
129
|
expect(user).to respond_to(:name)
|
127
130
|
expect(user.name).to be_kind_of(String)
|
128
131
|
end
|
129
132
|
|
130
|
-
example
|
133
|
+
example 'user.passwd behaves as expected' do
|
131
134
|
user = described_class.get_user(user_id)
|
132
135
|
expect(user).to respond_to(:passwd)
|
133
136
|
expect(user.passwd).to be_kind_of(String)
|
134
137
|
end
|
135
138
|
|
136
|
-
example
|
139
|
+
example 'user.uid behaves as expected' do
|
137
140
|
user = described_class.get_user(user_id)
|
138
141
|
expect(user).to respond_to(:uid)
|
139
142
|
expect(user.uid).to be_kind_of(Integer)
|
140
143
|
end
|
141
144
|
|
142
|
-
example
|
145
|
+
example 'user.gid behaves as expected' do
|
143
146
|
user = described_class.get_user(user_id)
|
144
147
|
expect(user).to respond_to(:gid)
|
145
148
|
expect(user.gid).to be_kind_of(Integer)
|
146
149
|
end
|
147
150
|
|
148
|
-
example
|
151
|
+
example 'user.dir behaves as expected' do
|
149
152
|
user = described_class.get_user(user_id)
|
150
153
|
expect(user).to respond_to(:dir)
|
151
154
|
expect(user.dir).to be_kind_of(String)
|
152
155
|
end
|
153
156
|
|
154
|
-
example
|
157
|
+
example 'user.shell behaves as expected' do
|
155
158
|
user = described_class.get_user(user_id)
|
156
159
|
expect(user).to respond_to(:shell)
|
157
160
|
expect(user.shell).to be_kind_of(String)
|
158
161
|
end
|
159
162
|
|
160
|
-
example
|
163
|
+
example 'user.gecos behaves as expected' do
|
161
164
|
user = described_class.get_user(user_id)
|
162
165
|
expect(user).to respond_to(:gecos)
|
163
166
|
expect(user.gecos).to be_kind_of(String).or be_nil
|
164
167
|
end
|
165
168
|
|
166
|
-
example
|
169
|
+
example 'user.quota behaves as expected' do
|
167
170
|
user = described_class.get_user(user_id)
|
168
171
|
expect(user).to respond_to(:quota)
|
169
172
|
expect(user.quota).to be_kind_of(Integer).or be_nil
|
170
173
|
end
|
171
174
|
|
172
|
-
example
|
175
|
+
example 'user.age behaves as expected' do
|
173
176
|
user = described_class.get_user(user_id)
|
174
177
|
expect(user).to respond_to(:age)
|
175
178
|
expect(user.age).to be_kind_of(Integer).or be_nil
|
176
179
|
end
|
177
180
|
|
178
|
-
example
|
181
|
+
example 'user.access behaves as expected' do
|
179
182
|
user = described_class.get_user(user_id)
|
180
183
|
expect(user).to respond_to(:access_class)
|
181
184
|
expect(user.access_class).to be_kind_of(String).or be_nil
|
182
185
|
end
|
183
186
|
|
184
|
-
example
|
187
|
+
example 'user.comment behaves as expected' do
|
185
188
|
user = described_class.get_user(user_id)
|
186
189
|
expect(user).to respond_to(:comment)
|
187
190
|
expect(user.comment).to be_kind_of(String).or be_nil
|
188
191
|
end
|
189
192
|
|
190
|
-
example
|
193
|
+
example 'user.expire behaves as expected' do
|
191
194
|
user = described_class.get_user(user_id)
|
192
195
|
expect(user).to respond_to(:expire)
|
193
196
|
expect(user.expire).to be_kind_of(Time).or be_nil
|
194
197
|
end
|
195
198
|
|
196
|
-
example
|
199
|
+
example 'user.change behaves as expected' do
|
197
200
|
user = described_class.get_user(user_id)
|
198
201
|
expect(user).to respond_to(:change)
|
199
202
|
expect(user.change).to be_kind_of(Time).or be_nil
|
200
203
|
end
|
201
204
|
|
202
|
-
example
|
205
|
+
example 'user.login_time behaves as expected' do
|
203
206
|
user = described_class.get_user(user_id)
|
204
207
|
expect(user).to respond_to(:login_time)
|
205
208
|
expect(user.login_time).to be_kind_of(Time).or be_nil
|
206
209
|
end
|
207
210
|
|
208
|
-
example
|
211
|
+
example 'user.login_device behaves as expected' do
|
209
212
|
user = described_class.get_user(user_id)
|
210
213
|
expect(user).to respond_to(:login_device)
|
211
214
|
expect(user.login_device).to be_kind_of(String).or be_nil
|
212
215
|
end
|
213
216
|
|
214
|
-
example
|
217
|
+
example 'user.login_host behaves as expected' do
|
215
218
|
user = described_class.get_user(user_id)
|
216
219
|
expect(user).to respond_to(:login_host)
|
217
220
|
expect(user.login_host).to be_kind_of(String).or be_nil
|
218
221
|
end
|
219
222
|
|
220
|
-
example
|
223
|
+
example 'user.groups behaves as expected' do
|
221
224
|
user = described_class.get_user(user_id)
|
222
225
|
expect(user).to respond_to(:groups)
|
223
226
|
expect(user.groups).to be_kind_of(Array)
|
224
227
|
end
|
225
228
|
end
|
226
229
|
|
227
|
-
describe
|
228
|
-
example
|
230
|
+
describe 'Group instance methods' do
|
231
|
+
example 'group.name behaves as expected' do
|
229
232
|
group = described_class.get_group(group_id)
|
230
233
|
expect(group).to respond_to(:name)
|
231
234
|
expect(group.name).to be_kind_of(String)
|
232
235
|
end
|
233
236
|
|
234
|
-
example
|
237
|
+
example 'group.gid behaves as expected' do
|
235
238
|
group = described_class.get_group(group_id)
|
236
239
|
expect(group).to respond_to(:gid)
|
237
240
|
expect(group.gid).to be_kind_of(Integer)
|
238
241
|
end
|
239
242
|
|
240
|
-
example
|
243
|
+
example 'group.members behaves as expected' do
|
241
244
|
group = described_class.get_group(group_id)
|
242
245
|
expect(group).to respond_to(:members)
|
243
246
|
expect(group.members).to be_kind_of(Array)
|
244
247
|
end
|
245
248
|
|
246
|
-
example
|
249
|
+
example 'group.passwd behaves as expected' do
|
247
250
|
group = described_class.get_group(group_id)
|
248
251
|
expect(group).to respond_to(:passwd)
|
249
252
|
expect(group.passwd).to be_kind_of(String)
|
@@ -251,8 +254,8 @@ RSpec.describe Sys::Admin, :unix do
|
|
251
254
|
end
|
252
255
|
end
|
253
256
|
|
254
|
-
context
|
255
|
-
example
|
257
|
+
context 'ffi functions' do
|
258
|
+
example 'ffi functions are private' do
|
256
259
|
methods = described_class.methods(false).map(&:to_s)
|
257
260
|
expect(methods).not_to include('getlogin')
|
258
261
|
expect(methods).not_to include('getlogin_r')
|