@@ -85,6 +85,24 @@ class { 'mongodb::globals':
8585 end
8686
8787 describe 'installation using authentication' do
88+ after :all do
89+ pp = <<-EOS
90+ class { 'mongodb::globals':
91+ #{ repo_ver_param }
92+ }
93+ -> class { 'mongodb::server':
94+ ensure => absent,
95+ package_ensure => purged,
96+ service_ensure => stopped
97+ }
98+ -> class { 'mongodb::client':
99+ ensure => purged
100+ }
101+ EOS
102+
103+ apply_manifest ( pp , catch_failures : true )
104+ end
105+
88106 it 'works with no errors' do
89107 pp = <<-EOS
90108 class { 'mongodb::globals':
@@ -154,6 +172,67 @@ class { 'mongodb::globals':
154172 end
155173 end
156174
175+ describe 'installation using authentication with complex password' do
176+ it 'works with no errors' do
177+ pp = <<-EOS
178+ class { 'mongodb::globals':
179+ #{ repo_ver_param }
180+ }
181+ -> class { 'mongodb::server':
182+ auth => true,
183+ create_admin => true,
184+ handle_creds => true,
185+ store_creds => true,
186+ admin_username => 'admin',
187+ admin_password => 'admin_\\ \\ _\\ '_"_&_password',
188+ restart => true,
189+ }
190+ class { 'mongodb::client': }
191+ EOS
192+
193+ apply_manifest ( pp , catch_failures : true )
194+ apply_manifest ( pp , catch_changes : true )
195+ end
196+
197+ describe package ( package_name ) do
198+ it { is_expected . to be_installed }
199+ end
200+
201+ describe file ( config_file ) do
202+ it { is_expected . to be_file }
203+ end
204+
205+ describe service ( service_name ) do
206+ it { is_expected . to be_enabled }
207+ it { is_expected . to be_running }
208+ end
209+
210+ describe port ( 27_017 ) do
211+ it { is_expected . to be_listening }
212+ end
213+
214+ describe command ( 'mongosh --quiet --eval "db.serverCmdLineOpts().ok"' ) do
215+ its ( :stderr ) { is_expected . to match %r{requires authentication} }
216+ end
217+
218+ describe file ( '/root/.mongoshrc.js' ) do
219+ it { is_expected . to be_file }
220+ it { is_expected . to be_owned_by 'root' }
221+ it { is_expected . to be_grouped_into 'root' }
222+ it { is_expected . to be_mode 600 }
223+ it { is_expected . to contain 'admin.auth(\'admin\', \'admin_\\\\_\\\'_"_&_password\')' }
224+ end
225+
226+ describe command ( "mongosh admin --quiet --eval \" load('/root/.mongoshrc.js');EJSON.stringify(db.getUser('admin')['customData'])\" " ) do
227+ its ( :exit_status ) { is_expected . to eq 0 }
228+ its ( :stdout ) { is_expected . to match "{\" createdBy\" :\" Puppet Mongodb_user['User admin on db admin']\" }\n " }
229+ end
230+
231+ describe command ( 'mongod --version' ) do
232+ its ( :exit_status ) { is_expected . to eq 0 }
233+ end
234+ end
235+
157236 describe 'uninstallation' do
158237 it 'uninstalls mongodb' do
159238 pp = <<-EOS
0 commit comments