Sha256: 458b19e56138560e25f7c0f91b0c9dd4f74b3de5caf3ad0cc96289e3f0d44fd8

Contents?: true

Size: 989 Bytes

Versions: 36

Compression:

Stored size: 989 Bytes

Contents

require 'spec_helper'

require 'puppet/ssl/certificate_authority/autosign_command'

describe Puppet::SSL::CertificateAuthority::AutosignCommand do
  let(:csr) { double('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)

    expect(decider.allowed?(csr)).to eq(true)
  end

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

    expect(decider.allowed?(csr)).to eq(false)
  end

  def executes_the_command_resulting_in(exitstatus)
    expect(Puppet::Util::Execution).to receive(:execute).
      with(['/autosign/command', 'host'],
           hash_including(:stdinfile => anything,
                          :combine => true,
                          :failonfail => false)).
      and_return(Puppet::Util::Execution::ProcessOutput.new('', exitstatus))
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
puppet-5.5.22 spec/unit/ssl/certificate_authority/autosign_command_spec.rb
puppet-5.5.22-x86-mingw32 spec/unit/ssl/certificate_authority/autosign_command_spec.rb
puppet-5.5.22-x64-mingw32 spec/unit/ssl/certificate_authority/autosign_command_spec.rb
puppet-5.5.22-universal-darwin spec/unit/ssl/certificate_authority/autosign_command_spec.rb
puppet-5.5.21 spec/unit/ssl/certificate_authority/autosign_command_spec.rb
puppet-5.5.21-x86-mingw32 spec/unit/ssl/certificate_authority/autosign_command_spec.rb
puppet-5.5.21-x64-mingw32 spec/unit/ssl/certificate_authority/autosign_command_spec.rb
puppet-5.5.21-universal-darwin spec/unit/ssl/certificate_authority/autosign_command_spec.rb
puppet-5.5.20 spec/unit/ssl/certificate_authority/autosign_command_spec.rb
puppet-5.5.20-x86-mingw32 spec/unit/ssl/certificate_authority/autosign_command_spec.rb
puppet-5.5.20-x64-mingw32 spec/unit/ssl/certificate_authority/autosign_command_spec.rb
puppet-5.5.20-universal-darwin spec/unit/ssl/certificate_authority/autosign_command_spec.rb
puppet-5.5.19 spec/unit/ssl/certificate_authority/autosign_command_spec.rb
puppet-5.5.19-x86-mingw32 spec/unit/ssl/certificate_authority/autosign_command_spec.rb
puppet-5.5.19-x64-mingw32 spec/unit/ssl/certificate_authority/autosign_command_spec.rb
puppet-5.5.19-universal-darwin spec/unit/ssl/certificate_authority/autosign_command_spec.rb
puppet-5.5.18 spec/unit/ssl/certificate_authority/autosign_command_spec.rb
puppet-5.5.18-x86-mingw32 spec/unit/ssl/certificate_authority/autosign_command_spec.rb
puppet-5.5.18-x64-mingw32 spec/unit/ssl/certificate_authority/autosign_command_spec.rb
puppet-5.5.18-universal-darwin spec/unit/ssl/certificate_authority/autosign_command_spec.rb