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.
@@ -1,20 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ###############################################################################
2
4
  # sys_admin_windows_spec.rb
3
5
  #
4
6
  # Test suite for the MS Windows version of sys-admin. Note that some of the
5
7
  # are ordered. That way I can add test users before configuring or deleting
6
- # them.
8
+ # them. These tests require admin privileges, otherwise they are skipped.
7
9
  #
8
10
  # It is assumed that these specs will be run via the 'rake spec' task.
9
11
  ###############################################################################
10
- require 'rspec'
11
- require 'sys/admin'
12
- require 'win32/security'
13
- require 'socket'
12
+ require 'spec_helper'
14
13
 
15
14
  RSpec.describe Sys::Admin, :windows do
16
15
  let(:host) { Socket.gethostname }
17
- let(:elevated) { Win32::Security.elevated_security? }
18
16
 
19
17
  before do
20
18
  @user = Sys::Admin::User.new
@@ -25,178 +23,170 @@ RSpec.describe Sys::Admin, :windows do
25
23
  @group_id = 546 # best guess, may fail
26
24
  end
27
25
 
28
- describe "add, configure and delete user", :order => :defined do
26
+ describe 'add, configure and delete user', :order => :defined, :requires_elevated => true do
29
27
  before(:all) do
30
- @local_user = "foo"
28
+ @local_user = 'foo'
31
29
  end
32
30
 
33
- example "add user" do
34
- skip "requires elevated privileges" unless elevated
31
+ example 'add user' do
35
32
  expect(described_class).to respond_to(:add_user)
36
33
  expect{ described_class.add_user(:name => @local_user, :password => 'a1b2c3D4') }.not_to raise_error
37
34
  expect{ described_class.get_user(@local_user) }.not_to raise_error
38
35
  end
39
36
 
40
- example "configure user" do
41
- skip "requires elevated privileges" unless elevated
37
+ example 'configure user' do
42
38
  expect(described_class).to respond_to(:configure_user)
43
- expect{
39
+ expect do
44
40
  described_class.configure_user(
45
41
  :name => @local_user,
46
42
  :description => 'delete me',
47
43
  :fullname => 'fubar',
48
44
  :password => 'd1c2b3A4'
49
45
  )
50
- }.not_to raise_error
46
+ end.not_to raise_error
51
47
  expect(described_class.get_user(@local_user).description).to eq('delete me')
52
48
  end
53
49
 
54
- example "delete user" do
55
- skip "requires elevated privileges" unless elevated
50
+ example 'delete user' do
56
51
  expect(described_class).to respond_to(:delete_user)
57
52
  expect{ described_class.delete_user(@local_user) }.not_to raise_error
58
53
  expect{ described_class.get_user(@local_user) }.to raise_error(Sys::Admin::Error)
59
54
  end
60
55
  end
61
56
 
62
- describe "add, configure and delete group", :order => :defined do
57
+ describe 'add, configure and delete group', :order => :defined, :requires_elevated => true do
63
58
  before(:all) do
64
- @local_user = "foo"
65
- @local_group = "bar"
66
- described_class.add_user(:name => @local_user)
59
+ @local_user = 'foo'
60
+ @local_group = 'bar'
61
+ described_class.add_user(:name => @local_user) if Win32::Security.elevated_security?
67
62
  end
68
63
 
69
64
  after(:all) do
70
- described_class.delete_user(@local_user)
65
+ described_class.delete_user(@local_user) if Win32::Security.elevated_security?
71
66
  end
72
67
 
73
- example "add group" do
74
- skip "requires elevated privileges" unless elevated
68
+ example 'add group' do
75
69
  expect(described_class).to respond_to(:add_group)
76
70
  expect{ described_class.add_group(:name => @local_group) }.not_to raise_error
77
71
  end
78
72
 
79
- example "configure group" do
80
- skip "requires elevated privileges" unless elevated
73
+ example 'configure group' do
81
74
  expect(described_class).to respond_to(:configure_group)
82
75
  expect{ described_class.configure_group(:name => @local_group, :description => 'delete me') }.not_to raise_error
83
76
  end
84
77
 
85
- example "add group member" do
86
- skip "requires elevated privileges" unless elevated
78
+ example 'add group member' do
87
79
  expect(described_class).to respond_to(:add_group_member)
88
80
  expect{ described_class.add_group_member(@local_user, @local_group) }.not_to raise_error
89
81
  expect(described_class.get_group(@local_group, :localaccount => true).members).to include(@local_user)
90
82
  end
91
83
 
92
- example "remove group member" do
93
- skip "requires elevated privileges" unless elevated
84
+ example 'remove group member' do
94
85
  expect(described_class).to respond_to(:remove_group_member)
95
86
  expect{ described_class.remove_group_member(@local_user, @local_group) }.not_to raise_error
96
87
  end
97
88
 
98
- example "delete group" do
99
- skip "requires elevated privileges" unless elevated
89
+ example 'delete group' do
100
90
  expect(described_class).to respond_to(:delete_group)
101
91
  expect{ described_class.delete_group(@local_group) }.not_to raise_error
102
92
  end
103
93
  end
104
94
 
105
- context "singleton methods" do
106
- describe "get_login" do
107
- example "get_login basic functionality" do
95
+ context 'singleton methods' do
96
+ describe 'get_login' do
97
+ example 'get_login basic functionality' do
108
98
  expect(described_class).to respond_to(:get_login)
109
99
  expect{ described_class.get_login }.not_to raise_error
110
100
  end
111
101
 
112
- example "get_login returns a string" do
113
- expect( described_class.get_login).to be_kind_of(String)
102
+ example 'get_login returns a string' do
103
+ expect(described_class.get_login).to be_kind_of(String)
114
104
  expect(described_class.get_login.size).to be > 0
115
105
  end
116
106
 
117
- example "get_login does not accept any arguments" do
107
+ example 'get_login does not accept any arguments' do
118
108
  expect{ described_class.get_login('foo') }.to raise_error(ArgumentError)
119
109
  end
120
110
  end
121
111
 
122
- describe "get_user" do
123
- example "get_user basic functionality" do
112
+ describe 'get_user' do
113
+ example 'get_user basic functionality' do
124
114
  expect(described_class).to respond_to(:get_user)
125
115
  end
126
116
 
127
- example "get_user with string argument works as expected" do
117
+ example 'get_user with string argument works as expected' do
128
118
  expect{ described_class.get_user(@user_name, :localaccount => true) }.not_to raise_error
129
- expect( described_class.get_user(@user_name, :localaccount => true)).to be_kind_of(Sys::Admin::User)
119
+ expect(described_class.get_user(@user_name, :localaccount => true)).to be_kind_of(Sys::Admin::User)
130
120
  end
131
121
 
132
- example "get user with integer argument works as expected" do
122
+ example 'get user with integer argument works as expected' do
133
123
  expect{ described_class.get_user(@user_id, :localaccount => true) }.not_to raise_error
134
- expect( described_class.get_user(@user_id, :localaccount => true)).to be_kind_of(Sys::Admin::User)
124
+ expect(described_class.get_user(@user_id, :localaccount => true)).to be_kind_of(Sys::Admin::User)
135
125
  end
136
126
 
137
- example "get_user method by string accepts a hash of options" do
127
+ example 'get_user method by string accepts a hash of options' do
138
128
  options = {:host => host, :localaccount => true}
139
129
  expect{ described_class.get_user(@user_name, options) }.not_to raise_error
140
- expect( described_class.get_user(@user_name, options)).to be_kind_of(Sys::Admin::User)
130
+ expect(described_class.get_user(@user_name, options)).to be_kind_of(Sys::Admin::User)
141
131
  end
142
132
 
143
- example "get_user method by uid accepts a hash of options" do
133
+ example 'get_user method by uid accepts a hash of options' do
144
134
  options = {:host => host, :localaccount => true}
145
135
  expect{ described_class.get_user(@user_id, options) }.not_to raise_error
146
- expect( described_class.get_user(@user_id, options)).to be_kind_of(Sys::Admin::User)
136
+ expect(described_class.get_user(@user_id, options)).to be_kind_of(Sys::Admin::User)
147
137
  end
148
138
 
149
- example "get_user method requires an argument" do
139
+ example 'get_user method requires an argument' do
150
140
  expect{ described_class.get_user }.to raise_error(ArgumentError)
151
141
  end
152
142
  end
153
143
 
154
- describe "users" do
155
- example "users method basic functionality" do
144
+ describe 'users' do
145
+ example 'users method basic functionality' do
156
146
  expect(described_class).to respond_to(:users)
157
147
  expect{ described_class.users(:localaccount => true) }.not_to raise_error
158
148
  end
159
149
 
160
- example "users method returns an array of User objects" do
150
+ example 'users method returns an array of User objects' do
161
151
  users = described_class.users(:localaccount => true)
