Sha256: 3910543b3042637b126b46f78d47b7550d6d04e00ef6cf9bfddc6983b1cfca5c

Contents?: true

Size: 1.52 KB

Versions: 2

Compression:

Stored size: 1.52 KB

Contents

# encoding: UTF-8
require 'rubyntlm'
require 'winrm/http/transport'

describe WinRM::HTTP::HttpNegotiate, unit: true do
  describe '#init' do
    let(:endpoint) { 'some_endpoint' }
    let(:domain) { 'some_domain' }
    let(:user) { 'some_user' }
    let(:password) { 'some_password' }
    let(:options) { {} }

    context 'user is not domain prefixed' do
      it 'does not pass a domain to the NTLM client' do
        expect(Net::NTLM::Client).to receive(:new).with(user, password, options)
        WinRM::HTTP::HttpNegotiate.new(endpoint, user, password, options)
      end
    end

    context 'user is domain prefixed' do
      it 'passes prefixed domain to the NTLM client' do
        expect(Net::NTLM::Client).to receive(:new) do |passed_user, passed_password, passed_options|
          expect(passed_user).to eq user
          expect(passed_password).to eq password
          expect(passed_options[:domain]).to eq domain
        end
        WinRM::HTTP::HttpNegotiate.new(endpoint, "#{domain}\\#{user}", password, options)
      end
    end

    context 'option is passed with a domain' do
      let(:options) { { domain: domain } }

      it 'passes domain option to the NTLM client' do
        expect(Net::NTLM::Client).to receive(:new) do |passed_user, passed_password, passed_options|
          expect(passed_user).to eq user
          expect(passed_password).to eq password
          expect(passed_options[:domain]).to eq domain
        end
        WinRM::HTTP::HttpNegotiate.new(endpoint, user, password, options)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
winrm-1.6.1 spec/transport_spec.rb
winrm-1.6.0 spec/transport_spec.rb