Sha256: 375fd1ccce6f01f314f34c97cb4ac68f9a2431017b584500b704b36991a9ea1b

Contents?: true

Size: 954 Bytes

Versions: 63

Compression:

Stored size: 954 Bytes

Contents

require 'spec_helper'

require 'puppet/ssl/certificate_authority/autosign_command'

describe Puppet::SSL::CertificateAuthority::AutosignCommand do

  let(:csr) { stub 'csr', :name => 'host', :to_s => 'CSR PEM goes here' }
  let(:decider) { Puppet::SSL::CertificateAuthority::AutosignCommand.new('/autosign/command') }

  it "returns true if the command succeeded" do
    executes_the_command_resulting_in(0)

    decider.allowed?(csr).should == true
  end

  it "returns false if the command failed" do
    executes_the_command_resulting_in(1)

    decider.allowed?(csr).should == false
  end

  def executes_the_command_resulting_in(exitstatus)
    Puppet::Util::Execution.expects(:execute).
      with(['/autosign/command', 'host'],
           has_entries(:stdinfile => anything,
                       :combine => true,
                       :failonfail => false)).
      returns(Puppet::Util::Execution::ProcessOutput.new('', exitstatus))
  end
end

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
puppet-3.4.0 spec/unit/ssl/certificate_authority/autosign_command_spec.rb
puppet-3.4.0.rc2 spec/unit/ssl/certificate_authority/autosign_command_spec.rb
puppet-3.4.0.rc1 spec/unit/ssl/certificate_authority/autosign_command_spec.rb