Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove obsolete explicit rspec tests for windows
Windows facts are included in facterdb meanwhile. There is no need
for explicit testing.
  • Loading branch information
bobapple committed Apr 24, 2018
1 parent 29eb145 commit 80c5d65
Show file tree
Hide file tree
Showing 47 changed files with 58 additions and 6,059 deletions.
2 changes: 2 additions & 0 deletions .rspec
@@ -0,0 +1,2 @@
--format documentation
--color
1 change: 1 addition & 0 deletions .rspec_parallel
@@ -0,0 +1 @@
--format progress
24 changes: 7 additions & 17 deletions Gemfile
@@ -1,23 +1,13 @@
source 'https://rubygems.org' source 'https://rubygems.org'


gem 'puppet', ENV.key?('PUPPET_VERSION') ? ENV['PUPPET_VERSION'].to_s : '>= 3.8' gem 'puppet', ENV.key?('PUPPET_VERSION') ? ENV['PUPPET_VERSION'].to_s : '>= 4.9'


gem 'puppetlabs_spec_helper', '>= 0.1.0' gem 'puppetlabs_spec_helper', '>= 2.0'
gem 'puppet-lint', '>= 0.3.2' gem 'puppet-lint', '>= 2.0.0'
gem 'facter', '>= 1.7.0' gem 'facter', '>= 2.4.0'
gem 'facterdb', '>= 0.3.12' gem 'facterdb', '>= 0.5'
gem 'rspec-puppet-facts', '>= 1.6.0' gem 'rspec-puppet-facts', '>= 1.6.0'
gem 'serverspec' gem 'serverspec'
gem 'r10k' gem 'r10k'

gem 'parallel_tests', '>= 2.10.0'
gem 'parallel_tests', RUBY_VERSION < '2.0.0' ? '~> 2.9.0' : '>= 2.10.0' gem 'metadata-json-lint'

# json > 2.0.1 is not compatible with Ruby 1.9
# metadata-json-lint > 1.1.0 is not compatible with Ruby 1.9
if RUBY_VERSION < '2.0.0'
gem 'json', '< 2'
gem 'json_pure', '< 2'
gem 'metadata-json-lint', '< 1.2.0'
else
gem 'metadata-json-lint'
end
4 changes: 2 additions & 2 deletions manifests/feature/elasticsearch.pp
Expand Up @@ -187,7 +187,7 @@


