summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorBapu L <bapu.labade@progress.com>2022-06-27 18:46:48 +0530
committerBapu L <bapu.labade@progress.com>2022-06-27 18:46:48 +0530
commit8c139ab355803a3487f91cd89121a57731a5f3e6 (patch)
treeeab072e096c46988b8bb7665dbae812a466ae2a1 /spec
parent7ba79354d064144dfa544fd3b45fc3445cbd0bfa (diff)
parentf2a10272c29c80c06143d094c87f182827de12c5 (diff)
downloadchef-8c139ab355803a3487f91cd89121a57731a5f3e6.tar.gz
Merge branch 'main' into fix_desired_state_issue
Diffstat (limited to 'spec')
-rw-r--r--spec/functional/resource/windows_pagefile_spec.rb35
-rw-r--r--spec/integration/client/client_spec.rb14
2 files changed, 38 insertions, 11 deletions
diff --git a/spec/functional/resource/windows_pagefile_spec.rb b/spec/functional/resource/windows_pagefile_spec.rb
index fd44c01973..9e4abc7e58 100644
--- a/spec/functional/resource/windows_pagefile_spec.rb
+++ b/spec/functional/resource/windows_pagefile_spec.rb
@@ -40,13 +40,32 @@ describe Chef::Resource::WindowsPagefile, :windows_only do
new_resource
end
+ def set_automatic_managed_to_false
+ powershell_code = <<~EOH
+ $computersys = Get-WmiObject Win32_ComputerSystem -EnableAllPrivileges;
+ $computersys.AutomaticManagedPagefile = $False;
+ $computersys.Put();
+ EOH
+ powershell_exec!(powershell_code)
+ end
+
+ def set_automatic_managed_to_true
+ powershell_code = <<~EOH
+ $computersys = Get-WmiObject Win32_ComputerSystem -EnableAllPrivileges;
+ $computersys.AutomaticManagedPagefile = $True;
+ $computersys.Put();
+ EOH
+ powershell_exec!(powershell_code)
+ end
+
describe "Setting Up Pagefile Management" do
context "Disable Automatic Management" do
- it "Disables Automatic Management" do
+ it "Verifies Automatic Management is Disabled" do
+ set_automatic_managed_to_false
subject.path c_path
subject.automatic_managed false
subject.run_action(:set)
- expect(subject).to be_updated_by_last_action
+ expect(subject).not_to be_updated_by_last_action
end
it "Enable Automatic Management " do
@@ -55,6 +74,14 @@ describe Chef::Resource::WindowsPagefile, :windows_only do
subject.run_action(:set)
expect(subject).to be_updated_by_last_action
end
+
+ it "Disables Automatic Management" do
+ set_automatic_managed_to_true
+ subject.path c_path
+ subject.automatic_managed false
+ subject.run_action(:set)
+ expect(subject).to be_updated_by_last_action
+ end
end
end
@@ -69,8 +96,8 @@ describe Chef::Resource::WindowsPagefile, :windows_only do
context "Update a pagefile" do
it "Changes a pagefile to use custom sizes" do
subject.path c_path
- subject.initial_size 20000
- subject.maximum_size 80000
+ subject.initial_size 128
+ subject.maximum_size 512
subject.run_action(:set)
expect(subject).to be_updated_by_last_action
end
diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb
index d2b79edf05..1bd84fa940 100644
--- a/spec/integration/client/client_spec.rb
+++ b/spec/integration/client/client_spec.rb
@@ -38,7 +38,7 @@ describe "chef-client" do
def install_certificate_in_store(client_name)
if ChefUtils.windows?
powershell_exec! <<~EOH
- if (-not ($PSVersionTable.PSVersion.Major -ge 5)) {
+ if (-not (($PSVersionTable.PSVersion.Major -ge 5) -and ($PSVersionTable.PSVersion.Build -ge 22000)) ) {
New-SelfSignedCertificate -CertStoreLocation Cert:\\LocalMachine\\My -DnsName "#{client_name}"
}
else {
@@ -72,13 +72,13 @@ describe "chef-client" do
def verify_export_password_exists
powershell_exec! <<~EOH
- Try {
- $response = Get-ItemPropertyValue -Path "HKLM:\\Software\\Progress\\Authentication" -Name "PfxPass" -ErrorAction Stop
- if ($response) {return $true}
- }
- Catch {
- return $false
+ Try {
+ $response = Get-ItemProperty -Path "HKLM:\\Software\\Progress\\Authentication" -Name "PfxPass" -ErrorAction Stop
+ if ($response) {return $true}
}
+ Catch {
+ return $false
+ }
EOH
end