Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'spec_helper'
- describe 'do_icinga2::default' do
- let(:vault_response) do
- double('secrets', :data => {
- :encryption_key => 'obbtref',
- :aws_access_key_id => 'obbtref',
- :aws_secret_access_key => 'obbtref',
- :db_user => 'root',
- :db_password => 'obbtref',
- :replication_user => 'replication',
- :replication_password => 'obbtref',
- :monitoring_user => 'monitoring',
- :monitoring_password => 'obbtref',
- :monitoring_dbname => 'heartbeat',
- :director_password => 'director_PASSWORD',
- :icinga2_password => 'icinga2_PASSWORD',
- :icingaweb2_password => 'icingaweb2_PASSWORD'
- })
- end
- before do
- allow_any_instance_of(::Chef::Recipe).to receive(:vault_auth_kargs)
- allow_any_instance_of(::Chef::Recipe).to receive(:vault_bag_item).and_return(vault_response)
- end
- context 'on ubuntu 14.04' do
- let(:chef_run) do
- ChefSpec::SoloRunner.new(
- platform: 'ubuntu',
- version: '14.04'
- ) do |n|
- allow(n).to receive(:has_role?).and_return(true)
- set_default_node_attributes!(n)
- end.converge(described_recipe)
- end
- context 'using roles' do
- describe 'when using the icinga2-primary-master role' do
- before do
- allow(chef_run.node).to receive(:has_role?).with('icinga2-primary-master').and_return(true)
- end
- it 'should include the do_icinga2::_primary_master recipe' do
- expect(chef_run).to include_recipe('do_icinga2::_primary_master')
- end
- it 'should converge' do
- expect{ chef_run }.to_not raise_error
- end
- end
- describe 'when using the icinga2-secondary-master role' do
- before do
- allow(chef_run.node).to receive(:has_role?).with('icinga2-primary-master').and_return(false)
- allow(chef_run.node).to receive(:has_role?).with('icinga2-secondary-master').and_return(true)
- end
- it 'should include the do_icinga2::_secondary_master recipe' do
- expect(chef_run).to include_recipe('do_icinga2::_secondary_master')
- end
- it 'should converge' do
- expect { chef_run }.to_not raise_error
- end
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment