Sha256: a02a61fa5c717447125b169436c471875b8e805710d749b569c11aa568e66a40

Contents?: true

Size: 1.76 KB

Versions: 21

Compression:

Stored size: 1.76 KB

Contents

require 'spec_helper'

module Scooter

  describe Utilities::BeakerUtilities do

    let(:result)          { instance_double(Beaker::Result)}
    let(:master)          { instance_double(Beaker::Host) }

    context 'with correct argument' do

      it 'gets the pe ca certfile' do
        cmd = "cat `puppet agent --configprint localcacert`"
        expect_any_instance_of(Beaker::DSL).to receive(:on).with(master, cmd, any_args).and_return(result)
        expect(result).to receive(:stdout).and_return('foobar')
        expect(subject.pe_ca_cert_file(master)).to match(/\/.*pe_certs.*\/cacert.pem/)
      end

      it 'gets the pe hostprivkey' do
        cmd = "cat `puppet agent --configprint hostprivkey`"
        expect_any_instance_of(Beaker::DSL).to receive(:on).with(master, cmd, any_args).and_return(result)
        expect(result).to receive(:stdout).and_return('foobar')
        expect(subject.pe_private_key(master)).to eq('foobar')
      end

      it 'gets the pe hostcert' do
        cmd = "cat `puppet agent --configprint hostcert`"
        expect_any_instance_of(Beaker::DSL).to receive(:on).with(master, cmd, any_args).and_return(result)
        expect(result).to receive(:stdout).and_return('foobar')
        expect(subject.pe_hostcert(master)).to eq('foobar')
      end

    end

    context 'without correct arguments' do

      it 'getting the pe ca certificate fails with no arguments' do
        expect{ subject.pe_ca_cert_file }.to raise_error(ArgumentError)
      end

      it 'getting the pe hostprivkey fails with no arguments' do
        expect{ subject.pe_private_key }.to raise_error(ArgumentError)
      end

      it 'getting the pe hostcert fails with no arguments' do
        expect{ subject.pe_hostcert }.to raise_error(ArgumentError)
      end

    end

  end

end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
scooter-4.5.4 spec/scooter/beaker_utilities_spec.rb
scooter-4.5.3 spec/scooter/beaker_utilities_spec.rb
scooter-4.5.2 spec/scooter/beaker_utilities_spec.rb
scooter-4.5.1 spec/scooter/beaker_utilities_spec.rb
scooter-4.5.0 spec/scooter/beaker_utilities_spec.rb
scooter-4.4.0 spec/scooter/beaker_utilities_spec.rb
scooter-4.3.2 spec/scooter/beaker_utilities_spec.rb
scooter-4.3.1 spec/scooter/beaker_utilities_spec.rb
scooter-4.3.0 spec/scooter/beaker_utilities_spec.rb
scooter-4.2.9 spec/scooter/beaker_utilities_spec.rb
scooter-4.2.8 spec/scooter/beaker_utilities_spec.rb
scooter-4.2.7 spec/scooter/beaker_utilities_spec.rb
scooter-4.2.6 spec/scooter/beaker_utilities_spec.rb
scooter-4.2.5 spec/scooter/beaker_utilities_spec.rb
scooter-4.2.4 spec/scooter/beaker_utilities_spec.rb
scooter-4.2.3 spec/scooter/beaker_utilities_spec.rb
scooter-4.2.2 spec/scooter/beaker_utilities_spec.rb
scooter-4.2.1 spec/scooter/beaker_utilities_spec.rb
scooter-4.2.0 spec/scooter/beaker_utilities_spec.rb
scooter-3.2.19 spec/scooter/beaker_utilities_spec.rb