3 describe 'os_database_connection' do
6 is_expected.to run.with_params('foo').\
7 and_raise_error(Puppet::ParseError, /Requires an hash/)
11 is_expected.to run.with_params(['foo']).\
12 and_raise_error(Puppet::ParseError, /Requires an hash/)
15 it 'refuses without at least one argument' do
16 is_expected.to run.with_params().\
17 and_raise_error(Puppet::ParseError, /Wrong number of arguments/)
20 it 'refuses too many arguments' do
21 is_expected.to run.with_params('foo', 'bar').\
22 and_raise_error(Puppet::ParseError, /Wrong number of arguments/)
25 it 'fails if port is provided with missing host' do
26 is_expected.to run.with_params({
27 'dialect' => 'sqlite',
28 'database' => '/var/lib/keystone/keystone.db',
31 }).and_raise_error(Puppet::ParseError, /host is required with port/)
34 context 'creates the correct connection URI' do
36 it 'with all parameters' do
37 is_expected.to run.with_params({
39 'host' => '127.0.0.1',
42 'username' => 'guest',
43 'password' => 's3cr3t',
45 }).and_return('mysql://guest:s3cr3t@127.0.0.1:3306/test?charset=utf-8')
49 is_expected.to run.with_params({
51 'host' => '127.0.0.1',
53 'username' => 'guest',
54 'password' => 's3cr3t',
56 }).and_return('mysql://guest:s3cr3t@127.0.0.1/test?charset=utf-8')
59 it 'without host and port' do
60 is_expected.to run.with_params({
61 'dialect' => 'sqlite',
62 'database' => '/var/lib/keystone/keystone.db',
64 }).and_return('sqlite:////var/lib/keystone/keystone.db?charset=utf-8')
67 it 'without username and password' do
68 is_expected.to run.with_params({
70 'host' => '127.0.0.1',
74 }).and_return('mysql://127.0.0.1:3306/test?charset=utf-8')
77 it 'with username set to undef' do
78 is_expected.to run.with_params({
80 'host' => '127.0.0.1',
85 }).and_return('mysql://127.0.0.1:3306/test?charset=utf-8')
88 it 'with username set to an empty string' do
89 is_expected.to run.with_params({
91 'host' => '127.0.0.1',
96 }).and_return('mysql://127.0.0.1:3306/test?charset=utf-8')
99 it 'without password' do
100 is_expected.to run.with_params({
101 'dialect' => 'mysql',
102 'host' => '127.0.0.1',
104 'database' => 'test',
105 'username' => 'guest',
107 }).and_return('mysql://guest@127.0.0.1:3306/test?charset=utf-8')
110 it 'with password set to undef' do
111 is_expected.to run.with_params({
112 'dialect' => 'mysql',
113 'host' => '127.0.0.1',
115 'database' => 'test',
116 'username' => 'guest',
117 'password' => :undef,
119 }).and_return('mysql://guest@127.0.0.1:3306/test?charset=utf-8')
122 it 'with password set to an empty string' do
123 is_expected.to run.with_params({
124 'dialect' => 'mysql',
125 'host' => '127.0.0.1',
127 'database' => 'test',
128 'username' => 'guest',
131 }).and_return('mysql://guest@127.0.0.1:3306/test?charset=utf-8')