Sha256: 708508fd7441c08860817cea1f06a901c99d4e85bbf1545eae7e3f4b3580e17c

Contents?: true

Size: 974 Bytes

Versions: 3

Compression:

Stored size: 974 Bytes

Contents

# encoding: UTF-8
require 'winrm'
require 'winrm-elevated'
require_relative 'matchers'

# Creates a WinRM connection for integration tests
module ConnectionHelper
  def winrm_connection
    WinRM::WinRMWebService.new(
      winrm_config['endpoint'],
      winrm_config['auth_type'].to_sym,
      user: username,
      pass: password,
      basic_auth_only: true)
  end

  def elevated_runner
    @elevated_runner ||= WinRM::Elevated::Runner.new(winrm_connection)
  end

  def winrm_config
    unless @winrm_config
      path = File.expand_path("#{File.dirname(__FILE__)}/config.yml")
      unless File.exist?(path)
        path = File.expand_path("#{File.dirname(__FILE__)}/config-example.yml")
      end
      @winrm_config = YAML.load(File.read(path))
    end
    @winrm_config
  end

  def username
    winrm_config['options']['user']
  end

  def password
    winrm_config['options']['pass']
  end
end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
winrm-elevated-0.3.0 spec/spec_helper.rb
winrm-elevated-0.2.0 spec/spec_helper.rb
winrm-elevated-0.1.0 spec/spec_helper.rb