File: autosign_command_spec.rb

package info (click to toggle)
puppet 4.8.2-5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 20,736 kB
  • ctags: 14,616
  • sloc: ruby: 236,754; xml: 1,586; sh: 1,178; lisp: 299; sql: 103; yacc: 72; makefile: 52
file content (30 lines) | stat: -rw-r--r-- 964 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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)

    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)
    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