Sha256: ac739a1951a36425209ffcde27544d1776d1afead3bfdb277bb2b1a4aa5f8193

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

$: << File.dirname(__FILE__) + '/../../lib/'
require 'winrm'
require 'json'

module ConnectionHelper
  # To run this test put a file called 'creds.json' in this directory with the following format:
  #   {"user":"myuser","pass":"mypass","endpoint":"http://mysys.com/wsman","realm":"MY.REALM"}
  WINRM_CONFIG = File.expand_path("#{File.dirname(__FILE__)}/../config.yml")

  def winrm_connection
    config = symbolize_keys(YAML.load(File.read(WINRM_CONFIG)))
    config[:options].merge!( :basic_auth_only => true ) unless config[:auth_type].eql? :kerberos
    winrm = WinRM::WinRMWebService.new(config[:endpoint], config[:auth_type].to_sym, config[:options])
    winrm
  end

  def symbolize_keys(hash)
    hash.inject({}){|result, (key, value)|
      new_key = case key
                when String then key.to_sym
                else key
                end
      new_value = case value
                  when Hash then symbolize_keys(value)
                  else value
                  end
      result[new_key] = new_value
      result
    }
  end

end

RSpec.configure do |config|
  config.include(ConnectionHelper)
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
vagrant-tiktalik-0.0.3 vendor/bundle/ruby/2.0.0/gems/winrm-1.1.3/test/spec/spec_helper.rb
winrm-1.1.3 test/spec/spec_helper.rb
winrm-1.1.2 test/spec/spec_helper.rb