From 2177caed38a667c5957752b44ae2a720788b3a81 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami <tkajinam@redhat.com> Date: Mon, 27 Sep 2021 13:09:10 +0900 Subject: [PATCH] Do not test detail of keystone::resource::service_identity ... but test interfaces of that resource type. This helps us avoid direct breakage caused by any change in puppet-keystone. Change-Id: I8a5ce23c55ac52f155a4cfec322eb3831df7494f --- spec/classes/mistral_keystone_auth_spec.rb | 122 +++++++++------------ 1 file changed, 52 insertions(+), 70 deletions(-) diff --git a/spec/classes/mistral_keystone_auth_spec.rb b/spec/classes/mistral_keystone_auth_spec.rb index 6d7086c..61bd9f9 100644 --- a/spec/classes/mistral_keystone_auth_spec.rb +++ b/spec/classes/mistral_keystone_auth_spec.rb @@ -1,86 +1,68 @@ +# +# Unit tests for mistral::keystone::auth +# + require 'spec_helper' describe 'mistral::keystone::auth' do - shared_examples 'mistral::keystone::auth' do + shared_examples_for 'mistral::keystone::auth' do context 'with default class parameters' do let :params do - { - :password => 'mistral_password', - :tenant => 'services' - } + { :password => 'mistral_password' } end - it { should contain_keystone_user('mistral').with( - :ensure => 'present', - :password => 'mistral_password', - )} - - it { should contain_keystone_user_role('mistral@services').with( - :ensure => 'present', - :roles => ['admin'] - )} - - it { should contain_keystone_service('mistral::workflowv2').with( - :ensure => 'present', - :description => 'OpenStack Workflow Service' - )} - - it { should contain_keystone_endpoint('RegionOne/mistral::workflowv2').with( - :ensure => 'present', - :public_url => "http://127.0.0.1:8989/v2", - :admin_url => "http://127.0.0.1:8989/v2", - :internal_url => "http://127.0.0.1:8989/v2" - )} + it { is_expected.to contain_keystone__resource__service_identity('mistral').with( + :configure_user => true, + :configure_user_role => true, + :configure_endpoint => true, + :service_name => 'mistral', + :service_type => 'workflowv2', + :service_description => 'OpenStack Workflow Service', + :region => 'RegionOne', + :auth_name => 'mistral', + :password => 'mistral_password', + :email => 'mistral@localhost', + :tenant => 'services', + :public_url => 'http://127.0.0.1:8989/v2', + :internal_url => 'http://127.0.0.1:8989/v2', + :admin_url => 'http://127.0.0.1:8989/v2', + ) } end - context 'when overriding auth and service name' do + context 'when overriding parameters' do let :params do - { - :service_name => 'mistraly', - :auth_name => 'mistraly', - :password => 'mistral_password' - } - end - - it { should contain_keystone_user('mistraly') } - it { should contain_keystone_user_role('mistraly@services') } - it { should contain_keystone_service('mistraly::workflowv2') } - it { should contain_keystone_endpoint('RegionOne/mistraly::workflowv2') } - end - - context 'when disabling user configuration' do - let :params do - { - :password => 'mistral_password', - :configure_user => false - } - end - - it { should_not contain_keystone_user('mistral') } - it { should contain_keystone_user_role('mistral@services') } - - it { should contain_keystone_service('mistral::workflowv2').with( - :ensure => 'present', - :description => 'OpenStack Workflow Service' - )} - end - - context 'when disabling user and user role configuration' do - let :params do - { - :password => 'mistral_password', + { :password => 'mistral_password', + :auth_name => 'alt_mistral', + :email => 'alt_mistral@alt_localhost', + :tenant => 'alt_service', + :configure_endpoint => false, :configure_user => false, - :configure_user_role => false - } + :configure_user_role => false, + :service_description => 'Alternative OpenStack Workflow Service', + :service_name => 'alt_service', + :service_type => 'alt_workflowv2', + :region => 'RegionTwo', + :public_url => 'https://10.10.10.10:80', + :internal_url => 'http://10.10.10.11:81', + :admin_url => 'http://10.10.10.12:81' } end - it { should_not contain_keystone_user('mistral') } - it { should_not contain_keystone_user_role('mistral@services') } - - it { should contain_keystone_service('mistral::workflowv2').with( - :ensure => 'present', - :description => 'OpenStack Workflow Service' - )} + it { is_expected.to contain_keystone__resource__service_identity('mistral').with( + :configure_user => false, + :configure_user_role => false, + :configure_endpoint => false, + :service_name => 'alt_service', + :service_type => 'alt_workflowv2', + :service_description => 'Alternative OpenStack Workflow Service', + :region => 'RegionTwo', + :auth_name => 'alt_mistral', + :password => 'mistral_password', + :email => 'alt_mistral@alt_localhost', + :tenant => 'alt_service', + :public_url => 'https://10.10.10.10:80', + :internal_url => 'http://10.10.10.11:81', + :admin_url => 'http://10.10.10.12:81', + ) } end end