sys-admin 1.8.4 → 1.9.0
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 +6 -0
- data/README.md +1 -1
- data/Rakefile +8 -0
- data/lib/bsd/sys/admin.rb +2 -5
- data/lib/darwin/sys/admin.rb +2 -5
- data/lib/linux/sys/admin.rb +2 -5
- data/lib/sys/admin.rb +1 -1
- data/lib/unix/sys/admin.rb +2 -0
- data/lib/windows/sys/admin.rb +20 -20
- data/spec/spec_helper.rb +1 -1
- data/spec/sys_admin_shared.rb +1 -1
- data/spec/sys_admin_unix_spec.rb +38 -38
- data/spec/sys_admin_windows_spec.rb +15 -15
- data/sys-admin.gemspec +5 -2
- data.tar.gz.sig +0 -0
- metadata +4 -6
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a5a1572e680bf42573b497003604bce996636b6f019d16a720d8c89e7ead91a2
|
|
4
|
+
data.tar.gz: 890f0f692bdaa05bc89fe32fa372a47ab24d193016b890103ed0b2a9c13fe97e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 036bdc584cd54cdf81e38f54ac1efbf3ed406fa6e3f4ce21da8a4b51481e6cc51cbeeb370051a8bf029a0373ef2d9508096e0fcd80d5ae1a0374e0d9f3879dba
|
|
7
|
+
data.tar.gz: ebcad9bb1c06ad8210aea0abf4c6a0cd318d6db148242656b4b15591e6283105f1b6633b0480f21a783dcd2698b4ce9104234ebc70b123d0137ffa0a37a843bc
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/CHANGES.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## 1.9.0 - 17-Feb-2026
|
|
2
|
+
* The win32ole and win32-registry gems are now dependencies for Windows since
|
|
3
|
+
Ruby 4.x does not bundle those automatically.
|
|
4
|
+
* Any << string operators were replaced with += to eliminate frozen string
|
|
5
|
+
warnings.
|
|
6
|
+
|
|
1
7
|
## 1.8.4 - 12-Jun-2024
|
|
2
8
|
* Fixes for DragonFly BSD support.
|
|
3
9
|
|
data/README.md
CHANGED
data/Rakefile
CHANGED
|
@@ -38,8 +38,16 @@ RSpec::Core::RakeTask.new(:spec) do |t|
|
|
|
38
38
|
else
|
|
39
39
|
t.rspec_opts = '-Ilib/unix'
|
|
40
40
|
end
|
|
41
|
+
|
|
42
|
+
t.verbose = true
|
|
43
|
+
t.rspec_opts << ' -f documentation -w'
|
|
41
44
|
end
|
|
42
45
|
|
|
43
46
|
RuboCop::RakeTask.new
|
|
44
47
|
|
|
48
|
+
# Clean up afterwards
|
|
49
|
+
Rake::Task[:spec].enhance do
|
|
50
|
+
Rake::Task[:clean].invoke
|
|
51
|
+
end
|
|
52
|
+
|
|
45
53
|
task :default => :spec
|
data/lib/bsd/sys/admin.rb
CHANGED
|
@@ -144,11 +144,8 @@ module Sys
|
|
|
144
144
|
end
|
|
145
145
|
|
|
146
146
|
if pbuf.null?
|
|
147
|
-
if val != 0
|
|
148
|
-
|
|
149
|
-
else
|
|
150
|
-
raise Error, "group '#{gid}' not found"
|
|
151
|
-
end
|
|
147
|
+
raise SystemCallError.new(fun, val) if val != 0
|
|
148
|
+
raise Error, "group '#{gid}' not found"
|
|
152
149
|
end
|
|
153
150
|
rescue Errno::ERANGE
|
|
154
151
|
size += 1024
|
data/lib/darwin/sys/admin.rb
CHANGED
|
@@ -138,11 +138,8 @@ module Sys
|
|
|
138
138
|
end
|
|
139
139
|
|
|
140
140
|
if pbuf.null?
|
|
141
|
-
if val != 0
|
|
142
|
-
|
|
143
|
-
else
|
|
144
|
-
raise Error, "group '#{gid}' not found"
|
|
145
|
-
end
|
|
141
|
+
raise SystemCallError.new(fun, val) if val != 0
|
|
142
|
+
raise Error, "group '#{gid}' not found"
|
|
146
143
|
end
|
|
147
144
|
rescue Errno::ERANGE
|
|
148
145
|
size += 1024
|
data/lib/linux/sys/admin.rb
CHANGED
|
@@ -133,11 +133,8 @@ module Sys
|
|
|
133
133
|
end
|
|
134
134
|
|
|
135
135
|
if pbuf.null?
|
|
136
|
-
if val != 0
|
|
137
|
-
|
|
138
|
-
else
|
|
139
|
-
raise Error, "group '#{gid}' not found"
|
|
140
|
-
end
|
|
136
|
+
raise SystemCallError.new(fun, val) if val != 0
|
|
137
|
+
raise Error, "group '#{gid}' not found"
|
|
141
138
|
end
|
|
142
139
|
rescue Errno::ERANGE # Large groups
|
|
143
140
|
size += 1024
|
data/lib/sys/admin.rb
CHANGED
data/lib/unix/sys/admin.rb
CHANGED
|
@@ -9,6 +9,7 @@ require 'sys/admin/common'
|
|
|
9
9
|
module Sys
|
|
10
10
|
# The Admin class provides a unified, cross platform replacement for the Etc module.
|
|
11
11
|
class Admin
|
|
12
|
+
# Private wrapper class for a struct passwd.
|
|
12
13
|
class PasswdStruct < FFI::Struct
|
|
13
14
|
layout(
|
|
14
15
|
:pw_name, :string,
|
|
@@ -23,6 +24,7 @@ module Sys
|
|
|
23
24
|
|
|
24
25
|
private_constant :PasswdStruct
|
|
25
26
|
|
|
27
|
+
# Private wrapper class for a struct group.
|
|
26
28
|
class GroupStruct < FFI::Struct
|
|
27
29
|
layout(
|
|
28
30
|
:gr_name, :string,
|
data/lib/windows/sys/admin.rb
CHANGED
|
@@ -402,7 +402,7 @@ module Sys
|
|
|
402
402
|
|
|
403
403
|
host = options.delete(:host) || Socket.gethostname
|
|
404
404
|
cs = 'winmgmts:{impersonationLevel=impersonate}!'
|
|
405
|
-
cs
|
|
405
|
+
cs += "//#{host}/root/cimv2"
|
|
406
406
|
|
|
407
407
|
begin
|
|
408
408
|
wmi = WIN32OLE.connect(cs)
|
|
@@ -416,24 +416,24 @@ module Sys
|
|
|
416
416
|
|
|
417
417
|
options.each do |opt, val|
|
|
418
418
|
if i == 0
|
|
419
|
-
query
|
|
419
|
+
query += " where #{opt} = '#{val}'"
|
|
420
420
|
i += 1
|
|
421
421
|
else
|
|
422
|
-
query
|
|
422
|
+
query += " and #{opt} = '#{val}'"
|
|
423
423
|
end
|
|
424
424
|
end
|
|
425
425
|
|
|
426
426
|
if usr.is_a?(Numeric)
|
|
427
427
|
if i == 0
|
|
428
|
-
query
|
|
428
|
+
query += " where sid like '%-#{usr}'"
|
|
429
429
|
else
|
|
430
|
-
query
|
|
430
|
+
query += " and sid like '%-#{usr}'"
|
|
431
431
|
end
|
|
432
432
|
else
|
|
433
433
|
if i == 0
|
|
434
|
-
query
|
|
434
|
+
query += " where name = '#{usr}'"
|
|
435
435
|
else
|
|
436
|
-
query
|
|
436
|
+
query += " and name = '#{usr}'"
|
|
437
437
|
end
|
|
438
438
|
end
|
|
439
439
|
|
|
@@ -503,7 +503,7 @@ module Sys
|
|
|
503
503
|
|
|
504
504
|
host = options.delete(:host) || Socket.gethostname
|
|
505
505
|
cs = 'winmgmts:{impersonationLevel=impersonate}!'
|
|
506
|
-
cs
|
|
506
|
+
cs += "//#{host}/root/cimv2"
|
|
507
507
|
|
|
508
508
|
begin
|
|
509
509
|
wmi = WIN32OLE.connect(cs)
|
|
@@ -517,10 +517,10 @@ module Sys
|
|
|
517
517
|
|
|
518
518
|
options.each do |opt, val|
|
|
519
519
|
if i == 0
|
|
520
|
-
query
|
|
520
|
+
query += " where #{opt} = '#{val}'"
|
|
521
521
|
i += 1
|
|
522
522
|
else
|
|
523
|
-
query
|
|
523
|
+
query += " and #{opt} = '#{val}'"
|
|
524
524
|
end
|
|
525
525
|
end
|
|
526
526
|
|
|
@@ -590,7 +590,7 @@ module Sys
|
|
|
590
590
|
|
|
591
591
|
host = options.delete(:host) || Socket.gethostname
|
|
592
592
|
cs = 'winmgmts:{impersonationLevel=impersonate}!'
|
|
593
|
-
cs
|
|
593
|
+
cs += "//#{host}/root/cimv2"
|
|
594
594
|
|
|
595
595
|
begin
|
|
596
596
|
wmi = WIN32OLE.connect(cs)
|
|
@@ -604,24 +604,24 @@ module Sys
|
|
|
604
604
|
|
|
605
605
|
options.each do |opt, val|
|
|
606
606
|
if i == 0
|
|
607
|
-
query
|
|
607
|
+
query += " where #{opt} = '#{val}'"
|
|
608
608
|
i += 1
|
|
609
609
|
else
|
|
610
|
-
query
|
|
610
|
+
query += " and #{opt} = '#{val}'"
|
|
611
611
|
end
|
|
612
612
|
end
|
|
613
613
|
|
|
614
614
|
if grp.is_a?(Integer)
|
|
615
615
|
if i == 0
|
|
616
|
-
query
|
|
616
|
+
query += " where sid like '%-#{grp}'"
|
|
617
617
|
else
|
|
618
|
-
query
|
|
618
|
+
query += " and sid like '%-#{grp}'"
|
|
619
619
|
end
|
|
620
620
|
else
|
|
621
621
|
if i == 0
|
|
622
|
-
query
|
|
622
|
+
query += " where name = '#{grp}'"
|
|
623
623
|
else
|
|
624
|
-
query
|
|
624
|
+
query += " and name = '#{grp}'"
|
|
625
625
|
end
|
|
626
626
|
end
|
|
627
627
|
|
|
@@ -679,7 +679,7 @@ module Sys
|
|
|
679
679
|
|
|
680
680
|
host = options.delete(:host) || Socket.gethostname
|
|
681
681
|
cs = 'winmgmts:{impersonationLevel=impersonate}!'
|
|
682
|
-
cs
|
|
682
|
+
cs += "//#{host}/root/cimv2"
|
|
683
683
|
|
|
684
684
|
begin
|
|
685
685
|
wmi = WIN32OLE.connect(cs)
|
|
@@ -693,10 +693,10 @@ module Sys
|
|
|
693
693
|
|
|
694
694
|
options.each do |opt, val|
|
|
695
695
|
if i == 0
|
|
696
|
-
query
|
|
696
|
+
query += " where #{opt} = '#{val}'"
|
|
697
697
|
i += 1
|
|
698
698
|
else
|
|
699
|
-
query
|
|
699
|
+
query += " and #{opt} = '#{val}'"
|
|
700
700
|
end
|
|
701
701
|
end
|
|
702
702
|
|
data/spec/spec_helper.rb
CHANGED
|
@@ -15,7 +15,7 @@ RSpec.configure do |config|
|
|
|
15
15
|
|
|
16
16
|
config.filter_run_excluding(:unix)
|
|
17
17
|
|
|
18
|
-
config.before(:each, :requires_elevated
|
|
18
|
+
config.before(:each, :requires_elevated) do
|
|
19
19
|
skip 'skipped unless administrator privileges' unless Win32::Security.elevated_security?
|
|
20
20
|
end
|
|
21
21
|
end
|
data/spec/sys_admin_shared.rb
CHANGED
data/spec/sys_admin_unix_spec.rb
CHANGED
|
@@ -22,7 +22,7 @@ RSpec.describe Sys::Admin, :unix do
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
example 'get_login returns a string' do
|
|
25
|
-
expect(described_class.get_login).to
|
|
25
|
+
expect(described_class.get_login).to be_a(String)
|
|
26
26
|
expect(described_class.get_login.length).to be > 0
|
|
27
27
|
end
|
|
28
28
|
end
|
|
@@ -35,11 +35,11 @@ RSpec.describe Sys::Admin, :unix do
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
example 'get_user with a string argument works as expected' do
|
|
38
|
-
expect(described_class.get_user(user)).to
|
|
38
|
+
expect(described_class.get_user(user)).to be_a(Sys::Admin::User)
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
example 'get_user with an integer argument works as expected' do
|
|
42
|
-
expect(described_class.get_user(user_id)).to
|
|
42
|
+
expect(described_class.get_user(user_id)).to be_a(Sys::Admin::User)
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
example 'get_user requires at least one argument' do
|
|
@@ -63,14 +63,14 @@ RSpec.describe Sys::Admin, :unix do
|
|
|
63
63
|
|
|
64
64
|
example 'users returns an array of User objects' do
|
|
65
65
|
users = described_class.users
|
|
66
|
-
expect(users).to
|
|
67
|
-
expect(users).to all(
|
|
66
|
+
expect(users).to be_a(Array)
|
|
67
|
+
expect(users).to all(be_a(Sys::Admin::User))
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
-
example 'users accepts an optional lastlog argument on darwin', :darwin
|
|
70
|
+
example 'users accepts an optional lastlog argument on darwin', :darwin do
|
|
71
71
|
users = described_class.users(:lastlog => false)
|
|
72
|
-
expect(users).to
|
|
73
|
-
expect(users).to all(
|
|
72
|
+
expect(users).to be_a(Array)
|
|
73
|
+
expect(users).to all(be_a(Sys::Admin::User))
|
|
74
74
|
expect(users.first.login_time).to be_nil
|
|
75
75
|
end
|
|
76
76
|
end
|
|
@@ -89,11 +89,11 @@ RSpec.describe Sys::Admin, :unix do
|
|
|
89
89
|
end
|
|
90
90
|
|
|
91
91
|
example 'get_group accepts a string argument' do
|
|
92
|
-
expect(described_class.get_group(group)).to
|
|
92
|
+
expect(described_class.get_group(group)).to be_a(Sys::Admin::Group)
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
example 'get_group accepts an integer argument' do
|
|
96
|
-
expect(described_class.get_group(group_id)).to
|
|
96
|
+
expect(described_class.get_group(group_id)).to be_a(Sys::Admin::Group)
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
example 'get_group requires one argument only' do
|
|
@@ -111,24 +111,24 @@ RSpec.describe Sys::Admin, :unix do
|
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
example 'get_group handles large groups and will retry an ERANGE' do
|
|
114
|
-
allow(
|
|
115
|
-
allow(
|
|
114
|
+
allow(described_class).to receive(:getgrgid_r).with(any_args).and_return(34)
|
|
115
|
+
allow(described_class).to receive(:getgrgid_r).with(any_args).and_call_original
|
|
116
116
|
expect{ described_class.get_group(group_id) }.not_to raise_error
|
|
117
117
|
end
|
|
118
118
|
|
|
119
119
|
example 'get_group will raise the expected error for an ENOENT' do
|
|
120
|
-
allow(
|
|
120
|
+
allow(described_class).to receive(:getgrgid_r).with(any_args).and_return(2)
|
|
121
121
|
expect{ described_class.get_group(group_id) }.to raise_error(Sys::Admin::Error)
|
|
122
122
|
end
|
|
123
123
|
|
|
124
124
|
example 'get_group will raise the expected error for a failed getgrxxx function call' do
|
|
125
|
-
allow(
|
|
125
|
+
allow(described_class).to receive(:getgrgid_r).with(any_args).and_return(22)
|
|
126
126
|
allow_any_instance_of(FFI::MemoryPointer).to receive(:null?).and_return(true)
|
|
127
127
|
expect{ described_class.get_group(group_id) }.to raise_error(Errno::EINVAL)
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
example 'get_group will not retry failures other than an ERANGE' do
|
|
131
|
-
allow(
|
|
131
|
+
allow(described_class).to receive(:getgrgid_r).with(any_args).and_return(35)
|
|
132
132
|
expect{ described_class.get_group(group_id) }.to raise_error(Sys::Admin::Error)
|
|
133
133
|
end
|
|
134
134
|
end
|
|
@@ -141,8 +141,8 @@ RSpec.describe Sys::Admin, :unix do
|
|
|
141
141
|
|
|
142
142
|
example 'groups returns an array of Group objects' do
|
|
143
143
|
groups = described_class.groups
|
|
144
|
-
expect(groups).to
|
|
145
|
-
expect(groups).to all(
|
|
144
|
+
expect(groups).to be_a(Array)
|
|
145
|
+
expect(groups).to all(be_a(Sys::Admin::Group))
|
|
146
146
|
end
|
|
147
147
|
|
|
148
148
|
example 'groups method does not accept any arguments' do
|
|
@@ -156,103 +156,103 @@ RSpec.describe Sys::Admin, :unix do
|
|
|
156
156
|
example 'user.name behaves as expected' do
|
|
157
157
|
user = described_class.get_user(user_id)
|
|
158
158
|
expect(user).to respond_to(:name)
|
|
159
|
-
expect(user.name).to
|
|
159
|
+
expect(user.name).to be_a(String)
|
|
160
160
|
end
|
|
161
161
|
|
|
162
162
|
example 'user.passwd behaves as expected' do
|
|
163
163
|
user = described_class.get_user(user_id)
|
|
164
164
|
expect(user).to respond_to(:passwd)
|
|
165
|
-
expect(user.passwd).to
|
|
165
|
+
expect(user.passwd).to be_a(String)
|
|
166
166
|
end
|
|
167
167
|
|
|
168
168
|
example 'user.uid behaves as expected' do
|
|
169
169
|
user = described_class.get_user(user_id)
|
|
170
170
|
expect(user).to respond_to(:uid)
|
|
171
|
-
expect(user.uid).to
|
|
171
|
+
expect(user.uid).to be_a(Integer)
|
|
172
172
|
end
|
|
173
173
|
|
|
174
174
|
example 'user.gid behaves as expected' do
|
|
175
175
|
user = described_class.get_user(user_id)
|
|
176
176
|
expect(user).to respond_to(:gid)
|
|
177
|
-
expect(user.gid).to
|
|
177
|
+
expect(user.gid).to be_a(Integer)
|
|
178
178
|
end
|
|
179
179
|
|
|
180
180
|
example 'user.dir behaves as expected' do
|
|
181
181
|
user = described_class.get_user(user_id)
|
|
182
182
|
expect(user).to respond_to(:dir)
|
|
183
|
-
expect(user.dir).to
|
|
183
|
+
expect(user.dir).to be_a(String)
|
|
184
184
|
end
|
|
185
185
|
|
|
186
186
|
example 'user.shell behaves as expected' do
|
|
187
187
|
user = described_class.get_user(user_id)
|
|
188
188
|
expect(user).to respond_to(:shell)
|
|
189
|
-
expect(user.shell).to
|
|
189
|
+
expect(user.shell).to be_a(String)
|
|
190
190
|
end
|
|
191
191
|
|
|
192
192
|
example 'user.gecos behaves as expected' do
|
|
193
193
|
user = described_class.get_user(user_id)
|
|
194
194
|
expect(user).to respond_to(:gecos)
|
|
195
|
-
expect(user.gecos).to
|
|
195
|
+
expect(user.gecos).to be_a(String).or be_nil
|
|
196
196
|
end
|
|
197
197
|
|
|
198
198
|
example 'user.quota behaves as expected' do
|
|
199
199
|
user = described_class.get_user(user_id)
|
|
200
200
|
expect(user).to respond_to(:quota)
|
|
201
|
-
expect(user.quota).to
|
|
201
|
+
expect(user.quota).to be_a(Integer).or be_nil
|
|
202
202
|
end
|
|
203
203
|
|
|
204
204
|
example 'user.age behaves as expected' do
|
|
205
205
|
user = described_class.get_user(user_id)
|
|
206
206
|
expect(user).to respond_to(:age)
|
|
207
|
-
expect(user.age).to
|
|
207
|
+
expect(user.age).to be_a(Integer).or be_nil
|
|
208
208
|
end
|
|
209
209
|
|
|
210
210
|
example 'user.access behaves as expected' do
|
|
211
211
|
user = described_class.get_user(user_id)
|
|
212
212
|
expect(user).to respond_to(:access_class)
|
|
213
|
-
expect(user.access_class).to
|
|
213
|
+
expect(user.access_class).to be_a(String).or be_nil
|
|
214
214
|
end
|
|
215
215
|
|
|
216
216
|
example 'user.comment behaves as expected' do
|
|
217
217
|
user = described_class.get_user(user_id)
|
|
218
218
|
expect(user).to respond_to(:comment)
|
|
219
|
-
expect(user.comment).to
|
|
219
|
+
expect(user.comment).to be_a(String).or be_nil
|
|
220
220
|
end
|
|
221
221
|
|
|
222
222
|
example 'user.expire behaves as expected' do
|
|
223
223
|
user = described_class.get_user(user_id)
|
|
224
224
|
expect(user).to respond_to(:expire)
|
|
225
|
-
expect(user.expire).to
|
|
225
|
+
expect(user.expire).to be_a(Time).or be_nil
|
|
226
226
|
end
|
|
227
227
|
|
|
228
228
|
example 'user.change behaves as expected' do
|
|
229
229
|
user = described_class.get_user(user_id)
|
|
230
230
|
expect(user).to respond_to(:change)
|
|
231
|
-
expect(user.change).to
|
|
231
|
+
expect(user.change).to be_a(Time).or be_nil
|
|
232
232
|
end
|
|
233
233
|
|
|
234
234
|
example 'user.login_time behaves as expected' do
|
|
235
235
|
user = described_class.get_user(user_id)
|
|
236
236
|
expect(user).to respond_to(:login_time)
|
|
237
|
-
expect(user.login_time).to
|
|
237
|
+
expect(user.login_time).to be_a(Time).or be_nil
|
|
238
238
|
end
|
|
239
239
|
|
|
240
240
|
example 'user.login_device behaves as expected' do
|
|
241
241
|
user = described_class.get_user(user_id)
|
|
242
242
|
expect(user).to respond_to(:login_device)
|
|
243
|
-
expect(user.login_device).to
|
|
243
|
+
expect(user.login_device).to be_a(String).or be_nil
|
|
244
244
|
end
|
|
245
245
|
|
|
246
246
|
example 'user.login_host behaves as expected' do
|
|
247
247
|
user = described_class.get_user(user_id)
|
|
248
248
|
expect(user).to respond_to(:login_host)
|
|
249
|
-
expect(user.login_host).to
|
|
249
|
+
expect(user.login_host).to be_a(String).or be_nil
|
|
250
250
|
end
|
|
251
251
|
|
|
252
252
|
example 'user.groups behaves as expected' do
|
|
253
253
|
user = described_class.get_user(user_id)
|
|
254
254
|
expect(user).to respond_to(:groups)
|
|
255
|
-
expect(user.groups).to
|
|
255
|
+
expect(user.groups).to be_a(Array)
|
|
256
256
|
end
|
|
257
257
|
end
|
|
258
258
|
|
|
@@ -260,25 +260,25 @@ RSpec.describe Sys::Admin, :unix do
|
|
|
260
260
|
example 'group.name behaves as expected' do
|
|
261
261
|
group = described_class.get_group(group_id)
|
|
262
262
|
expect(group).to respond_to(:name)
|
|
263
|
-
expect(group.name).to
|
|
263
|
+
expect(group.name).to be_a(String)
|
|
264
264
|
end
|
|
265
265
|
|
|
266
266
|
example 'group.gid behaves as expected' do
|
|
267
267
|
group = described_class.get_group(group_id)
|
|
268
268
|
expect(group).to respond_to(:gid)
|
|
269
|
-
expect(group.gid).to
|
|
269
|
+
expect(group.gid).to be_a(Integer)
|
|
270
270
|
end
|
|
271
271
|
|
|
272
272
|
example 'group.members behaves as expected' do
|
|
273
273
|
group = described_class.get_group(group_id)
|
|
274
274
|
expect(group).to respond_to(:members)
|
|
275
|
-
expect(group.members).to
|
|
275
|
+
expect(group.members).to be_a(Array)
|
|
276
276
|
end
|
|
277
277
|
|
|
278
278
|
example 'group.passwd behaves as expected' do
|
|
279
279
|
group = described_class.get_group(group_id)
|
|
280
280
|
expect(group).to respond_to(:passwd)
|
|
281
|
-
expect(group.passwd).to
|
|
281
|
+
expect(group.passwd).to be_a(String)
|
|
282
282
|
end
|
|
283
283
|
end
|
|
284
284
|
end
|
|
@@ -23,7 +23,7 @@ RSpec.describe Sys::Admin, :windows do
|
|
|
23
23
|
@group_id = 546 # best guess, may fail
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
describe 'add, configure and delete user', :order => :defined
|
|
26
|
+
describe 'add, configure and delete user', :requires_elevated, :order => :defined do
|
|
27
27
|
before(:all) do
|
|
28
28
|
@local_user = 'foo'
|
|
29
29
|
end
|
|
@@ -54,7 +54,7 @@ RSpec.describe Sys::Admin, :windows do
|
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
-
describe 'add, configure and delete group', :order => :defined
|
|
57
|
+
describe 'add, configure and delete group', :requires_elevated, :order => :defined do
|
|
58
58
|
before(:all) do
|
|
59
59
|
@local_user = 'foo'
|
|
60
60
|
@local_group = 'bar'
|
|
@@ -100,7 +100,7 @@ RSpec.describe Sys::Admin, :windows do
|
|
|
100
100
|
end
|
|
101
101
|
|
|
102
102
|
example 'get_login returns a string' do
|
|
103
|
-
expect(described_class.get_login).to
|
|
103
|
+
expect(described_class.get_login).to be_a(String)
|
|
104
104
|
expect(described_class.get_login.size).to be > 0
|
|
105
105
|
end
|
|
106
106
|
|
|
@@ -116,24 +116,24 @@ RSpec.describe Sys::Admin, :windows do
|
|
|
116
116
|
|
|
117
117
|
example 'get_user with string argument works as expected' do
|
|
118
118
|
expect{ described_class.get_user(@user_name, :localaccount => true) }.not_to raise_error
|
|
119
|
-
expect(described_class.get_user(@user_name, :localaccount => true)).to
|
|
119
|
+
expect(described_class.get_user(@user_name, :localaccount => true)).to be_a(Sys::Admin::User)
|
|
120
120
|
end
|
|
121
121
|
|
|
122
122
|
example 'get user with integer argument works as expected' do
|
|
123
123
|
expect{ described_class.get_user(@user_id, :localaccount => true) }.not_to raise_error
|
|
124
|
-
expect(described_class.get_user(@user_id, :localaccount => true)).to
|
|
124
|
+
expect(described_class.get_user(@user_id, :localaccount => true)).to be_a(Sys::Admin::User)
|
|
125
125
|
end
|
|
126
126
|
|
|
127
127
|
example 'get_user method by string accepts a hash of options' do
|
|
128
128
|
options = {:host => host, :localaccount => true}
|
|
129
129
|
expect{ described_class.get_user(@user_name, options) }.not_to raise_error
|
|
130
|
-
expect(described_class.get_user(@user_name, options)).to
|
|
130
|
+
expect(described_class.get_user(@user_name, options)).to be_a(Sys::Admin::User)
|
|
131
131
|
end
|
|
132
132
|
|
|
133
133
|
example 'get_user method by uid accepts a hash of options' do
|
|
134
134
|
options = {:host => host, :localaccount => true}
|
|
135
135
|
expect{ described_class.get_user(@user_id, options) }.not_to raise_error
|
|
136
|
-
expect(described_class.get_user(@user_id, options)).to
|
|
136
|
+
expect(described_class.get_user(@user_id, options)).to be_a(Sys::Admin::User)
|
|
137
137
|
end
|
|
138
138
|
|
|
139
139
|
example 'get_user method requires an argument' do
|
|
@@ -149,8 +149,8 @@ RSpec.describe Sys::Admin, :windows do
|
|
|
149
149
|
|
|
150
150
|
example 'users method returns an array of User objects' do
|
|
151
151
|
users = described_class.users(:localaccount => true)
|
|
152
|
-
expect(users).to
|
|
153
|
-
expect(users).to all(
|
|
152
|
+
expect(users).to be_a(Array)
|
|
153
|
+
expect(users).to all(be_a(Sys::Admin::User))
|
|
154
154
|
end
|
|
155
155
|
end
|
|
156
156
|
|
|
@@ -161,18 +161,18 @@ RSpec.describe Sys::Admin, :windows do
|
|
|
161
161
|
|
|
162
162
|
example 'get_group method returns expected results with a string argument' do
|
|
163
163
|
expect{ described_class.get_group(@group_name, :localaccount => true) }.not_to raise_error
|
|
164
|
-
expect(described_class.get_group(@group_name, :localaccount => true)).to
|
|
164
|
+
expect(described_class.get_group(@group_name, :localaccount => true)).to be_a(Sys::Admin::Group)
|
|
165
165
|
end
|
|
166
166
|
|
|
167
167
|
example 'get_group method returns expected results with an integer argument' do
|
|
168
168
|
expect{ described_class.get_group(@group_id, :localaccount => true) }.not_to raise_error
|
|
169
|
-
expect(described_class.get_group(@group_id, :localaccount => true)).to
|
|
169
|
+
expect(described_class.get_group(@group_id, :localaccount => true)).to be_a(Sys::Admin::Group)
|
|
170
170
|
end
|
|
171
171
|
|
|
172
172
|
example 'get_group method accepts a hash of options' do
|
|
173
173
|
options = {:host => host, :localaccount => true}
|
|
174
174
|
expect{ described_class.get_group(@group_name, options) }.not_to raise_error
|
|
175
|
-
expect(described_class.get_group(@group_name, options)).to
|
|
175
|
+
expect(described_class.get_group(@group_name, options)).to be_a(Sys::Admin::Group)
|
|
176
176
|
end
|
|
177
177
|
|
|
178
178
|
example 'get_group method requires an argument' do
|
|
@@ -188,8 +188,8 @@ RSpec.describe Sys::Admin, :windows do
|
|
|
188
188
|
|
|
189
189
|
example 'groups method returns an array of Group objects' do
|
|
190
190
|
groups = described_class.groups(:localaccount => true)
|
|
191
|
-
expect(groups).to
|
|
192
|
-
expect(groups).to all(
|
|
191
|
+
expect(groups).to be_a(Array)
|
|
192
|
+
expect(groups).to all(be_a(Sys::Admin::Group))
|
|
193
193
|
end
|
|
194
194
|
end
|
|
195
195
|
end
|
|
@@ -282,7 +282,7 @@ RSpec.describe Sys::Admin, :windows do
|
|
|
282
282
|
|
|
283
283
|
example 'dir method returns either a string or nil' do
|
|
284
284
|
expect{ @user = described_class.get_user(@user_name, :localaccount => true) }.not_to raise_error
|
|
285
|
-
expect(@user.dir).to
|
|
285
|
+
expect(@user.dir).to be_a(String).or be_a(NilClass)
|
|
286
286
|
end
|
|
287
287
|
end
|
|
288
288
|
|
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.
|
|
6
|
+
spec.version = '1.9.0'
|
|
7
7
|
spec.author = 'Daniel J. Berger'
|
|
8
8
|
spec.license = 'Apache-2.0'
|
|
9
9
|
spec.email = 'djberg96@gmail.com'
|
|
@@ -20,6 +20,8 @@ Gem::Specification.new do |spec|
|
|
|
20
20
|
if Gem.win_platform?
|
|
21
21
|
spec.platform = Gem::Platform.new(['universal', 'mingw32'])
|
|
22
22
|
spec.add_dependency('win32-security', '~> 0.5')
|
|
23
|
+
spec.add_dependency('win32ole')
|
|
24
|
+
spec.add_dependency('win32-registry')
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
spec.add_development_dependency('rspec', '~> 3.9')
|
|
@@ -35,7 +37,8 @@ Gem::Specification.new do |spec|
|
|
|
35
37
|
'source_code_uri' => 'https://github.com/djberg96/sys-admin',
|
|
36
38
|
'wiki_uri' => 'https://github.com/djberg96/sys-admin/wiki',
|
|
37
39
|
'rubygems_mfa_required' => 'true',
|
|
38
|
-
'github_repo' => 'https://github.com/djberg96/sys-admin'
|
|
40
|
+
'github_repo' => 'https://github.com/djberg96/sys-admin',
|
|
41
|
+
'funding_uri' => 'https://github.com/sponsors/djberg96'
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
spec.description = <<-EOF
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sys-admin
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel J. Berger
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain:
|
|
11
10
|
- |
|
|
@@ -35,7 +34,7 @@ cert_chain:
|
|
|
35
34
|
ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
|
|
36
35
|
WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
|
|
37
36
|
-----END CERTIFICATE-----
|
|
38
|
-
date:
|
|
37
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
39
38
|
dependencies:
|
|
40
39
|
- !ruby/object:Gem::Dependency
|
|
41
40
|
name: ffi
|
|
@@ -156,7 +155,7 @@ metadata:
|
|
|
156
155
|
wiki_uri: https://github.com/djberg96/sys-admin/wiki
|
|
157
156
|
rubygems_mfa_required: 'true'
|
|
158
157
|
github_repo: https://github.com/djberg96/sys-admin
|
|
159
|
-
|
|
158
|
+
funding_uri: https://github.com/sponsors/djberg96
|
|
160
159
|
rdoc_options: []
|
|
161
160
|
require_paths:
|
|
162
161
|
- lib
|
|
@@ -171,8 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
171
170
|
- !ruby/object:Gem::Version
|
|
172
171
|
version: '0'
|
|
173
172
|
requirements: []
|
|
174
|
-
rubygems_version:
|
|
175
|
-
signing_key:
|
|
173
|
+
rubygems_version: 4.0.3
|
|
176
174
|
specification_version: 4
|
|
177
175
|
summary: A unified, cross platform replacement for the "etc" library.
|
|
178
176
|
test_files:
|
metadata.gz.sig
CHANGED
|
Binary file
|