From c5ee68926f62715939033f70e6db0ec548b66e9c Mon Sep 17 00:00:00 2001 From: John McCrae Date: Fri, 17 Jun 2022 10:51:00 -0700 Subject: Correcting Cert creation for rspec tests Signed-off-by: John McCrae --- spec/integration/client/client_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb index d2b79edf05..a56c640188 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 { -- cgit v1.2.1 From 201ad1ab88405f3c676712be27cb9d3ad15a4c63 Mon Sep 17 00:00:00 2001 From: John McCrae Date: Thu, 23 Jun 2022 08:34:35 -0700 Subject: Refactored tests for older Windows versions Signed-off-by: John McCrae --- spec/integration/client/client_spec.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'spec') diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb index a56c640188..3fa2e608e1 100644 --- a/spec/integration/client/client_spec.rb +++ b/spec/integration/client/client_spec.rb @@ -72,13 +72,18 @@ 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 { + if (-not (($PSVersionTable.PSVersion.Major -ge 5) -and ($PSVersionTable.PSVersion.Build -ge 22000)) ) { + $response = Get-ItemProperty -Path "HKLM:\\Software\\Progress\\Authentication" -Name "PfxPass" -ErrorAction Stop + } + else { + $response = Get-ItemPropertyValue -Path "HKLM:\\Software\\Progress\\Authentication" -Name "PfxPass" -ErrorAction Stop + } + if ($response) {return $true} } + Catch { + return $false + } EOH end -- cgit v1.2.1 From eee6b43216015cf7db9825b60c3c5f35d624c203 Mon Sep 17 00:00:00 2001 From: John McCrae Date: Fri, 24 Jun 2022 09:41:47 -0700 Subject: Refactored tests for older Windows versions Signed-off-by: John McCrae --- spec/integration/client/client_spec.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'spec') diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb index 3fa2e608e1..1bd84fa940 100644 --- a/spec/integration/client/client_spec.rb +++ b/spec/integration/client/client_spec.rb @@ -73,12 +73,7 @@ describe "chef-client" do def verify_export_password_exists powershell_exec! <<~EOH Try { - if (-not (($PSVersionTable.PSVersion.Major -ge 5) -and ($PSVersionTable.PSVersion.Build -ge 22000)) ) { - $response = Get-ItemProperty -Path "HKLM:\\Software\\Progress\\Authentication" -Name "PfxPass" -ErrorAction Stop - } - else { - $response = Get-ItemPropertyValue -Path "HKLM:\\Software\\Progress\\Authentication" -Name "PfxPass" -ErrorAction Stop - } + $response = Get-ItemProperty -Path "HKLM:\\Software\\Progress\\Authentication" -Name "PfxPass" -ErrorAction Stop if ($response) {return $true} } Catch { -- cgit v1.2.1 From 326af7f58592cef4c6e997296ec50c4eccb39826 Mon Sep 17 00:00:00 2001 From: John McCrae Date: Wed, 15 Jun 2022 17:30:29 -0700 Subject: Refactored code to be more readable and changed a test to correct for starting out with Auto-Managed being false by default Signed-off-by: John McCrae --- spec/functional/resource/windows_pagefile_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec') diff --git a/spec/functional/resource/windows_pagefile_spec.rb b/spec/functional/resource/windows_pagefile_spec.rb index fd44c01973..bb30c0e054 100644 --- a/spec/functional/resource/windows_pagefile_spec.rb +++ b/spec/functional/resource/windows_pagefile_spec.rb @@ -42,11 +42,11 @@ describe Chef::Resource::WindowsPagefile, :windows_only do describe "Setting Up Pagefile Management" do context "Disable Automatic Management" do - it "Disables Automatic Management" do + it "Verifies Automatic Management is Disabled" do 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 -- cgit v1.2.1 From 2227d02c8d99ee4c0e4978f1c824860ebb8b48bc Mon Sep 17 00:00:00 2001 From: John McCrae Date: Tue, 21 Jun 2022 10:51:00 -0700 Subject: Refactored code to be more readable and changed a test to correct for starting out with Auto-Managed being false by default Signed-off-by: John McCrae --- spec/functional/resource/windows_pagefile_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'spec') diff --git a/spec/functional/resource/windows_pagefile_spec.rb b/spec/functional/resource/windows_pagefile_spec.rb index bb30c0e054..a947d5b40e 100644 --- a/spec/functional/resource/windows_pagefile_spec.rb +++ b/spec/functional/resource/windows_pagefile_spec.rb @@ -40,9 +40,19 @@ 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 + describe "Setting Up Pagefile Management" do context "Disable 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) -- cgit v1.2.1 From 6348db235a97a196593f9be38fc08d324a428761 Mon Sep 17 00:00:00 2001 From: John McCrae Date: Fri, 24 Jun 2022 19:03:23 -0700 Subject: Added a new test, discovered a new bug in the tests and corrected that. All tests passing locally Signed-off-by: John McCrae --- spec/functional/resource/windows_pagefile_spec.rb | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'spec') diff --git a/spec/functional/resource/windows_pagefile_spec.rb b/spec/functional/resource/windows_pagefile_spec.rb index a947d5b40e..9767f7eeb1 100644 --- a/spec/functional/resource/windows_pagefile_spec.rb +++ b/spec/functional/resource/windows_pagefile_spec.rb @@ -49,6 +49,15 @@ describe Chef::Resource::WindowsPagefile, :windows_only do 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 "Verifies Automatic Management is Disabled" do @@ -65,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 @@ -79,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 -- cgit v1.2.1 From 87193ea7913b85330f5bbf45d02a022c65fb920e Mon Sep 17 00:00:00 2001 From: John McCrae Date: Fri, 24 Jun 2022 20:03:25 -0700 Subject: Added a new test, discovered a new bug in the tests and corrected that. All tests passing locally Signed-off-by: John McCrae --- spec/functional/resource/windows_pagefile_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/functional/resource/windows_pagefile_spec.rb b/spec/functional/resource/windows_pagefile_spec.rb index 9767f7eeb1..9e4abc7e58 100644 --- a/spec/functional/resource/windows_pagefile_spec.rb +++ b/spec/functional/resource/windows_pagefile_spec.rb @@ -49,7 +49,7 @@ describe Chef::Resource::WindowsPagefile, :windows_only do powershell_exec!(powershell_code) end - def set_automatic_managed_to_true + def set_automatic_managed_to_true powershell_code = <<~EOH $computersys = Get-WmiObject Win32_ComputerSystem -EnableAllPrivileges; $computersys.AutomaticManagedPagefile = $True; -- cgit v1.2.1