Skip to content

Commit

Permalink
(CONT-812) Add helper to set up winrm
Browse files Browse the repository at this point in the history
  • Loading branch information
chelnak committed Apr 13, 2023
1 parent 4274541 commit 609a9f3
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion spec/acceptance/dsc/basic.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require 'spec_helper'
require 'spec_helper_acceptance'
require 'ruby-pwsh'
require 'securerandom'

Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/dsc/cim_instances.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# 1. Make sure valid nested CIM instances can be passed to Invoke-DscResource
# 2. Make sure nested CIM instances can be read back from Invoke-DscResource

require 'spec_helper'
require 'spec_helper_acceptance'
require 'ruby-pwsh'

# Needs to be declared here so it is usable in before and it blocks alike
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/dsc/class.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require 'spec_helper'
require 'spec_helper_acceptance'
require 'ruby-pwsh'

powershell = Pwsh::Manager.instance(Pwsh::Manager.powershell_path, Pwsh::Manager.powershell_args)
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/dsc/complex.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require 'spec_helper'
require 'spec_helper_acceptance'
require 'ruby-pwsh'

# Needs to be declared here so it is usable in before and it blocks alike
Expand Down
6 changes: 6 additions & 0 deletions spec/acceptance/support/setup_winrm.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Get-ChildItem WSMan:\localhost\Listener\ -OutVariable Listeners | Format-List * -Force
$HTTPListener = $Listeners | Where-Object -FilterScript { $_.Keys.Contains('Transport=HTTP') }
If ($HTTPListener.Count -eq 0) {
winrm create winrm/config/Listener?Address=*+Transport=HTTP
winrm e winrm/config/listener
}
13 changes: 13 additions & 0 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require 'spec_helper'

# Execute a PowerShell Script from path
def execute_powershell_script(path)
return unless Gem.win_platform?

command = "pwsh.exe -NoProfile -NonInteractive -NoLogo -ExecutionPolicy Bypass -File '#{path}'"
system(command)
end

execute_powershell_script('spec/acceptance/support/setup_winrm.ps1')

0 comments on commit 609a9f3

Please sign in to comment.