specinfra 2.35.0 → 2.35.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14e06d19c0a3038546153e4085ad0becd03b94f9
|
4
|
+
data.tar.gz: ccc0e91ca160daf01e681b277f82976d76edfd46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ea4a629909c618faf67f9b9c3a4e966059f3e066db749b290a18620f7b90c5bdf4eca337e677a196ee174ffd6fec8b5427bdccdc0a770b2e6a5a486c61834a7
|
7
|
+
data.tar.gz: c436115f88456d1c30b4fcc62a377a5f4f6bf4052cc6248f9b2361436eb97594d98a0d389e5b0db45d575b79396ce5948ab16379ce1fceee70c96a3d455cf183
|
@@ -5,6 +5,13 @@ class Specinfra::Command::Windows::Base
|
|
5
5
|
end
|
6
6
|
|
7
7
|
private
|
8
|
+
def create_command(command, using_ps1 = nil)
|
9
|
+
Backend::PowerShell::Command.new do
|
10
|
+
using using_ps1 if using_ps1
|
11
|
+
exec command
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
8
15
|
def windows_account account
|
9
16
|
match = /((.+)\\)?(.+)/.match account
|
10
17
|
domain = match[2]
|
@@ -11,18 +11,18 @@ class Specinfra::Command::Windows::Base::RegistryKey < Specinfra::Command::Windo
|
|
11
11
|
|
12
12
|
def check_exists(key_name)
|
13
13
|
cmd = "(Get-Item 'Registry::#{key_name}') -ne $null"
|
14
|
-
|
14
|
+
create_command cmd
|
15
15
|
end
|
16
16
|
|
17
17
|
def check_has_property(key_name, key_property)
|
18
|
-
cmd = "(Get-Item 'Registry::#{key_name}').GetValueKind('#{key_property[:name]}') -eq '#{get_key_type(
|
19
|
-
|
18
|
+
cmd = "(Get-Item 'Registry::#{key_name}').GetValueKind('#{key_property[:name]}') -eq '#{get_key_type(key_property[:type])}'"
|
19
|
+
create_command cmd
|
20
20
|
end
|
21
21
|
|
22
22
|
def check_has_value(key_name, key_property)
|
23
23
|
value = convert_key_property_value key_property
|
24
24
|
cmd = "(Compare-Object (Get-Item 'Registry::#{key_name}').GetValue('#{key_property[:name]}') #{value}) -eq $null"
|
25
|
-
|
25
|
+
create_command cmd
|
26
26
|
end
|
27
27
|
|
28
28
|
private
|
@@ -31,11 +31,11 @@ class Specinfra::Command::Windows::Base::RegistryKey < Specinfra::Command::Windo
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def get_key_type(key_type)
|
34
|
-
REGISTRY_KEY_TYPES[key_type.to_s.gsub("_converted").to_sym]
|
34
|
+
REGISTRY_KEY_TYPES[key_type.to_s.gsub("_converted",'').to_sym]
|
35
35
|
end
|
36
36
|
|
37
37
|
def convert_key_property_value property
|
38
|
-
return property if do_not_convert? property[:type]
|
38
|
+
return property[:value] if do_not_convert? property[:type]
|
39
39
|
case property[:type]
|
40
40
|
when :type_binary
|
41
41
|
byte_array = [property[:value]].pack('H*').bytes.to_a
|
data/lib/specinfra/version.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Specinfra::Command::Windows::Base::RegistryKey do
|
4
|
+
let(:key_path) { "HKLM\\Software\\Microsoft\\Windows" }
|
5
|
+
|
6
|
+
def stub_exec (command)
|
7
|
+
expect(described_class).to receive(:create_command).with(command)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'has_property?' do
|
11
|
+
it {
|
12
|
+
stub_exec "(Get-Item 'Registry::#{key_path}') -ne $null"
|
13
|
+
described_class.check_exists(key_path)
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
[:type_dword, :type_dword_converted].each do |reg_type|
|
18
|
+
it "has_property_value #{reg_type}" do
|
19
|
+
prop = {:name => 'CurrentVersion', :type => reg_type}
|
20
|
+
stub_exec "(Get-Item 'Registry::#{key_path}').GetValueKind('CurrentVersion') -eq 'DWord'"
|
21
|
+
described_class.check_has_property key_path, prop
|
22
|
+
end
|
23
|
+
end
|
24
|
+
[:type_dword, :type_dword_converted].each do |reg_type|
|
25
|
+
describe 'check_has_value' do
|
26
|
+
it {
|
27
|
+
value = reg_type == :type_dword_converted ? "23" : "17"
|
28
|
+
prop = {:name => 'CurrentVersion', :type => reg_type, :value => value}
|
29
|
+
cmd = "(Compare-Object (Get-Item 'Registry::#{key_path}').GetValue('CurrentVersion') 23) -eq $null"
|
30
|
+
stub_exec cmd
|
31
|
+
described_class.check_has_value key_path, prop
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: specinfra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.35.
|
4
|
+
version: 2.35.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gosuke Miyashita
|
@@ -423,6 +423,7 @@ files:
|
|
423
423
|
- spec/command/redhat/service_spec.rb
|
424
424
|
- spec/command/redhat7/service_spec.rb
|
425
425
|
- spec/command/ubuntu/ppa_spec.rb
|
426
|
+
- spec/command/windows/registry_key_spec.rb
|
426
427
|
- spec/configuration_spec.rb
|
427
428
|
- spec/helper/detect_os/esxi_spec.rb
|
428
429
|
- spec/helper/os_spec.rb
|
@@ -488,6 +489,7 @@ test_files:
|
|
488
489
|
- spec/command/redhat/service_spec.rb
|
489
490
|
- spec/command/redhat7/service_spec.rb
|
490
491
|
- spec/command/ubuntu/ppa_spec.rb
|
492
|
+
- spec/command/windows/registry_key_spec.rb
|
491
493
|
- spec/configuration_spec.rb
|
492
494
|
- spec/helper/detect_os/esxi_spec.rb
|
493
495
|
- spec/helper/os_spec.rb
|