if $ssl_cert { if $ssl_cert {
$_ssl_cert = $::osfamily ? { $_ssl_cert = $::osfamily ? {
'windows' => regsubst($cert_path, '\n', "\r\n", 'EMG'), 'windows' => regsubst($ssl_cert, '\n', "\r\n", 'EMG'),
default => $ssl_cert, default => $ssl_cert,
} }


Expand All @@ -200,7 +200,7 @@


if $ssl_cacert { if $ssl_cacert {
$_ssl_cacert = $::osfamily ? { $_ssl_cacert = $::osfamily ? {
'windows' => regsubst($ca_path, '\n', "\r\n", 'EMG'), 'windows' => regsubst($ssl_cacert, '\n', "\r\n", 'EMG'),
default => $ssl_cacert, default => $ssl_cacert,
} }


Expand Down
282 changes: 1 addition & 281 deletions spec/classes/api_spec.rb
Expand Up @@ -300,284 +300,4 @@
end end
end end
end end
end end


describe('icinga2::feature::api', :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;',
:icinga2_puppet_hostcert => 'C:\Program Files\Puppet Labs\Puppet\var\lib\puppet\ssl\certs\host.example.org.pem',
:icinga2_puppet_hostprivkey => 'C:\Program Files\Puppet Labs\Puppet\var\lib\puppet\ssl\private_keys\host.example.org.pem',
:icinga2_puppet_localcacert => 'C:\Program Files\Puppet Labs\Puppet\var\lib\puppet\ssl\certs\ca.pem',
} }
let(:pre_condition) { [
"class { 'icinga2': features => [], constants => {'NodeName' => 'host.example.org'} }"
] }


context 'Windows 2012 R2 with ensure => present' do
let(:params) { {:ensure => 'present'} }

it { is_expected.to contain_icinga2__feature('api').with({'ensure' => 'present'}) }

it { is_expected.to contain_icinga2__object('icinga2::object::ApiListener::api')
.with({ 'target' => 'C:/ProgramData/icinga2/etc/icinga2/features-available/api.conf' })
.that_notifies('Class[icinga2::service]') }
end


context 'Windows 2012 R2 with ensure => absent' do
let(:params) { {:ensure => 'absent'} }

it { is_expected.to contain_icinga2__feature('api').with({'ensure' => 'absent'}) }

it { is_expected.to contain_icinga2__object('icinga2::object::ApiListener::api')
.with({ 'target' => 'C:/ProgramData/icinga2/etc/icinga2/features-available/api.conf' }) }
end


context "Windows 2012 R2 with all defaults" do
it { is_expected.to contain_icinga2__feature('api').with({'ensure' => 'present'}) }

it { is_expected.to contain_icinga2__object('icinga2::object::ApiListener::api')
.with({ 'target' => 'C:/ProgramData/icinga2/etc/icinga2/features-available/api.conf' })
.that_notifies('Class[icinga2::service]') }

it { is_expected.to contain_concat__fragment('icinga2::object::ApiListener::api')
.with({ 'target' => 'C:/ProgramData/icinga2/etc/icinga2/features-available/api.conf' })
.with_content(/accept_config = false/)
.with_content(/accept_commands = false/) }

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

it { is_expected.to contain_icinga2__object__endpoint('NodeName') }

it { is_expected.to contain_icinga2__object__zone('ZoneName')
.with({ 'endpoints' => [ 'NodeName' ] }) }
end


context "Windows 2012 R2 with pki => puppet" do
let(:params) { {:pki => 'puppet'} }

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


context "Windows 2012 R2 with pki => icinga2" do
let(:params) { {:pki => 'icinga2'} }

it { is_expected.to contain_exec('icinga2 pki create key') }
it { is_expected.to contain_exec('icinga2 pki get trusted-cert') }
it { is_expected.to contain_exec('icinga2 pki request') }
end


context "Windows 2012 R2 with pki => foo (not a valid value)" do
let(:params) { {:pki => 'foo'} }

it { is_expected.to raise_error(Puppet::Error, /expects a match for Enum\['ca', 'icinga2', 'none', 'puppet'\]/) }
end


context "Windows 2012 R2 with pki => none, ssl_key => foo, ssl_cert => bar, ssl_cacert => baz" do
let(:params) { {:pki => 'none', 'ssl_key' => 'foo', 'ssl_cert' => 'bar', 'ssl_cacert' => 'baz'} }

it { is_expected.to contain_file('C:/ProgramData/icinga2/etc/icinga2/pki/host.example.org.key')
.with_content(/^foo/) }

it { is_expected.to contain_file('C:/ProgramData/icinga2/etc/icinga2/pki/host.example.org.crt')
.with_content(/^bar/) }

it { is_expected.to contain_file('C:/ProgramData/icinga2/etc/icinga2/pki/ca.crt')
.with_content(/^baz/) }
end


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

it { is_expected.to contain_concat__fragment('icinga2::object::ApiListener::api')
.with({ 'target' => 'C:/ProgramData/icinga2/etc/icinga2/features-available/api.conf' })
.with_content(/key_path = "\/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, /Evaluation Error: Error while evaluating a Resource Statement/) }
end


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

it { is_expected.to contain_concat__fragment('icinga2::object::ApiListener::api')
.with({ 'target' => 'C:/ProgramData/icinga2/etc/icinga2/features-available/api.conf' })
.with_content(/cert_path = "\/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, /Evaluation Error: Error while evaluating a Resource Statement/) }
end


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

it { is_expected.to contain_concat__fragment('icinga2::object::ApiListener::api')
.with({ 'target' => 'C:/ProgramData/icinga2/etc/icinga2/features-available/api.conf' })
.with_content(/ca_path = "\/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, /Evaluation Error: Error while evaluating a Resource Statement/) }
end


context "Windows 2012 R2 with accept_config => true" do
let(:params) { {:accept_config => true} }

it { is_expected.to contain_concat__fragment('icinga2::object::ApiListener::api')
.with({ 'target' => 'C:/ProgramData/icinga2/etc/icinga2/features-available/api.conf' })
.with_content(/accept_config = true/) }
end


context "Windows 2012 R2 with accept_config => false" do
let(:params) { {:accept_config => false} }

it { is_expected.to contain_concat__fragment('icinga2::object::ApiListener::api')
.with({ 'target' => 'C:/ProgramData/icinga2/etc/icinga2/features-available/api.conf' })
.with_content(/accept_config = false/) }
end


context "Windows 2012 R2 with accept_config => foo (not a valid boolean)" do
let(:params) { {:accept_config => 'foo'} }

it { is_expected.to raise_error(Puppet::Error, /expects a Boolean value/) }
end


context "Windows 2012 R2 with accept_commands => true" do
let(:params) { {:accept_commands => true} }

it { is_expected.to contain_concat__fragment('icinga2::object::ApiListener::api')
.with({ 'target' => 'C:/ProgramData/icinga2/etc/icinga2/features-available/api.conf' })
.with_content(/accept_commands = true/) }
end


context "Windows 2012 R2 with accept_commands => false" do
let(:params) { {:accept_commands => false} }

it { is_expected.to contain_concat__fragment('icinga2::object::ApiListener::api')
.with({ 'target' => 'C:/ProgramData/icinga2/etc/icinga2/features-available/api.conf' })
.with_content(/accept_commands = false/) }
end


context "Windows 2012 R2 with accept_config => foo (not a valid boolean)" do
let(:params) { {:accept_commands => 'foo'} }

it { is_expected.to raise_error(Puppet::Error, /expects a Boolean value/) }
end


context "Windows 2012 R2 with pki => none, ticket_salt => foo" do
let(:params) { {:pki => 'none', :ticket_salt => 'foo'} }

it { is_expected.to contain_concat__fragment('icinga2::object::ApiListener::api')
.with({ 'target' => 'C:/ProgramData/icinga2/etc/icinga2/features-available/api.conf' })
.with_content(/ticket_salt = "foo"/) }
end


context "Windows 2012 R2 with pki => 'icinga2', ca_host => foo" do
let(:params) { {:pki => 'icinga2', :ca_host => 'foo'} }

it { is_expected.to contain_concat__fragment('icinga2::object::ApiListener::api')
.with({ 'target' => 'C:/ProgramData/icinga2/etc/icinga2/features-available/api.conf' }) }
end


context "Windows 2012 R2 with pki => 'icinga2', ca_port => 1234" do
let(:params) { {:pki => 'icinga2',:ca_port => 1234} }

it { is_expected.to contain_concat__fragment('icinga2::object::ApiListener::api')
.with({ 'target' => 'C:/ProgramData/icinga2/etc/icinga2/features-available/api.conf' }) }
end


context "Windows 2012 R2 with pki => 'icinga2', ca_port => foo (not a valid integer)" do
let(:params) { {:pki => 'icinga2',:ca_port => 'foo'} }

it { is_expected.to raise_error(Puppet::Error, /expects an Integer value/) }
end


context "Windows 2012 R2 with endpoints => { foo => {} }" do
let(:params) { {:endpoints => { 'foo' => {}} }}

it { is_expected.to contain_icinga2__object__endpoint('foo') }
end


context "Windows 2012 R2 with endpoints => foo (not a valid hash)" do
let(:params) { {:endpoints => 'foo'} }

it { is_expected.to raise_error(Puppet::Error, /expects a Hash value/) }
end


context "Windows 2012 R2 with zones => { foo => {endpoints => ['bar']} } }" do
let(:params) { {:zones => { 'foo' => {'endpoints' => ['bar']}} }}

it { is_expected.to contain_icinga2__object__zone('foo')
.with({ 'endpoints' => [ 'bar' ] }) }
end


context "Windows 2012 R2 with zones => foo (not a valid hash)" do
let(:params) { {:zones => 'foo'} }

it { is_expected.to raise_error(Puppet::Error, /expects a Hash value/) }
end

context 'Windows 2012 R2 with bind settings' do
let(:params) { { bind_host: '::', bind_port: 1234 } }

it 'should set bind_* settings' do
is_expected.to contain_concat__fragment('icinga2::object::ApiListener::api')
.with({ 'target' => 'C:/ProgramData/icinga2/etc/icinga2/features-available/api.conf' })
.with_content(/bind_host = "::"/)
.with_content(/bind_port = 1234/)
end
end
end

0 comments on commit 80c5d65

Please sign in to comment.