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: Icafdac7a8f2e0184f296203177e48f2910ede66e
This commit is contained in:
Takashi Kajinami 2021-09-27 21:38:41 +09:00
parent 827d3fe148
commit 074b7fce7c
2 changed files with 102 additions and 253 deletions

View File

@ -15,140 +15,69 @@
# License for the specific language governing permissions and limitations
# under the License.
#
#
# Unit tests for ironic::keystone::auth_inspector
#
require 'spec_helper'
describe 'ironic::keystone::auth_inspector' do
shared_examples_for 'ironic keystone auth inspector' do
describe 'with default class parameters' do
shared_examples_for 'ironic::keystone::auth_inspector' do
context 'with default class parameters' do
let :params do
{ :password => 'ironic_inspector_password',
:tenant => 'foobar' }
{ :password => 'ironic-inspector_password' }
end
it { is_expected.to contain_keystone_user('ironic-inspector').with(
:ensure => 'present',
:password => 'ironic_inspector_password',
) }
it { is_expected.to contain_keystone_user_role('ironic-inspector@foobar').with(
:ensure => 'present',
:roles => ['admin']
)}
it { is_expected.to contain_keystone_service('ironic-inspector::baremetal-introspection').with(
:ensure => 'present',
:type => 'baremetal-introspection',
:description => 'Bare Metal Introspection Service'
) }
it { is_expected.to contain_keystone_endpoint('RegionOne/ironic-inspector::baremetal-introspection').with(
:ensure => 'present',
:public_url => "http://127.0.0.1:5050",
:admin_url => "http://127.0.0.1:5050",
:internal_url => "http://127.0.0.1:5050"
it { is_expected.to contain_keystone__resource__service_identity('ironic-inspector').with(
:configure_user => true,
:configure_user_role => true,
:configure_endpoint => true,
:service_name => 'ironic-inspector',
:service_type => 'baremetal-introspection',
:service_description => 'Bare Metal Introspection Service',
:region => 'RegionOne',
:password => 'ironic-inspector_password',
:email => 'baremetal-introspection@localhost',
:tenant => 'services',
:public_url => 'http://127.0.0.1:5050',
:internal_url => 'http://127.0.0.1:5050',
:admin_url => 'http://127.0.0.1:5050',
) }
end
describe 'when configuring ironic-inspector' do
let :pre_condition do
"class { 'ironic::inspector': auth_password => 'test' }"
end
context 'when overriding parameters' do
let :params do
{ :password => 'ironic_password',
:tenant => 'foobar' }
end
end
describe 'with endpoint parameters' do
let :params do
{ :password => 'ironic_password',
:public_url => 'https://10.0.0.10:5050',
:admin_url => 'https://10.0.0.11:5050',
:internal_url => 'https://10.0.0.11:5050' }
end
it { is_expected.to contain_keystone_endpoint('RegionOne/ironic-inspector::baremetal-introspection').with(
:ensure => 'present',
:public_url => 'https://10.0.0.10:5050',
:admin_url => 'https://10.0.0.11:5050',
:internal_url => 'https://10.0.0.11:5050'
) }
end
describe 'when overriding auth name' do
let :params do
{ :password => 'foo',
:auth_name => 'inspecty' }
end
it { is_expected.to contain_keystone_user('inspecty') }
it { is_expected.to contain_keystone_user_role('inspecty@services') }
it { is_expected.to contain_keystone_service('inspecty::baremetal-introspection') }
it { is_expected.to contain_keystone_endpoint('RegionOne/inspecty::baremetal-introspection') }
end
describe 'when overriding service name' do
let :params do
{
:service_name => 'inspector_service',
:password => 'ironic_password',
}
end
it { is_expected.to contain_keystone_user('ironic-inspector') }
it { is_expected.to contain_keystone_user_role('ironic-inspector@services') }
it { is_expected.to contain_keystone_service('inspector_service::baremetal-introspection') }
it { is_expected.to contain_keystone_endpoint('RegionOne/inspector_service::baremetal-introspection') }
end
describe 'when disabling user configuration' do
let :params do
{
:password => 'ironic_password',
:configure_user => false
}
end
it { is_expected.not_to contain_keystone_user('ironic-inspector') }
it { is_expected.to contain_keystone_user_role('ironic-inspector@services') }
it { is_expected.to contain_keystone_service('ironic-inspector::baremetal-introspection').with(
:ensure => 'present',
:type => 'baremetal-introspection',
:description => 'Bare Metal Introspection Service'
) }
end
describe 'when disabling user and user role configuration' do
let :params do
{
:password => 'ironic_password',
{ :password => 'ironic-inspector_password',
:auth_name => 'alt_ironic-inspector',
:email => 'alt_ironic-inspector@alt_localhost',
:tenant => 'alt_service',
:configure_endpoint => false,
:configure_user => false,
:configure_user_role => false
}
:configure_user_role => false,
:service_description => 'Alternative Bare Metal Introspection Service',
:service_name => 'alt_service',
:service_type => 'alt_baremetal-introspection',
: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 { is_expected.not_to contain_keystone_user('ironic-inspector') }
it { is_expected.not_to contain_keystone_user_role('ironic-inspector@services') }
it { is_expected.to contain_keystone_service('ironic-inspector::baremetal-introspection').with(
:ensure => 'present',
:type => 'baremetal-introspection',
:description => 'Bare Metal Introspection Service'
it { is_expected.to contain_keystone__resource__service_identity('alt_ironic-inspector').with(
:configure_user => false,
:configure_user_role => false,
:configure_endpoint => false,
:service_name => 'alt_service',
:service_type => 'alt_baremetal-introspection',
:service_description => 'Alternative Bare Metal Introspection Service',
:region => 'RegionTwo',
:password => 'ironic-inspector_password',
:email => 'alt_ironic-inspector@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
@ -157,11 +86,10 @@ describe 'ironic::keystone::auth_inspector' do
}).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 'ironic keystone auth inspector'
it_behaves_like 'ironic::keystone::auth_inspector'
end
end
end

View File

@ -21,146 +21,68 @@
require 'spec_helper'
describe 'ironic::keystone::auth' do
shared_examples_for 'ironic::keystone::auth' do
context 'with default class parameters' do
let :params do
{ :password => 'ironic_password' }
end
shared_examples_for 'ironic keystone auth' do
it { is_expected.to contain_keystone__resource__service_identity('ironic').with(
:configure_user => true,
:configure_user_role => true,
:configure_endpoint => true,
:service_name => 'ironic',
:service_type => 'baremetal',
:service_description => 'Ironic Bare Metal Provisioning Service',
:region => 'RegionOne',
:auth_name => 'ironic',
:password => 'ironic_password',
:email => 'ironic@localhost',
:tenant => 'services',
:roles => ['admin'],
:public_url => 'http://127.0.0.1:6385',
:internal_url => 'http://127.0.0.1:6385',
:admin_url => 'http://127.0.0.1:6385',
) }
end
describe 'with default class parameters' do
context 'when overriding parameters' do
let :params do
{ :password => 'ironic_password',
:tenant => 'foobar' }
end
it { is_expected.to contain_keystone_user('ironic').with(
:ensure => 'present',
:password => 'ironic_password',
) }
it { is_expected.to contain_keystone_user_role('ironic@foobar').with(
:ensure => 'present',
:roles => ['admin']
)}
it { is_expected.to contain_keystone_service('ironic::baremetal').with(
:ensure => 'present',
:description => 'Ironic Bare Metal Provisioning Service'
) }
it { is_expected.to contain_keystone_endpoint('RegionOne/ironic::baremetal').with(
:ensure => 'present',
:public_url => "http://127.0.0.1:6385",
:admin_url => "http://127.0.0.1:6385",
:internal_url => "http://127.0.0.1:6385"
) }
end
describe 'when configuring ironic-server' do
let :pre_condition do
"class { 'ironic::server': auth_password => 'test' }"
end
let :params do
{ :password => 'ironic_password',
:tenant => 'foobar' }
end
#FIXME it { should contain_keystone_endpoint('RegionOne/ironic').with_notify('Service[ironic-server]') }
end
describe 'with overrided roles' do
let :params do
{ :password => 'ironic_password',
:roles => ['admin', 'service']}
end
it { is_expected.to contain_keystone_user_role('ironic@services').with(
:ensure => 'present',
:roles => ['admin', 'service']
)}
end
describe 'with endpoint parameters' do
let :params do
{ :password => 'ironic_password',
:public_url => 'https://10.0.0.10:6385',
:admin_url => 'https://10.0.0.11:6385',
:internal_url => 'https://10.0.0.11:6385' }
end
it { is_expected.to contain_keystone_endpoint('RegionOne/ironic::baremetal').with(
:ensure => 'present',
:public_url => 'https://10.0.0.10:6385',
:admin_url => 'https://10.0.0.11:6385',
:internal_url => 'https://10.0.0.11:6385'
) }
end
describe 'when overriding auth name' do
let :params do
{ :password => 'foo',
:auth_name => 'ironicy' }
end
it { is_expected.to contain_keystone_user('ironicy') }
it { is_expected.to contain_keystone_user_role('ironicy@services') }
it { is_expected.to contain_keystone_service('ironic::baremetal') }
it { is_expected.to contain_keystone_endpoint('RegionOne/ironic::baremetal') }
end
describe 'when overriding service name' do
let :params do
{
:service_name => 'ironic_service',
:password => 'ironic_password',
}
end
it { is_expected.to contain_keystone_user('ironic') }
it { is_expected.to contain_keystone_user_role('ironic@services') }
it { is_expected.to contain_keystone_service('ironic_service::baremetal') }
it { is_expected.to contain_keystone_endpoint('RegionOne/ironic_service::baremetal') }
end
describe 'when disabling user configuration' do
let :params do
{
:password => 'ironic_password',
:configure_user => false
}
end
it { is_expected.not_to contain_keystone_user('ironic') }
it { is_expected.to contain_keystone_user_role('ironic@services') }
it { is_expected.to contain_keystone_service('ironic::baremetal').with(
:ensure => 'present',
:description => 'Ironic Bare Metal Provisioning Service'
) }
end
describe 'when disabling user and user role configuration' do
let :params do
{
:password => 'ironic_password',
:auth_name => 'alt_ironic',
:email => 'alt_ironic@alt_localhost',
:tenant => 'alt_service',
:roles => ['admin', 'service'],
:configure_endpoint => false,
:configure_user => false,
:configure_user_role => false
}
:configure_user_role => false,
:service_description => 'Alternative Ironic Bare Metal Provisioning Service',
:service_name => 'alt_service',
:service_type => 'alt_baremetal',
: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 { is_expected.not_to contain_keystone_user('ironic') }
it { is_expected.not_to contain_keystone_user_role('ironic@services') }
it { is_expected.to contain_keystone_service('ironic::baremetal').with(
:ensure => 'present',
:description => 'Ironic Bare Metal Provisioning Service'
it { is_expected.to contain_keystone__resource__service_identity('ironic').with(
:configure_user => false,
:configure_user_role => false,
:configure_endpoint => false,
:service_name => 'alt_service',
:service_type => 'alt_baremetal',
:service_description => 'Alternative Ironic Bare Metal Provisioning Service',
:region => 'RegionTwo',
:auth_name => 'alt_ironic',
:password => 'ironic_password',
:email => 'alt_ironic@alt_localhost',
:tenant => 'alt_service',
:roles => ['admin', '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
on_supported_os({
@ -168,11 +90,10 @@ describe 'ironic::keystone::auth' do
}).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 'ironic keystone auth'
it_behaves_like 'ironic::keystone::auth'
end
end
end