Merge "Update allowed_hosts conditional statement"
This commit is contained in:
commit
c38d00ab06
@ -25,9 +25,18 @@ class glance::db::mysql(
|
||||
require => Class['mysql::config'],
|
||||
}
|
||||
|
||||
if $allowed_hosts {
|
||||
# Check allowed_hosts to avoid duplicate resource declarations
|
||||
# If $host in $allowed_hosts, then remove it
|
||||
if is_array($allowed_hosts) and delete($allowed_hosts,$host) != [] {
|
||||
$real_allowed_hosts = delete($allowed_hosts,$host)
|
||||
# If $host = $allowed_hosts, then set it to undef
|
||||
} elsif is_string($allowed_hosts) and ($allowed_hosts != $host) {
|
||||
$real_allowed_hosts = $allowed_hosts
|
||||
}
|
||||
|
||||
if $real_allowed_hosts {
|
||||
# TODO this class should be in the mysql namespace
|
||||
glance::db::mysql::host_access { $allowed_hosts:
|
||||
glance::db::mysql::host_access { $real_allowed_hosts:
|
||||
user => $user,
|
||||
password => $password,
|
||||
database => $dbname,
|
||||
|
@ -33,7 +33,7 @@ describe 'glance::db::mysql' do
|
||||
{
|
||||
:password => 'glancepass2',
|
||||
:dbname => 'glancedb2',
|
||||
:charset => 'utf8'
|
||||
:charset => 'utf8',
|
||||
}
|
||||
end
|
||||
|
||||
@ -44,4 +44,58 @@ describe 'glance::db::mysql' do
|
||||
|
||||
end
|
||||
|
||||
describe "overriding allowed_hosts param to array" do
|
||||
let :params do
|
||||
{
|
||||
:password => 'glancepass2',
|
||||
:dbname => 'glancedb2',
|
||||
:allowed_hosts => ['127.0.0.1','%']
|
||||
}
|
||||
end
|
||||
|
||||
it {should_not contain_glance__db__mysql__host_access("127.0.0.1").with(
|
||||
:user => 'glance',
|
||||
:password => 'glancepass2',
|
||||
:database => 'glancedb2'
|
||||
)}
|
||||
it {should contain_glance__db__mysql__host_access("%").with(
|
||||
:user => 'glance',
|
||||
:password => 'glancepass2',
|
||||
:database => 'glancedb2'
|
||||
)}
|
||||
|
||||
end
|
||||
|
||||
describe "overriding allowed_hosts param to string" do
|
||||
let :params do
|
||||
{
|
||||
:password => 'glancepass2',
|
||||
:dbname => 'glancedb2',
|
||||
:allowed_hosts => '192.168.1.1'
|
||||
}
|
||||
end
|
||||
|
||||
it {should contain_glance__db__mysql__host_access("192.168.1.1").with(
|
||||
:user => 'glance',
|
||||
:password => 'glancepass2',
|
||||
:database => 'glancedb2'
|
||||
)}
|
||||
end
|
||||
|
||||
describe "overriding allowed_hosts param equals to host param " do
|
||||
let :params do
|
||||
{
|
||||
:password => 'glancepass2',
|
||||
:dbname => 'glancedb2',
|
||||
:allowed_hosts => '127.0.0.1'
|
||||
}
|
||||
end
|
||||
|
||||
it {should_not contain_glance__db__mysql__host_access("127.0.0.1").with(
|
||||
:user => 'glance',
|
||||
:password => 'glancepass2',
|
||||
:database => 'glancedb2'
|
||||
)}
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user