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