162
152
  expect(users).to be_kind_of(Array)
163
153
  expect(users).to all(be_kind_of(Sys::Admin::User))
164
154
  end
165
155
  end
166
156
 
167
- describe "get_group" do
168
- example "get_group basic functionality" do
157
+ describe 'get_group' do
158
+ example 'get_group basic functionality' do
169
159
  expect(described_class).to respond_to(:get_group)
170
160
  end
171
161
 
172
- example "get_group method returns expected results with a string argument" do
162
+ example 'get_group method returns expected results with a string argument' do
173
163
  expect{ described_class.get_group(@group_name, :localaccount => true) }.not_to raise_error
174
164
  expect(described_class.get_group(@group_name, :localaccount => true)).to be_kind_of(Sys::Admin::Group)
175
165
  end
176
166
 
177
- example "get_group method returns expected results with an integer argument" do
167
+ example 'get_group method returns expected results with an integer argument' do
178
168
  expect{ described_class.get_group(@group_id, :localaccount => true) }.not_to raise_error
179
169
  expect(described_class.get_group(@group_id, :localaccount => true)).to be_kind_of(Sys::Admin::Group)
180
170
  end
181
171
 
182
- example "get_group method accepts a hash of options" do
172
+ example 'get_group method accepts a hash of options' do
183
173
  options = {:host => host, :localaccount => true}
184
174
  expect{ described_class.get_group(@group_name, options) }.not_to raise_error
185
175
  expect(described_class.get_group(@group_name, options)).to be_kind_of(Sys::Admin::Group)
186
176
  end
187
177
 
188
- example "get_group method requires an argument" do
178
+ example 'get_group method requires an argument' do
189
179
  expect{ described_class.get_group }.to raise_error(ArgumentError)
190
180
  end
191
181
  end
192
182
 
193
- describe "groups" do
194
- example "groups method basic functionality" do
183
+ describe 'groups' do
184
+ example 'groups method basic functionality' do
195
185
  expect(described_class).to respond_to(:groups)
196
186
  expect{ described_class.groups(:localaccount => true) }.not_to raise_error
197
187
  end
198
188
 
199
- example "groups method returns an array of Group objects" do
189
+ example 'groups method returns an array of Group objects' do
200
190
  groups = described_class.groups(:localaccount => true)
201
191
  expect(groups).to be_kind_of(Array)
202
192
  expect(groups).to all(be_kind_of(Sys::Admin::Group))
@@ -204,145 +194,145 @@ RSpec.describe Sys::Admin, :windows do
204
194
  end
205
195
  end
206
196
 
207
- context "User class" do
208
- example "caption accessor for User class" do
197
+ context 'User class' do
198
+ example 'caption accessor for User class' do
209
199
  expect(@user).to respond_to(:caption)
210
200
  expect(@user).to respond_to(:caption=)
211
201
  end
212
202
 
213
- example "description accessor for User class" do
203
+ example 'description accessor for User class' do
214
204
  expect(@user).to respond_to(:description)
215
205
  expect(@user).to respond_to(:description=)
216
206
  end
217
207
 
218
- example "domain accessor for User class" do
208
+ example 'domain accessor for User class' do
219
209
  expect(@user).to respond_to(:domain)
220
210
  expect(@user).to respond_to(:domain=)
221
211
  end
222
212
 
223
- example "password accessor for User class" do
213
+ example 'password accessor for User class' do
224
214
  expect(@user).to respond_to(:password)
225
215
  expect(@user).to respond_to(:password=)
226
216
  end
227
217
 
228
- example "full_name accessor for User class" do
218
+ example 'full_name accessor for User class' do
229
219
  expect(@user).to respond_to(:full_name)
230
220
  expect(@user).to respond_to(:full_name=)
231
221
  end
232
222
 
233
- example "name accessor for User class" do
223
+ example 'name accessor for User class' do
234
224
  expect(@user).to respond_to(:name)
235
225
  expect(@user).to respond_to(:name=)
236
226
  end
237
227
 
238
- example "sid accessor for User class" do
228
+ example 'sid accessor for User class' do
239
229
  expect(@user).to respond_to(:sid)
240
230
  expect(@user).to respond_to(:sid=)
241
231
  end
242
232
 
243
- example "status accessor for User class" do
233
+ example 'status accessor for User class' do
244
234
  expect(@user).to respond_to(:status)
245
235
  expect(@user).to respond_to(:status=)
246
236
  end
247
237
 
248
- example "disabled accessor for User class" do
238
+ example 'disabled accessor for User class' do
249
239
  expect(@user).to respond_to(:disabled?)
250
240
  expect(@user).to respond_to(:disabled=)
251
241
  end
252
242
 
253
- example "local accessor for User class" do
243
+ example 'local accessor for User class' do
254
244
  expect(@user).to respond_to(:local?)
255
245
  expect(@user).to respond_to(:local=)
256
246
  end
257
247
 
258
- example "lockout accessor for User class" do
248
+ example 'lockout accessor for User class' do
259
249
  expect(@user).to respond_to(:lockout?)
260
250
  expect(@user).to respond_to(:lockout=)
261
251
  end
262
252
 
263
- example "password_changeable accessor for User class" do
253
+ example 'password_changeable accessor for User class' do
264
254
  expect(@user).to respond_to(:password_changeable?)
265
255
  expect(@user).to respond_to(:password_changeable=)
266
256
  end
267
257
 
268
- example "password_expires accessor for User class" do
258
+ example 'password_expires accessor for User class' do
269
259
  expect(@user).to respond_to(:password_expires?)
270
260
  expect(@user).to respond_to(:password_expires=)
271
261
  end
272
262
 
273
- example "password_required accessor for User class" do
263
+ example 'password_required accessor for User class' do
274
264
  expect(@user).to respond_to(:password_required?)
275
265
  expect(@user).to respond_to(:password_required=)
276
266
  end
277
267
 
278
- example "account_type accessor for User class" do
268
+ example 'account_type accessor for User class' do
279
269
  expect(@user).to respond_to(:account_type)
280
270
  expect(@user).to respond_to(:account_type=)
281
271
  end
282
272
 
283
- example "uid accessor for User class" do
273
+ example 'uid accessor for User class' do
284
274
  expect(@user).to respond_to(:uid)
285
275
  expect(@user).to respond_to(:uid=)
286
276
  end
287
277
 
288
- example "dir accessor for User class" do
278
+ example 'dir accessor for User class' do
289
279
  expect(@user).to respond_to(:dir)
290
280
  expect(@user).to respond_to(:dir=)
291
281
  end
292
282
 
293
- example "dir method returns either a string or nil" do
283
+ example 'dir method returns either a string or nil' do
294
284
  expect{ @user = described_class.get_user(@user_name, :localaccount => true) }.not_to raise_error
295
285
  expect(@user.dir).to be_kind_of(String).or be_kind_of(NilClass)
296
286
  end
297
287
  end
298
288
 
299
- context "Group class" do
300
- example "caption accessor for Group class" do
289
+ context 'Group class' do
290
+ example 'caption accessor for Group class' do
301
291
  expect(@group).to respond_to(:caption)
302
292
  expect(@group).to respond_to(:caption=)
303
293
  end
304
294
 
305
- example "description accessor for Group class" do
295
+ example 'description accessor for Group class' do
306
296
  expect(@group).to respond_to(:description)
307
297
  expect(@group).to respond_to(:description=)
308
298
  end
309
299
 
310
- example "domain accessor for Group class" do
300
+ example 'domain accessor for Group class' do
311
301
  expect(@group).to respond_to(:domain)
312
302
  expect(@group).to respond_to(:domain=)
313
303
  end
314
304
 
315
- example "install_date accessor for Group class" do
305
+ example 'install_date accessor for Group class' do
316
306
  expect(@group).to respond_to(:install_date)
317
307
  expect(@group).to respond_to(:install_date=)
318
308
  end
319
309
 
320
- example "name accessor for Group class" do
310
+ example 'name accessor for Group class' do
321
311
  expect(@group).to respond_to(:name)
322
312
  expect(@group).to respond_to(:name)
323
313
  end
324
314
 
325
- example "gid accessor for Group class" do
315
+ example 'gid accessor for Group class' do
326
316
  expect(@group).to respond_to(:gid)
327
317
  expect(@group).to respond_to(:gid=)
328
318
  end
329
319
 
330
- example "status accessor for Group class" do
320
+ example 'status accessor for Group class' do
331
321
  expect(@group).to respond_to(:status)
332
322
  expect(@group).to respond_to(:status=)
333
323
  end
334
324
 
335
- example "sid accessor for Group class" do
325
+ example 'sid accessor for Group class' do
336
326
  expect(@group).to respond_to(:sid)
337
327
  expect(@group).to respond_to(:sid=)
338
328
  end
339
329
 
