Convert spec testing to use rspec-puppet-facts
Change-Id: I2f385c42020c7ae862d2385a807f9a1c7fb8dc68
This commit is contained in:
parent
489c57a567
commit
436a89e216
|
@ -20,116 +20,130 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'barbican::keystone::auth' do
|
||||
shared_examples 'barbican::keystone::auth' do
|
||||
context 'with default class parameters' do
|
||||
let :params do
|
||||
{
|
||||
:password => 'barbican_password',
|
||||
:tenant => 'foobar'
|
||||
}
|
||||
end
|
||||
|
||||
let :facts do
|
||||
@default_facts.merge({ :osfamily => 'Debian' })
|
||||
end
|
||||
it { should contain_keystone_user('barbican').with(
|
||||
:ensure => 'present',
|
||||
:password => 'barbican_password',
|
||||
)}
|
||||
|
||||
describe 'with default class parameters' do
|
||||
let :params do
|
||||
{ :password => 'barbican_password',
|
||||
:tenant => 'foobar' }
|
||||
it { should contain_keystone_user_role('barbican@foobar').with(
|
||||
:ensure => 'present',
|
||||
:roles => ['admin']
|
||||
)}
|
||||
|
||||
it { should contain_keystone_service('barbican::key-manager').with(
|
||||
:ensure => 'present',
|
||||
:description => 'Key management Service'
|
||||
)}
|
||||
|
||||
it { should contain_keystone_endpoint('RegionOne/barbican::key-manager').with(
|
||||
:ensure => 'present',
|
||||
:public_url => 'http://127.0.0.1:9311',
|
||||
:admin_url => 'http://127.0.0.1:9311',
|
||||
:internal_url => 'http://127.0.0.1:9311',
|
||||
)}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_keystone_user('barbican').with(
|
||||
:ensure => 'present',
|
||||
:password => 'barbican_password',
|
||||
) }
|
||||
context 'when overriding URL parameters' do
|
||||
let :params do
|
||||
{
|
||||
:password => 'barbican_password',
|
||||
: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.to contain_keystone_user_role('barbican@foobar').with(
|
||||
:ensure => 'present',
|
||||
:roles => ['admin']
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_keystone_service('barbican::key-manager').with(
|
||||
:ensure => 'present',
|
||||
:description => 'Key management Service'
|
||||
) }
|
||||
|
||||
it { is_expected.to contain_keystone_endpoint('RegionOne/barbican::key-manager').with(
|
||||
:ensure => 'present',
|
||||
:public_url => 'http://127.0.0.1:9311',
|
||||
:admin_url => 'http://127.0.0.1:9311',
|
||||
:internal_url => 'http://127.0.0.1:9311',
|
||||
) }
|
||||
end
|
||||
|
||||
describe 'when overriding URL parameters' do
|
||||
let :params do
|
||||
{ :password => 'barbican_password',
|
||||
it { should contain_keystone_endpoint('RegionOne/barbican::key-manager').with(
|
||||
:ensure => 'present',
|
||||
:public_url => 'https://10.10.10.10:80',
|
||||
:internal_url => 'http://10.10.10.11:81',
|
||||
:admin_url => 'http://10.10.10.12:81' }
|
||||
:admin_url => 'http://10.10.10.12:81'
|
||||
)}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_keystone_endpoint('RegionOne/barbican::key-manager').with(
|
||||
:ensure => 'present',
|
||||
: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
|
||||
context 'when overriding auth name' do
|
||||
let :params do
|
||||
{
|
||||
:password => 'foo',
|
||||
:auth_name => 'barbicany'
|
||||
}
|
||||
end
|
||||
|
||||
describe 'when overriding auth name' do
|
||||
let :params do
|
||||
{ :password => 'foo',
|
||||
:auth_name => 'barbicany' }
|
||||
it { should contain_keystone_user('barbicany') }
|
||||
it { should contain_keystone_user_role('barbicany@services') }
|
||||
it { should contain_keystone_service('barbican::key-manager') }
|
||||
it { should contain_keystone_endpoint('RegionOne/barbican::key-manager') }
|
||||
end
|
||||
|
||||
it { is_expected.to contain_keystone_user('barbicany') }
|
||||
it { is_expected.to contain_keystone_user_role('barbicany@services') }
|
||||
it { is_expected.to contain_keystone_service('barbican::key-manager') }
|
||||
it { is_expected.to contain_keystone_endpoint('RegionOne/barbican::key-manager') }
|
||||
end
|
||||
context 'when overriding service name' do
|
||||
let :params do
|
||||
{
|
||||
:service_name => 'barbican_service',
|
||||
:auth_name => 'barbican',
|
||||
:password => 'barbican_password'
|
||||
}
|
||||
end
|
||||
|
||||
describe 'when overriding service name' do
|
||||
let :params do
|
||||
{ :service_name => 'barbican_service',
|
||||
:auth_name => 'barbican',
|
||||
:password => 'barbican_password' }
|
||||
it { should contain_keystone_user('barbican') }
|
||||
it { should contain_keystone_user_role('barbican@services') }
|
||||
it { should contain_keystone_service('barbican_service::key-manager') }
|
||||
it { should contain_keystone_endpoint('RegionOne/barbican_service::key-manager') }
|
||||
end
|
||||
|
||||
it { is_expected.to contain_keystone_user('barbican') }
|
||||
it { is_expected.to contain_keystone_user_role('barbican@services') }
|
||||
it { is_expected.to contain_keystone_service('barbican_service::key-manager') }
|
||||
it { is_expected.to contain_keystone_endpoint('RegionOne/barbican_service::key-manager') }
|
||||
end
|
||||
context 'when disabling user configuration' do
|
||||
let :params do
|
||||
{
|
||||
:password => 'barbican_password',
|
||||
:configure_user => false
|
||||
}
|
||||
end
|
||||
|
||||
describe 'when disabling user configuration' do
|
||||
it { should_not contain_keystone_user('barbican') }
|
||||
it { should contain_keystone_user_role('barbican@services') }
|
||||
|
||||
let :params do
|
||||
{
|
||||
:password => 'barbican_password',
|
||||
:configure_user => false
|
||||
}
|
||||
it { should contain_keystone_service('barbican::key-manager').with(
|
||||
:ensure => 'present',
|
||||
:description => 'Key management Service'
|
||||
)}
|
||||
end
|
||||
|
||||
it { is_expected.not_to contain_keystone_user('barbican') }
|
||||
it { is_expected.to contain_keystone_user_role('barbican@services') }
|
||||
it { is_expected.to contain_keystone_service('barbican::key-manager').with(
|
||||
:ensure => 'present',
|
||||
:description => 'Key management Service'
|
||||
) }
|
||||
context 'when disabling user and user role configuration' do
|
||||
let :params do
|
||||
{
|
||||
:password => 'barbican_password',
|
||||
:configure_user => false,
|
||||
:configure_user_role => false
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
it { should_not contain_keystone_user('barbican') }
|
||||
it { should_not contain_keystone_user_role('barbican@services') }
|
||||
|
||||
describe 'when disabling user and user role configuration' do
|
||||
|
||||
let :params do
|
||||
{
|
||||
:password => 'barbican_password',
|
||||
:configure_user => false,
|
||||
:configure_user_role => false
|
||||
}
|
||||
it { should contain_keystone_service('barbican::key-manager').with(
|
||||
:ensure => 'present',
|
||||
:description => 'Key management Service'
|
||||
)}
|
||||
end
|
||||
|
||||
it { is_expected.not_to contain_keystone_user('barbican') }
|
||||
it { is_expected.not_to contain_keystone_user_role('barbican@services') }
|
||||
it { is_expected.to contain_keystone_service('barbican::key-manager').with(
|
||||
:ensure => 'present',
|
||||
:description => 'Key management Service'
|
||||
) }
|
||||
|
||||
end
|
||||
|
||||
on_supported_os({
|
||||
:supported_os => OSDefaults.get_supported_os
|
||||
}).each do |os,facts|
|
||||
context "on #{os}" do
|
||||
let (:facts) do
|
||||
facts.merge!(OSDefaults.get_facts())
|
||||
end
|
||||
|
||||
it_behaves_like 'barbican::keystone::auth'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,86 +20,76 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'barbican::plugins::dogtag' do
|
||||
|
||||
let :facts do
|
||||
@default_facts.merge(
|
||||
{
|
||||
:osfamily => 'RedHat',
|
||||
:os_workers => '7',
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
let :default_params do
|
||||
{
|
||||
:dogtag_plugin_ensure_package => 'present',
|
||||
:dogtag_plugin_pem_path => '<SERVICE DEFAULT>',
|
||||
:dogtag_plugin_dogtag_host => '<SERVICE DEFAULT>',
|
||||
:dogtag_plugin_dogtag_port => '<SERVICE DEFAULT>',
|
||||
:dogtag_plugin_nss_db_path => '<SERVICE DEFAULT>',
|
||||
:dogtag_plugin_simple_cmc_profile => '<SERVICE DEFAULT>',
|
||||
:dogtag_plugin_ca_expiration_time => '<SERVICE DEFAULT>',
|
||||
:dogtag_plugin_plugin_working_dir => '<SERVICE DEFAULT>',
|
||||
:global_default => false,
|
||||
:dogtag_plugin_ensure_package => 'present',
|
||||
:dogtag_plugin_pem_path => '<SERVICE DEFAULT>',
|
||||
:dogtag_plugin_dogtag_host => '<SERVICE DEFAULT>',
|
||||
:dogtag_plugin_dogtag_port => '<SERVICE DEFAULT>',
|
||||
:dogtag_plugin_nss_db_path => '<SERVICE DEFAULT>',
|
||||
:dogtag_plugin_simple_cmc_profile => '<SERVICE DEFAULT>',
|
||||
:dogtag_plugin_ca_expiration_time => '<SERVICE DEFAULT>',
|
||||
:dogtag_plugin_plugin_working_dir => '<SERVICE DEFAULT>',
|
||||
:global_default => false,
|
||||
}
|
||||
end
|
||||
|
||||
[{
|
||||
:dogtag_plugin_nss_password => 'password',
|
||||
},
|
||||
{
|
||||
:dogtag_plugin_pem_path => 'path_to_pem_file',
|
||||
:dogtag_plugin_dogtag_host => 'dogtag_host',
|
||||
:dogtag_plugin_dogtag_port => '1234',
|
||||
:dogtag_plugin_nss_db_path => 'path_to_nss_db',
|
||||
:dogtag_plugin_nss_password => 'password',
|
||||
:dogtag_plugin_simple_cmc_profile => 'caServerCert',
|
||||
:dogtag_plugin_ca_expiration_time => '100',
|
||||
:dogtag_plugin_plugin_working_dir => 'path_to_working_dir',
|
||||
:global_default => true,
|
||||
}
|
||||
].each do |param_set|
|
||||
shared_examples 'barbican::plugins::dogtag' do
|
||||
[{
|
||||
:dogtag_plugin_nss_password => 'password',
|
||||
},
|
||||
{
|
||||
:dogtag_plugin_pem_path => 'path_to_pem_file',
|
||||
:dogtag_plugin_dogtag_host => 'dogtag_host',
|
||||
:dogtag_plugin_dogtag_port => '1234',
|
||||
:dogtag_plugin_nss_db_path => 'path_to_nss_db',
|
||||
:dogtag_plugin_nss_password => 'password',
|
||||
:dogtag_plugin_simple_cmc_profile => 'caServerCert',
|
||||
:dogtag_plugin_ca_expiration_time => '100',
|
||||
:dogtag_plugin_plugin_working_dir => 'path_to_working_dir',
|
||||
:global_default => true,
|
||||
}
|
||||
].each do |param_set|
|
||||
context "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
|
||||
let :param_hash do
|
||||
default_params.merge(param_set)
|
||||
end
|
||||
|
||||
describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
|
||||
let :params do
|
||||
param_set
|
||||
end
|
||||
|
||||
let :param_hash do
|
||||
default_params.merge(param_set)
|
||||
end
|
||||
it { should contain_package('dogtag-client').with(
|
||||
:ensure => param_hash[:dogtag_plugin_ensure_package],
|
||||
:name => 'pki-base',
|
||||
:tag => ['openstack', 'barbican-package'],
|
||||
)}
|
||||
|
||||
let :params do
|
||||
param_set
|
||||
end
|
||||
|
||||
it { is_expected.to contain_package('dogtag-client').with(
|
||||
'ensure' => param_hash[:dogtag_plugin_ensure_package],
|
||||
'tag' => ['openstack', 'barbican-package'],
|
||||
) }
|
||||
|
||||
it 'is_expected.to set dogtag parameters' do
|
||||
is_expected.to contain_barbican_config('dogtag_plugin/pem_path')\
|
||||
.with_value(param_hash[:dogtag_plugin_pem_path])
|
||||
is_expected.to contain_barbican_config('dogtag_plugin/dogtag_host')\
|
||||
.with_value(param_hash[:dogtag_plugin_dogtag_host])
|
||||
is_expected.to contain_barbican_config('dogtag_plugin/dogtag_port')\
|
||||
.with_value(param_hash[:dogtag_plugin_dogtag_port])
|
||||
is_expected.to contain_barbican_config('dogtag_plugin/nss_db_path')\
|
||||
.with_value(param_hash[:dogtag_plugin_nss_db_path])
|
||||
is_expected.to contain_barbican_config('dogtag_plugin/nss_password')\
|
||||
.with_value(param_hash[:dogtag_plugin_nss_password]).with_secret(true)
|
||||
is_expected.to contain_barbican_config('dogtag_plugin/simple_cmc_profile')\
|
||||
.with_value(param_hash[:dogtag_plugin_simple_cmc_profile])
|
||||
is_expected.to contain_barbican_config('dogtag_plugin/ca_expiration_time')\
|
||||
.with_value(param_hash[:dogtag_plugin_ca_expiration_time])
|
||||
is_expected.to contain_barbican_config('dogtag_plugin/plugin_working_dir')\
|
||||
.with_value(param_hash[:dogtag_plugin_plugin_working_dir])
|
||||
is_expected.to contain_barbican_config(
|
||||
'secretstore:dogtag/secret_store_plugin') \
|
||||
.with_value('dogtag_plugin')
|
||||
is_expected.to contain_barbican_config(
|
||||
'secretstore:dogtag/global_default') \
|
||||
.with_value(param_hash[:global_default])
|
||||
it {
|
||||
should contain_barbican_config('dogtag_plugin/pem_path').with_value(param_hash[:dogtag_plugin_pem_path])
|
||||
should contain_barbican_config('dogtag_plugin/dogtag_host').with_value(param_hash[:dogtag_plugin_dogtag_host])
|
||||
should contain_barbican_config('dogtag_plugin/dogtag_port').with_value(param_hash[:dogtag_plugin_dogtag_port])
|
||||
should contain_barbican_config('dogtag_plugin/nss_db_path').with_value(param_hash[:dogtag_plugin_nss_db_path])
|
||||
should contain_barbican_config('dogtag_plugin/nss_password').with_value(param_hash[:dogtag_plugin_nss_password]).with_secret(true)
|
||||
should contain_barbican_config('dogtag_plugin/simple_cmc_profile').with_value(param_hash[:dogtag_plugin_simple_cmc_profile])
|
||||
should contain_barbican_config('dogtag_plugin/ca_expiration_time').with_value(param_hash[:dogtag_plugin_ca_expiration_time])
|
||||
should contain_barbican_config('dogtag_plugin/plugin_working_dir').with_value(param_hash[:dogtag_plugin_plugin_working_dir])
|
||||
should contain_barbican_config('secretstore:dogtag/secret_store_plugin').with_value('dogtag_plugin')
|
||||
should contain_barbican_config('secretstore:dogtag/global_default').with_value(param_hash[:global_default])
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
on_supported_os({
|
||||
:supported_os => OSDefaults.get_supported_os
|
||||
}).each do |os,facts|
|
||||
context "on #{os}" do
|
||||
let (:facts) do
|
||||
facts.merge!(OSDefaults.get_facts( :os_workers => '7' ))
|
||||
end
|
||||
|
||||
it_behaves_like 'barbican::plugins::dogtag'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue