Do not test detail of keystone::auth::service_identity

... but test interfaces of that resource type. This helps us avoid
direct breakage caused by any change in puppet-keystone.

Change-Id: If1172824c6f446602632632ad749aed48fb5abfa
This commit is contained in:
Takashi Kajinami 2022-01-22 21:19:45 +09:00
parent 8ff2661983
commit bcb4265b2b

View File

@ -1,100 +1,63 @@
#
# Unit tests for ceilometer::keystone::auth
#
require 'spec_helper'
describe 'ceilometer::keystone::auth' do
shared_examples_for 'ceilometer::keystone::auth' do
context 'with default class parameters' do
let :params do
{ :password => 'ceilometer_password' }
end
let :default_params do
{
:email => 'ceilometer@localhost',
:auth_name => 'ceilometer',
:region => 'RegionOne',
:tenant => 'services',
}
end
shared_examples_for 'ceilometer keystone auth' do
context 'without the required password parameter' do
it { expect { is_expected.to raise_error(Puppet::Error) } }
it { is_expected.to contain_keystone__resource__service_identity('ceilometer').with(
:configure_user => true,
:configure_user_role => true,
:configure_endpoint => false,
:configure_service => false,
:region => 'RegionOne',
:auth_name => 'ceilometer',
:password => 'ceilometer_password',
:email => 'ceilometer@localhost',
:tenant => 'services',
) }
end
let :params do
{ :password => 'ceil0met3r-passZord' }
context 'when overriding parameters' do
let :params do
{ :password => 'ceilometer_password',
:auth_name => 'alt_ceilometer',
:email => 'alt_ceilometer@alt_localhost',
:tenant => 'alt_service',
:configure_user => false,
:configure_user_role => false,
:region => 'RegionTwo' }
end
it { is_expected.to contain_keystone__resource__service_identity('ceilometer').with(
:configure_user => false,
:configure_user_role => false,
:configure_endpoint => false,
:configure_service => false,
:region => 'RegionTwo',
:auth_name => 'alt_ceilometer',
:password => 'ceilometer_password',
:email => 'alt_ceilometer@alt_localhost',
:tenant => 'alt_service',
) }
end
context 'with the required parameters' do
it 'configures ceilometer user' do
is_expected.to contain_keystone_user( default_params[:auth_name] ).with(
:ensure => 'present',
:password => params[:password],
:email => default_params[:email],
)
end
it 'configures ceilometer user roles' do
is_expected.to contain_keystone_user_role("#{default_params[:auth_name]}@#{default_params[:tenant]}").with(
:ensure => 'present',
)
end
end
context 'with overridden parameters' do
before do
params.merge!({
:email => 'mighty-ceilometer@remotehost',
:auth_name => 'mighty-ceilometer',
:region => 'RegionFortyTwo',
:tenant => 'mighty-services',
})
end
it 'configures ceilometer user' do
is_expected.to contain_keystone_user( params[:auth_name] ).with(
:ensure => 'present',
:password => params[:password],
:email => params[:email],
)
end
it 'configures ceilometer user roles' do
is_expected.to contain_keystone_user_role("#{params[:auth_name]}@#{params[:tenant]}").with(
:ensure => 'present',
)
end
end
context 'when disabling user configuration' do
before do
params.merge!( :configure_user => false )
end
it { is_expected.to_not contain_keystone_user('ceilometer') }
it { is_expected.to contain_keystone_user_role('ceilometer@services') }
end
context 'when disabling user and role configuration' do
before do
params.merge!(
:configure_user => false,
:configure_user_role => false
)
end
it { is_expected.to_not contain_keystone_user('ceilometer') }
it { is_expected.to_not contain_keystone_user_role('ceilometer@services') }
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge(OSDefaults.get_facts())
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'ceilometer keystone auth'
it_behaves_like 'ceilometer::keystone::auth'
end
end
end