From 3499bbe25a4bdeb326776bba5402f85521f2a206 Mon Sep 17 00:00:00 2001 From: Blerim Sheqa Date: Thu, 6 Apr 2017 16:14:33 +0200 Subject: [PATCH] Add rspec tests for custom facts --- .../util/fact_icinga2_puppet_hostcert_spec.rb | 38 +++++++++++++++++++ .../fact_icinga2_puppet_hostprivkey_spec.rb | 38 +++++++++++++++++++ .../fact_icinga2_puppet_localcacert_spec.rb | 38 +++++++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 spec/unit/facter/util/fact_icinga2_puppet_hostcert_spec.rb create mode 100644 spec/unit/facter/util/fact_icinga2_puppet_hostprivkey_spec.rb create mode 100644 spec/unit/facter/util/fact_icinga2_puppet_localcacert_spec.rb diff --git a/spec/unit/facter/util/fact_icinga2_puppet_hostcert_spec.rb b/spec/unit/facter/util/fact_icinga2_puppet_hostcert_spec.rb new file mode 100644 index 000000000..dbba4228e --- /dev/null +++ b/spec/unit/facter/util/fact_icinga2_puppet_hostcert_spec.rb @@ -0,0 +1,38 @@ +require 'spec_helper' + +describe Facter::Util::Fact do + on_supported_os.each do |os, facts| + let :facts do + facts + end + + context "#{os} icinga2_puppet_hostcert fact" do + it { expect(Facter.fact(:icinga2_puppet_hostcert).value).to match(/\/ssl\/certs\/.*.pem/) } + end + end +end + +describe('icinga2::feature::gelf', :type => :class) do + let(:facts) { { + :kernel => 'Windows', + :architecture => 'x86_64', + :osfamily => 'Windows', + :operatingsystem => 'Windows', + :operatingsystemmajrelease => '2012 R2', + :path => 'C:\Program Files\Puppet Labs\Puppet\puppet\bin; + C:\Program Files\Puppet Labs\Puppet\facter\bin; + C:\Program Files\Puppet Labs\Puppet\hiera\bin; + C:\Program Files\Puppet Labs\Puppet\mcollective\bin; + C:\Program Files\Puppet Labs\Puppet\bin; + C:\Program Files\Puppet Labs\Puppet\sys\ruby\bin; + C:\Program Files\Puppet Labs\Puppet\sys\tools\bin; + C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem; + C:\Windows\System32\WindowsPowerShell\v1.0\; + C:\ProgramData\chocolatey\bin;', + } } + + context "Windows 2012 R2 icinga2_puppet_hostcert fact" do + it { expect(Facter.fact(:icinga2_puppet_hostcert).value).to match(/\/ssl\/certs\/.*.pem/) } + end + +end diff --git a/spec/unit/facter/util/fact_icinga2_puppet_hostprivkey_spec.rb b/spec/unit/facter/util/fact_icinga2_puppet_hostprivkey_spec.rb new file mode 100644 index 000000000..e4f5a05f0 --- /dev/null +++ b/spec/unit/facter/util/fact_icinga2_puppet_hostprivkey_spec.rb @@ -0,0 +1,38 @@ +require 'spec_helper' + +describe Facter::Util::Fact do + on_supported_os.each do |os, facts| + let :facts do + facts + end + + context "#{os} icinga2_puppet_hostprivkey fact" do + it { expect(Facter.fact(:icinga2_puppet_hostprivkey).value).to match(/\/ssl\/private_keys\/.*.pem/) } + end + end +end + +describe('icinga2::feature::gelf', :type => :class) do + let(:facts) { { + :kernel => 'Windows', + :architecture => 'x86_64', + :osfamily => 'Windows', + :operatingsystem => 'Windows', + :operatingsystemmajrelease => '2012 R2', + :path => 'C:\Program Files\Puppet Labs\Puppet\puppet\bin; + C:\Program Files\Puppet Labs\Puppet\facter\bin; + C:\Program Files\Puppet Labs\Puppet\hiera\bin; + C:\Program Files\Puppet Labs\Puppet\mcollective\bin; + C:\Program Files\Puppet Labs\Puppet\bin; + C:\Program Files\Puppet Labs\Puppet\sys\ruby\bin; + C:\Program Files\Puppet Labs\Puppet\sys\tools\bin; + C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem; + C:\Windows\System32\WindowsPowerShell\v1.0\; + C:\ProgramData\chocolatey\bin;', + } } + + context "Windows 2012 R2 icinga2_puppet_hostprivkey fact" do + it { expect(Facter.fact(:icinga2_puppet_hostprivkey).value).to match(/\/ssl\/private_keys\/.*.pem/) } + end + +end diff --git a/spec/unit/facter/util/fact_icinga2_puppet_localcacert_spec.rb b/spec/unit/facter/util/fact_icinga2_puppet_localcacert_spec.rb new file mode 100644 index 000000000..822f928bb --- /dev/null +++ b/spec/unit/facter/util/fact_icinga2_puppet_localcacert_spec.rb @@ -0,0 +1,38 @@ +require 'spec_helper' + +describe Facter::Util::Fact do + on_supported_os.each do |os, facts| + let :facts do + facts + end + + context "#{os} icinga2_puppet_localcacert fact" do + it { expect(Facter.fact(:icinga2_puppet_localcacert).value).to match(/\/ssl\/certs\/.*.pem/) } + end + end +end + +describe('icinga2::feature::gelf', :type => :class) do + let(:facts) { { + :kernel => 'Windows', + :architecture => 'x86_64', + :osfamily => 'Windows', + :operatingsystem => 'Windows', + :operatingsystemmajrelease => '2012 R2', + :path => 'C:\Program Files\Puppet Labs\Puppet\puppet\bin; + C:\Program Files\Puppet Labs\Puppet\facter\bin; + C:\Program Files\Puppet Labs\Puppet\hiera\bin; + C:\Program Files\Puppet Labs\Puppet\mcollective\bin; + C:\Program Files\Puppet Labs\Puppet\bin; + C:\Program Files\Puppet Labs\Puppet\sys\ruby\bin; + C:\Program Files\Puppet Labs\Puppet\sys\tools\bin; + C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem; + C:\Windows\System32\WindowsPowerShell\v1.0\; + C:\ProgramData\chocolatey\bin;', + } } + + context "Windows 2012 R2 icinga2_puppet_localcacert fact" do + it { expect(Facter.fact(:icinga2_puppet_localcacert).value).to match(/\/ssl\/certs\/.*.pem/) } + end + +end