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