340
- example "sid_type accessor for Group class" do
330
+ example 'sid_type accessor for Group class' do
341
331
  expect(@group).to respond_to(:sid_type)
342
332
  expect(@group).to respond_to(:sid_type=)
343
333
  end
344
334
 
345
- example "local accessor for Group class" do
335
+ example 'local accessor for Group class' do
346
336
  expect(@group).to respond_to(:local?)
347
337
  expect(@group).to respond_to(:local=)
348
338
  end
data/sys-admin.gemspec CHANGED
@@ -3,7 +3,7 @@ require 'rubygems'
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = 'sys-admin'
6
- spec.version = '1.8.0'
6
+ spec.version = '1.8.2'
7
7
  spec.author = 'Daniel J. Berger'
8
8
  spec.license = 'Apache-2.0'
9
9
  spec.email = 'djberg96@gmail.com'
@@ -24,14 +24,18 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.add_development_dependency('rspec', '~> 3.9')
26
26
  spec.add_development_dependency('rake')
27
+ spec.add_development_dependency('rubocop')
28
+ spec.add_development_dependency('rubocop-rspec')
27
29
 
28
30
  spec.metadata = {
29
- 'homepage_uri' => 'https://github.com/djberg96/sys-admin',
30
- 'bug_tracker_uri' => 'https://github.com/djberg96/sys-admin/issues',
31
- 'changelog_uri' => 'https://github.com/djberg96/sys-admin/blob/main/CHANGES.md',
32
- 'documentation_uri' => 'https://github.com/djberg96/sys-admin/wiki',
33
- 'source_code_uri' => 'https://github.com/djberg96/sys-admin',
34
- 'wiki_uri' => 'https://github.com/djberg96/sys-admin/wiki'
31
+ 'homepage_uri' => 'https://github.com/djberg96/sys-admin',
32
+ 'bug_tracker_uri' => 'https://github.com/djberg96/sys-admin/issues',
33
+ 'changelog_uri' => 'https://github.com/djberg96/sys-admin/blob/main/CHANGES.md',
34
+ 'documentation_uri' => 'https://github.com/djberg96/sys-admin/wiki',
35
+ 'source_code_uri' => 'https://github.com/djberg96/sys-admin',
36
+ 'wiki_uri' => 'https://github.com/djberg96/sys-admin/wiki',
37
+ 'rubygems_mfa_required' => 'true',
38
+ 'github_repo' => 'https://github.com/djberg96/sys-admin'
35
39
  }
36
40
 
37
41
  spec.description = <<-EOF
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.8.0
4
+ version: 1.8.2
5
5
  platform: universal-mingw32
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-08-26 00:00:00.000000000 Z
38
+ date: 2023-04-09 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: ffi
@@ -93,6 +93,34 @@ dependencies:
93
93
  - - ">="
94
94
  - !ruby/object:Gem::Version
95
95
  version: '0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: rubocop
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rubocop-rspec
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ type: :development
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
96
124
  description: |2
97
125
  The sys-admin library is a unified, cross platform replacement for the
98
126
  'etc' library that ships as part of the Ruby standard library. It
@@ -125,6 +153,8 @@ files:
125
153
  - lib/sys/admin/custom.rb
126
154
  - lib/unix/sys/admin.rb
127
155
  - lib/windows/sys/admin.rb
156
+ - spec/spec_helper.rb
157
+ - spec/sys_admin_shared.rb
128
158
  - spec/sys_admin_unix_spec.rb
129
159
  - spec/sys_admin_windows_spec.rb
130
160
  - sys-admin.gemspec
@@ -138,6 +168,8 @@ metadata:
138
168
  documentation_uri: https://github.com/djberg96/sys-admin/wiki
139
169
  source_code_uri: https://github.com/djberg96/sys-admin
140
170
  wiki_uri: https://github.com/djberg96/sys-admin/wiki
171
+ rubygems_mfa_required: 'true'
172
+ github_repo: https://github.com/djberg96/sys-admin
141
173
  post_install_message:
142
174
  rdoc_options: []
143
175
  require_paths:
@@ -158,5 +190,7 @@ signing_key:
158
190
  specification_version: 4
159
191
  summary: A unified, cross platform replacement for the "etc" library.
160
192
  test_files:
193
+ - spec/spec_helper.rb
194
+ - spec/sys_admin_shared.rb
161
195
  - spec/sys_admin_unix_spec.rb
162
196
  - spec/sys_admin_windows_spec.rb
metadata.gz.sig CHANGED
Binary file