Cleanup, Improve coverage of swift::keystone::auth spec tests
Refactor with shared examples, improves coverage with 12 additional tests. Change-Id: Ie686af051f11941a88ea479b1d9187560f8140bb
This commit is contained in:
@@ -2,153 +2,122 @@ require 'spec_helper'
|
|||||||
|
|
||||||
describe 'swift::keystone::auth' do
|
describe 'swift::keystone::auth' do
|
||||||
|
|
||||||
describe 'with default class parameters' do
|
let :params do
|
||||||
|
{ }
|
||||||
|
end
|
||||||
|
|
||||||
it { should contain_keystone_user('swift').with(
|
let :default_params do
|
||||||
:ensure => 'present',
|
{
|
||||||
:password => 'swift_password'
|
:auth_name => 'swift',
|
||||||
) }
|
:password => 'swift_password',
|
||||||
|
:port => '8080',
|
||||||
|
:tenant => 'services',
|
||||||
|
:email => 'swift@localhost',
|
||||||
|
:region => 'RegionOne',
|
||||||
|
:operator_roles => ['admin', 'SwiftOperator'],
|
||||||
|
:public_protocol => 'http',
|
||||||
|
:public_address => '127.0.0.1',
|
||||||
|
:admin_protocol => 'http',
|
||||||
|
:admin_address => '127.0.0.1',
|
||||||
|
:internal_protocol => 'http',
|
||||||
|
:internal_address => '127.0.0.1',
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
it { should contain_keystone_user_role('swift@services').with(
|
shared_examples_for 'swift keystone auth' do
|
||||||
:ensure => 'present',
|
context 'with default class parameters' do
|
||||||
:roles => 'admin',
|
it_configures 'keystone auth configuration'
|
||||||
:require => 'Keystone_user[swift]'
|
|
||||||
)}
|
|
||||||
|
|
||||||
it { should contain_keystone_service('swift').with(
|
|
||||||
:ensure => 'present',
|
|
||||||
:type => 'object-store',
|
|
||||||
:description => 'Openstack Object-Store Service'
|
|
||||||
) }
|
|
||||||
|
|
||||||
it { should contain_keystone_endpoint('RegionOne/swift').with(
|
|
||||||
:ensure => 'present',
|
|
||||||
:public_url => "http://127.0.0.1:8080/v1/AUTH_%(tenant_id)s",
|
|
||||||
:admin_url => "http://127.0.0.1:8080/",
|
|
||||||
:internal_url => "http://127.0.0.1:8080/v1/AUTH_%(tenant_id)s"
|
|
||||||
) }
|
|
||||||
|
|
||||||
it { should contain_keystone_service('swift_s3').with(
|
|
||||||
:ensure => 'present',
|
|
||||||
:type => 's3',
|
|
||||||
:description => 'Openstack S3 Service'
|
|
||||||
) }
|
|
||||||
|
|
||||||
it { should contain_keystone_endpoint('RegionOne/swift_s3').with(
|
|
||||||
:ensure => 'present',
|
|
||||||
:public_url => 'http://127.0.0.1:8080',
|
|
||||||
:admin_url => 'http://127.0.0.1:8080',
|
|
||||||
:internal_url => 'http://127.0.0.1:8080'
|
|
||||||
) }
|
|
||||||
|
|
||||||
['admin', 'SwiftOperator'].each do |role_name|
|
['admin', 'SwiftOperator'].each do |role_name|
|
||||||
it { should contain_keystone_role(role_name).with_ensure('present') }
|
it { should contain_keystone_role(role_name).with_ensure('present') }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'overriding public_port public_protocol, admin_protocol and internal_protocol' do
|
context 'with custom class parameters' do
|
||||||
|
before do
|
||||||
let :params do
|
params.merge!({
|
||||||
{
|
:auth_name => 'object_store',
|
||||||
|
:password => 'passw0rd',
|
||||||
:port => '443',
|
:port => '443',
|
||||||
|
:tenant => 'admin',
|
||||||
|
:email => 'object_store@localhost',
|
||||||
|
:region => 'RegionTwo',
|
||||||
|
:operator_roles => ['admin', 'SwiftOperator', 'Gopher'],
|
||||||
:public_protocol => 'https',
|
:public_protocol => 'https',
|
||||||
|
:public_address => 'public.example.org',
|
||||||
|
:public_port => '443',
|
||||||
:admin_protocol => 'https',
|
:admin_protocol => 'https',
|
||||||
|
:admin_address => 'admin.example.org',
|
||||||
:internal_protocol => 'https',
|
:internal_protocol => 'https',
|
||||||
}
|
:internal_address => 'internal.example.org',
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
it { should contain_keystone_endpoint('RegionOne/swift').with(
|
it_configures 'keystone auth configuration'
|
||||||
|
|
||||||
|
['admin', 'SwiftOperator', 'Gopher'].each do |role_name|
|
||||||
|
it { should contain_keystone_role(role_name).with_ensure('present') }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
shared_examples_for 'keystone auth configuration' do
|
||||||
|
let :p do
|
||||||
|
default_params.merge( params )
|
||||||
|
end
|
||||||
|
|
||||||
|
it { should contain_keystone_user(p[:auth_name]).with(
|
||||||
:ensure => 'present',
|
:ensure => 'present',
|
||||||
:public_url => "https://127.0.0.1:443/v1/AUTH_%(tenant_id)s",
|
:password => p[:password],
|
||||||
:admin_url => "https://127.0.0.1:443/",
|
:email => p[:email]
|
||||||
:internal_url => "https://127.0.0.1:443/v1/AUTH_%(tenant_id)s"
|
)}
|
||||||
) }
|
|
||||||
|
|
||||||
it { should contain_keystone_endpoint('RegionOne/swift_s3').with(
|
it { should contain_keystone_user_role("#{p[:auth_name]}@#{p[:tenant]}").with(
|
||||||
:ensure => 'present',
|
:ensure => 'present',
|
||||||
:public_url => 'https://127.0.0.1:443',
|
:roles => 'admin',
|
||||||
:admin_url => 'https://127.0.0.1:443',
|
:require => "Keystone_user[#{p[:auth_name]}]"
|
||||||
:internal_url => 'https://127.0.0.1:443'
|
)}
|
||||||
) }
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'when overriding public_port, public address, admin_address and internal_address' do
|
it { should contain_keystone_service(p[:auth_name]).with(
|
||||||
|
|
||||||
let :params do
|
|
||||||
{
|
|
||||||
:public_port => '80',
|
|
||||||
:public_address => '10.10.10.10',
|
|
||||||
:admin_address => '10.10.10.2',
|
|
||||||
:internal_address => '127.0.0.1'
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
it { should contain_keystone_endpoint('RegionOne/swift').with(
|
|
||||||
:ensure => 'present',
|
:ensure => 'present',
|
||||||
:public_url => "http://10.10.10.10:80/v1/AUTH_%(tenant_id)s",
|
:type => 'object-store',
|
||||||
:admin_url => "http://10.10.10.2:8080/",
|
:description => 'Openstack Object-Store Service'
|
||||||
:internal_url => "http://127.0.0.1:8080/v1/AUTH_%(tenant_id)s"
|
)}
|
||||||
) }
|
|
||||||
|
|
||||||
it { should contain_keystone_endpoint('RegionOne/swift_s3').with(
|
it { should contain_keystone_endpoint("#{p[:region]}/#{p[:auth_name]}").with(
|
||||||
:ensure => 'present',
|
:ensure => 'present',
|
||||||
:public_url => 'http://10.10.10.10:80',
|
:public_url => "#{p[:public_protocol]}://#{p[:public_address]}:#{p[:port]}/v1/AUTH_%(tenant_id)s",
|
||||||
:admin_url => 'http://10.10.10.2:8080',
|
:admin_url => "#{p[:admin_protocol]}://#{p[:admin_address]}:#{p[:port]}/",
|
||||||
:internal_url => 'http://127.0.0.1:8080'
|
:internal_url => "#{p[:internal_protocol]}://#{p[:internal_address]}:#{p[:port]}/v1/AUTH_%(tenant_id)s"
|
||||||
) }
|
)}
|
||||||
|
|
||||||
|
it { should contain_keystone_service("#{p[:auth_name]}_s3").with(
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
describe 'when overriding password' do
|
|
||||||
|
|
||||||
let :params do
|
|
||||||
{
|
|
||||||
:password => 'foo'
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
it { should contain_keystone_user('swift').with(
|
|
||||||
:ensure => 'present',
|
:ensure => 'present',
|
||||||
:password => 'foo'
|
:type => 's3',
|
||||||
) }
|
:description => 'Openstack S3 Service'
|
||||||
|
)}
|
||||||
|
|
||||||
|
it { should contain_keystone_endpoint("#{p[:region]}/#{p[:auth_name]}_s3").with(
|
||||||
|
:ensure => 'present',
|
||||||
|
:public_url => "#{p[:public_protocol]}://#{p[:public_address]}:#{p[:port]}",
|
||||||
|
:admin_url => "#{p[:admin_protocol]}://#{p[:admin_address]}:#{p[:port]}",
|
||||||
|
:internal_url => "#{p[:internal_protocol]}://#{p[:internal_address]}:#{p[:port]}"
|
||||||
|
)}
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'when overriding auth name' do
|
context 'on Debian platforms' do
|
||||||
|
let :facts do
|
||||||
let :params do
|
{ :osfamily => 'Debian' }
|
||||||
{
|
|
||||||
:auth_name => 'swifty'
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it { should contain_keystone_user('swifty') }
|
it_configures 'swift keystone auth'
|
||||||
|
|
||||||
it { should contain_keystone_user_role('swifty@services') }
|
|
||||||
|
|
||||||
it { should contain_keystone_service('swifty') }
|
|
||||||
|
|
||||||
it { should contain_keystone_endpoint('RegionOne/swifty') }
|
|
||||||
|
|
||||||
it { should contain_keystone_service('swifty_s3') }
|
|
||||||
|
|
||||||
it { should contain_keystone_endpoint('RegionOne/swifty_s3') }
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'when overriding operator_roles' do
|
context 'on RedHat platforms' do
|
||||||
|
let :facts do
|
||||||
let :params do
|
{ :osfamily => 'RedHat' }
|
||||||
{
|
|
||||||
:operator_roles => 'foo',
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it { should contain_keystone_role('foo').with(
|
it_configures 'swift keystone auth'
|
||||||
:ensure => 'present'
|
|
||||||
) }
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@@ -1 +1,5 @@
|
|||||||
require 'puppetlabs_spec_helper/module_spec_helper'
|
require 'puppetlabs_spec_helper/module_spec_helper'
|
||||||
|
|
||||||
|
RSpec.configure do |c|
|
||||||
|
c.alias_it_should_behave_like_to :it_configures, 'configures'
|
||||||
|
end
|
||||||
|
Reference in New Issue
Block a user