Merge "Do not test authtoken parameters directly"

This commit is contained in:
Zuul 2021-09-08 01:44:27 +00:00 committed by Gerrit Code Review
commit 92705cb8d3
1 changed files with 117 additions and 118 deletions

View File

@ -6,136 +6,133 @@ describe 'octavia::keystone::authtoken' do
{ :password => 'octavia_password', } { :password => 'octavia_password', }
end end
shared_examples 'octavia authtoken' do shared_examples 'octavia::keystone::authtoken' do
context 'without required password parameter' do
before { params.delete(:password) }
it { expect { is_expected.to raise_error(Puppet::Error) } }
end
context 'with default parameters' do context 'with default parameters' do
it 'configure keystone_authtoken' do it 'configure keystone_authtoken' do
is_expected.to contain_octavia_config('keystone_authtoken/username').with_value('octavia') is_expected.to contain_keystone__resource__authtoken('octavia_config').with(
is_expected.to contain_octavia_config('keystone_authtoken/password').with_value('octavia_password') :username => 'octavia',
is_expected.to contain_octavia_config('keystone_authtoken/auth_url').with_value('http://localhost:5000') :password => 'octavia_password',
is_expected.to contain_octavia_config('keystone_authtoken/project_name').with_value('services') :auth_url => 'http://localhost:5000',
is_expected.to contain_octavia_config('keystone_authtoken/user_domain_name').with_value('Default') :project_name => 'services',
is_expected.to contain_octavia_config('keystone_authtoken/project_domain_name').with_value('Default') :user_domain_name => 'Default',
is_expected.to contain_octavia_config('keystone_authtoken/insecure').with_value('<SERVICE DEFAULT>') :project_domain_name => 'Default',
is_expected.to contain_octavia_config('keystone_authtoken/auth_section').with_value('<SERVICE DEFAULT>') :insecure => '<SERVICE DEFAULT>',
is_expected.to contain_octavia_config('keystone_authtoken/auth_type').with_value('password') :auth_section => '<SERVICE DEFAULT>',
is_expected.to contain_octavia_config('keystone_authtoken/www_authenticate_uri').with_value('http://localhost:5000') :auth_type => 'password',
is_expected.to contain_octavia_config('keystone_authtoken/auth_version').with_value('<SERVICE DEFAULT>') :www_authenticate_uri => 'http://localhost:5000',
is_expected.to contain_octavia_config('keystone_authtoken/cache').with_value('<SERVICE DEFAULT>') :auth_version => '<SERVICE DEFAULT>',
is_expected.to contain_octavia_config('keystone_authtoken/cafile').with_value('<SERVICE DEFAULT>') :cache => '<SERVICE DEFAULT>',
is_expected.to contain_octavia_config('keystone_authtoken/certfile').with_value('<SERVICE DEFAULT>') :cafile => '<SERVICE DEFAULT>',
is_expected.to contain_octavia_config('keystone_authtoken/delay_auth_decision').with_value('<SERVICE DEFAULT>') :certfile => '<SERVICE DEFAULT>',
is_expected.to contain_octavia_config('keystone_authtoken/enforce_token_bind').with_value('<SERVICE DEFAULT>') :delay_auth_decision => '<SERVICE DEFAULT>',
is_expected.to contain_octavia_config('keystone_authtoken/http_connect_timeout').with_value('<SERVICE DEFAULT>') :enforce_token_bind => '<SERVICE DEFAULT>',
is_expected.to contain_octavia_config('keystone_authtoken/http_request_max_retries').with_value('<SERVICE DEFAULT>') :http_connect_timeout => '<SERVICE DEFAULT>',
is_expected.to contain_octavia_config('keystone_authtoken/include_service_catalog').with_value('<SERVICE DEFAULT>') :http_request_max_retries => '<SERVICE DEFAULT>',
is_expected.to contain_octavia_config('keystone_authtoken/keyfile').with_value('<SERVICE DEFAULT>') :include_service_catalog => '<SERVICE DEFAULT>',
is_expected.to contain_octavia_config('keystone_authtoken/memcache_pool_conn_get_timeout').with_value('<SERVICE DEFAULT>') :keyfile => '<SERVICE DEFAULT>',
is_expected.to contain_octavia_config('keystone_authtoken/memcache_pool_dead_retry').with_value('<SERVICE DEFAULT>') :memcache_pool_conn_get_timeout => '<SERVICE DEFAULT>',
is_expected.to contain_octavia_config('keystone_authtoken/memcache_pool_maxsize').with_value('<SERVICE DEFAULT>') :memcache_pool_dead_retry => '<SERVICE DEFAULT>',
is_expected.to contain_octavia_config('keystone_authtoken/memcache_pool_socket_timeout').with_value('<SERVICE DEFAULT>') :memcache_pool_maxsize => '<SERVICE DEFAULT>',
is_expected.to contain_octavia_config('keystone_authtoken/memcache_pool_unused_timeout').with_value('<SERVICE DEFAULT>') :memcache_pool_socket_timeout => '<SERVICE DEFAULT>',
is_expected.to contain_octavia_config('keystone_authtoken/memcache_secret_key').with_value('<SERVICE DEFAULT>') :memcache_pool_unused_timeout => '<SERVICE DEFAULT>',
is_expected.to contain_octavia_config('keystone_authtoken/memcache_security_strategy').with_value('<SERVICE DEFAULT>') :memcache_secret_key => '<SERVICE DEFAULT>',
is_expected.to contain_octavia_config('keystone_authtoken/memcache_use_advanced_pool').with_value('<SERVICE DEFAULT>') :memcache_security_strategy => '<SERVICE DEFAULT>',
is_expected.to contain_octavia_config('keystone_authtoken/memcached_servers').with_value('<SERVICE DEFAULT>') :memcache_use_advanced_pool => '<SERVICE DEFAULT>',
is_expected.to contain_octavia_config('keystone_authtoken/region_name').with_value('<SERVICE DEFAULT>') :memcached_servers => '<SERVICE DEFAULT>',
is_expected.to contain_octavia_config('keystone_authtoken/token_cache_time').with_value('<SERVICE DEFAULT>') :manage_memcache_package => false,
is_expected.to contain_octavia_config('keystone_authtoken/service_token_roles').with_value('<SERVICE DEFAULT>') :region_name => '<SERVICE DEFAULT>',
is_expected.to contain_octavia_config('keystone_authtoken/service_token_roles_required').with_value('<SERVICE DEFAULT>') :token_cache_time => '<SERVICE DEFAULT>',
is_expected.to contain_octavia_config('keystone_authtoken/service_type').with_value('<SERVICE DEFAULT>') :service_token_roles => '<SERVICE DEFAULT>',
is_expected.to contain_octavia_config('keystone_authtoken/interface').with_value('<SERVICE DEFAULT>') :service_token_roles_required => '<SERVICE DEFAULT>',
:service_type => '<SERVICE DEFAULT>',
:interface => '<SERVICE DEFAULT>',
)
end end
end end
context 'when overriding parameters' do context 'when overriding parameters' do
before do before do
params.merge!({ params.merge!({
:www_authenticate_uri => 'https://10.0.0.1:9999/', :www_authenticate_uri => 'https://10.0.0.1:9999/',
:username => 'myuser', :username => 'myuser',
:password => 'mypasswd', :password => 'mypasswd',
:auth_url => 'https://127.0.0.1:5000', :auth_url => 'http://127.0.0.1:5000',
:project_name => 'service_project', :project_name => 'service_project',
:user_domain_name => 'domainX', :user_domain_name => 'domainX',
:project_domain_name => 'domainX', :project_domain_name => 'domainX',
:insecure => false, :insecure => false,
:auth_section => 'new_section', :auth_section => 'new_section',
:auth_type => 'password', :auth_type => 'password',
:auth_version => 'v3', :auth_version => 'v3',
:cache => 'somevalue', :cache => 'somevalue',
:cafile => '/opt/stack/data/cafile.pem', :cafile => '/opt/stack/data/cafile.pem',
:certfile => 'certfile.crt', :certfile => 'certfile.crt',
:delay_auth_decision => false, :delay_auth_decision => false,
:enforce_token_bind => 'permissive', :enforce_token_bind => 'permissive',
:http_connect_timeout => '300', :http_connect_timeout => '300',
:http_request_max_retries => '3', :http_request_max_retries => '3',
:include_service_catalog => true, :include_service_catalog => true,
:keyfile => 'keyfile', :keyfile => 'keyfile',
:memcache_pool_conn_get_timeout => '9', :memcache_pool_conn_get_timeout => '9',
:memcache_pool_dead_retry => '302', :memcache_pool_dead_retry => '302',
:memcache_pool_maxsize => '11', :memcache_pool_maxsize => '11',
:memcache_pool_socket_timeout => '2', :memcache_pool_socket_timeout => '2',
:memcache_pool_unused_timeout => '61', :memcache_pool_unused_timeout => '61',
:memcache_secret_key => 'secret_key', :memcache_secret_key => 'secret_key',
:memcache_security_strategy => 'ENCRYPT', :memcache_security_strategy => 'ENCRYPT',
:memcache_use_advanced_pool => true, :memcache_use_advanced_pool => true,
:memcached_servers => ['memcached01:11211','memcached02:11211'], :memcached_servers => ['memcached01:11211','memcached02:11211'],
:manage_memcache_package => true, :manage_memcache_package => true,
:region_name => 'region2', :region_name => 'region2',
:token_cache_time => '301', :token_cache_time => '301',
:service_token_roles => ['service'], :service_token_roles => ['service'],
:service_token_roles_required => false, :service_token_roles_required => false,
:service_type => 'identity', :service_type => 'identity',
:interface => 'internal', :interface => 'internal',
}) })
end end
it 'configure keystone_authtoken' do it 'configure keystone_authtoken' do
is_expected.to contain_octavia_config('keystone_authtoken/www_authenticate_uri').with_value('https://10.0.0.1:9999/') is_expected.to contain_keystone__resource__authtoken('octavia_config').with(
is_expected.to contain_octavia_config('keystone_authtoken/username').with_value(params[:username]) :www_authenticate_uri => 'https://10.0.0.1:9999/',
is_expected.to contain_octavia_config('keystone_authtoken/password').with_value(params[:password]).with_secret(true) :username => 'myuser',
is_expected.to contain_octavia_config('keystone_authtoken/auth_url').with_value(params[:auth_url]) :password => 'mypasswd',
is_expected.to contain_octavia_config('keystone_authtoken/project_name').with_value(params[:project_name]) :auth_url => 'http://127.0.0.1:5000',
is_expected.to contain_octavia_config('keystone_authtoken/user_domain_name').with_value(params[:user_domain_name]) :project_name => 'service_project',
is_expected.to contain_octavia_config('keystone_authtoken/project_domain_name').with_value(params[:project_domain_name]) :user_domain_name => 'domainX',
is_expected.to contain_octavia_config('keystone_authtoken/insecure').with_value(params[:insecure]) :project_domain_name => 'domainX',
is_expected.to contain_octavia_config('keystone_authtoken/auth_section').with_value(params[:auth_section]) :insecure => false,
is_expected.to contain_octavia_config('keystone_authtoken/auth_type').with_value(params[:auth_type]) :auth_section => 'new_section',
is_expected.to contain_octavia_config('keystone_authtoken/auth_version').with_value(params[:auth_version]) :auth_type => 'password',
is_expected.to contain_octavia_config('keystone_authtoken/cache').with_value(params[:cache]) :auth_version => 'v3',
is_expected.to contain_octavia_config('keystone_authtoken/cafile').with_value(params[:cafile]) :cache => 'somevalue',
is_expected.to contain_octavia_config('keystone_authtoken/certfile').with_value(params[:certfile]) :cafile => '/opt/stack/data/cafile.pem',
is_expected.to contain_octavia_config('keystone_authtoken/delay_auth_decision').with_value(params[:delay_auth_decision]) :certfile => 'certfile.crt',
is_expected.to contain_octavia_config('keystone_authtoken/enforce_token_bind').with_value(params[:enforce_token_bind]) :delay_auth_decision => false,
is_expected.to contain_octavia_config('keystone_authtoken/http_connect_timeout').with_value(params[:http_connect_timeout]) :enforce_token_bind => 'permissive',
is_expected.to contain_octavia_config('keystone_authtoken/http_request_max_retries').with_value(params[:http_request_max_retries]) :http_connect_timeout => '300',
is_expected.to contain_octavia_config('keystone_authtoken/include_service_catalog').with_value(params[:include_service_catalog]) :http_request_max_retries => '3',
is_expected.to contain_octavia_config('keystone_authtoken/keyfile').with_value(params[:keyfile]) :include_service_catalog => true,
is_expected.to contain_octavia_config('keystone_authtoken/memcache_pool_conn_get_timeout').with_value(params[:memcache_pool_conn_get_timeout]) :keyfile => 'keyfile',
is_expected.to contain_octavia_config('keystone_authtoken/memcache_pool_dead_retry').with_value(params[:memcache_pool_dead_retry]) :memcache_pool_conn_get_timeout => '9',
is_expected.to contain_octavia_config('keystone_authtoken/memcache_pool_maxsize').with_value(params[:memcache_pool_maxsize]) :memcache_pool_dead_retry => '302',
is_expected.to contain_octavia_config('keystone_authtoken/memcache_pool_socket_timeout').with_value(params[:memcache_pool_socket_timeout]) :memcache_pool_maxsize => '11',
is_expected.to contain_octavia_config('keystone_authtoken/memcache_pool_unused_timeout').with_value(params[:memcache_pool_unused_timeout]) :memcache_pool_socket_timeout => '2',
is_expected.to contain_octavia_config('keystone_authtoken/memcache_secret_key').with_value(params[:memcache_secret_key]) :memcache_pool_unused_timeout => '61',
is_expected.to contain_octavia_config('keystone_authtoken/memcache_security_strategy').with_value(params[:memcache_security_strategy]) :memcache_secret_key => 'secret_key',
is_expected.to contain_octavia_config('keystone_authtoken/memcache_use_advanced_pool').with_value(params[:memcache_use_advanced_pool]) :memcache_security_strategy => 'ENCRYPT',
is_expected.to contain_octavia_config('keystone_authtoken/memcached_servers').with_value('memcached01:11211,memcached02:11211') :memcache_use_advanced_pool => true,
is_expected.to contain_octavia_config('keystone_authtoken/region_name').with_value(params[:region_name]) :memcached_servers => ['memcached01:11211','memcached02:11211'],
is_expected.to contain_octavia_config('keystone_authtoken/token_cache_time').with_value(params[:token_cache_time]) :manage_memcache_package => true,
is_expected.to contain_octavia_config('keystone_authtoken/service_token_roles').with_value(params[:service_token_roles]) :region_name => 'region2',
is_expected.to contain_octavia_config('keystone_authtoken/service_token_roles_required').with_value(params[:service_token_roles_required]) :token_cache_time => '301',
is_expected.to contain_octavia_config('keystone_authtoken/service_type').with_value(params[:service_type]) :service_token_roles => ['service'],
is_expected.to contain_octavia_config('keystone_authtoken/interface').with_value(params[:interface]) :service_token_roles_required => false,
end :service_type => 'identity',
:interface => 'internal',
it 'installs python memcache package' do )
is_expected.to contain_package('python-memcache')
end end
end end
@ -148,7 +145,9 @@ describe 'octavia::keystone::authtoken' do
end end
it 'configure keystone_authtoken' do it 'configure keystone_authtoken' do
is_expected.to contain_octavia_config('keystone_authtoken/username').with_value(params[:params]['username']) is_expected.to contain_keystone__resource__authtoken('octavia_config').with(
:username => 'myotheruser',
)
end end
end end
end end
@ -161,7 +160,7 @@ describe 'octavia::keystone::authtoken' do
facts.merge!(OSDefaults.get_facts()) facts.merge!(OSDefaults.get_facts())
end end
it_configures 'octavia authtoken' it_configures 'octavia::keystone::authtoken'
end end
end end