Skip to content

Commit

Permalink
Update specs for icinga2::pki::ca
Browse files Browse the repository at this point in the history
  • Loading branch information
bobapple committed Feb 28, 2017
1 parent a80a97f commit 44180f7
Showing 1 changed file with 123 additions and 2 deletions.
125 changes: 123 additions & 2 deletions spec/classes/ca_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe('icinga2::pki::ca', :type => :class) do
let(:pre_condition) { [
"class { 'icinga2': }"
"class { 'icinga2': features => [], constants => {'NodeName' => 'host.example.org'} }"
] }

before(:all) do
Expand All @@ -17,6 +17,10 @@

context "#{os} with defaults (no params)" do
it { is_expected.to contain_exec('create-icinga2-ca') }

it { is_expected.to contain_file('/etc/icinga2/pki/host.example.org.key') }
it { is_expected.to contain_file('/etc/icinga2/pki/host.example.org.crt') }
it { is_expected.to contain_file('/etc/icinga2/pki/ca.crt') }
end


Expand All @@ -26,6 +30,61 @@
it { is_expected.to contain_file(@ca_cert).with_content(/foo/) }
it { is_expected.to contain_file(@ca_key).with_content(/bar/) }
end

context "#{os} with ssl_key_path = /foo/bar" do
let(:params) { {:ssl_key_path => '/foo/bar'} }

it { is_expected.to contain_file('/foo/bar') }
end


context "#{os} with ssl_key_path = foo/bar (not a valid absolute path)" do
let(:params) { {:ssl_key_path => 'foo/bar'} }

it { is_expected.to raise_error(Puppet::Error, /"foo\/bar" is not an absolute path/) }
end


context "#{os} with ssl_cert_path = /foo/bar" do
let(:params) { {:ssl_cert_path => '/foo/bar'} }

it { is_expected.to contain_file('/foo/bar') }
end


context "#{os} with ssl_cert_path = foo/bar (not a valid absolute path)" do
let(:params) { {:ssl_cert_path => 'foo/bar'} }

it { is_expected.to raise_error(Puppet::Error, /"foo\/bar" is not an absolute path/) }
end


context "#{os} with ssl_csr_path = /foo/bar" do
let(:params) { {:ssl_csr_path => '/foo/bar'} }

it { is_expected.to contain_file('/foo/bar') }
end


context "#{os} with ssl_csr_path = foo/bar (not a valid absolute path)" do
let(:params) { {:ssl_csr_path => 'foo/bar'} }

it { is_expected.to raise_error(Puppet::Error, /"foo\/bar" is not an absolute path/) }
end


context "#{os} with ssl_cacert_path = /foo/bar" do
let(:params) { {:ssl_cacert_path => '/foo/bar'} }

it { is_expected.to contain_file('/foo/bar') }
end


context "#{os} with ssl_cacert_path = foo/bar (not a valid absolute path)" do
let(:params) { {:ssl_cacert_path => 'foo/bar'} }

it { is_expected.to raise_error(Puppet::Error, /"foo\/bar" is not an absolute path/) }
end
end
end

Expand All @@ -48,16 +107,21 @@
C:\ProgramData\chocolatey\bin;',
} }
let(:pre_condition) { [
"class { 'icinga2': }"
"class { 'icinga2': features => [], constants => {'NodeName' => 'host.example.org'} }"
] }

before(:all) do
@ca_cert = "C:/ProgramData/icinga2/var/lib/icinga2/ca/ca.crt"
@ca_key = "C:/ProgramData/icinga2/var/lib/icinga2/ca/ca.key"
end


context "Windows 2012 R2 with defaults (no params)" do
it { is_expected.to contain_exec('create-icinga2-ca') }

it { is_expected.to contain_file('C:/ProgramData/icinga2/etc/icinga2/pki/host.example.org.key') }
it { is_expected.to contain_file('C:/ProgramData/icinga2/etc/icinga2/pki/host.example.org.crt') }
it { is_expected.to contain_file('C:/ProgramData/icinga2/etc/icinga2/pki/ca.crt') }
end


Expand All @@ -67,6 +131,63 @@
it { is_expected.to contain_file(@ca_cert).with_content(/foo/) }
it { is_expected.to contain_file(@ca_key).with_content(/bar/) }
end

context "Windows 2012 R2 with ssl_key_path = /foo/bar" do
let(:params) { {:ssl_key_path => 'C:/ProgramData/icinga2/foo/bar'} }

it { is_expected.to contain_file('C:/ProgramData/icinga2/foo/bar') }
end


context "Windows 2012 R2 with ssl_key_path = foo/bar (not a valid absolute path)" do
let(:params) { {:ssl_key_path => 'foo/bar'} }

it { is_expected.to raise_error(Puppet::Error, /"foo\/bar" is not an absolute path/) }
end


context "Windows 2012 R2 with ssl_cert_path = C:/ProgramData/icinga2/foo/bar" do
let(:params) { {:ssl_cert_path => 'C:/ProgramData/icinga2/foo/bar'} }

it { is_expected.to contain_file('C:/ProgramData/icinga2/foo/bar') }
end


context "Windows 2012 R2 with ssl_cert_path = foo/bar (not a valid absolute path)" do
let(:params) { {:ssl_cert_path => 'foo/bar'} }

it { is_expected.to raise_error(Puppet::Error, /"foo\/bar" is not an absolute path/) }
end


context "Windows 2012 R2 with ssl_csr_path = C:/ProgramData/icinga2/foo/bar" do
let(:params) { {:ssl_csr_path => 'C:/ProgramData/icinga2/foo/bar'} }

it { is_expected.to contain_file('C:/ProgramData/icinga2/foo/bar') }
end


context "Windows 2012 R2 with ssl_csr_path = foo/bar (not a valid absolute path)" do
let(:params) { {:ssl_csr_path => 'foo/bar'} }

it { is_expected.to raise_error(Puppet::Error, /"foo\/bar" is not an absolute path/) }
end


context "Windows 2012 R2 with ssl_cacert_path = C:/ProgramData/icinga2/foo/bar" do
let(:params) { {:ssl_cacert_path => 'C:/ProgramData/icinga2/foo/bar'} }

it { is_expected.to contain_file('C:/ProgramData/icinga2/foo/bar') }
end


context "Windows 2012 R2 with ssl_cacert_path = foo/bar (not a valid absolute path)" do
let(:params) { {:ssl_cacert_path => 'foo/bar'} }

it { is_expected.to raise_error(Puppet::Error, /"foo\/bar" is not an absolute path/) }
end


end


Expand Down

0 comments on commit 44180f7

Please sign in to comment.