Skip to content

Commit

Permalink
Add spec tests
Browse files Browse the repository at this point in the history
This commit adds spec tests for the changes made in the previous
commit.
  • Loading branch information
chelnak committed Aug 17, 2022
1 parent 66479fb commit b60b76c
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions spec/classes/mysql_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,46 @@
)
end
end

context 'with an invalid install_secret_file path' do
let(:params) { {} }

[
'|| ls -la ||',
'|| touch /tmp/foo.txt ||',
'/tmp/foo.txt;echo',
'myPath;',
'\\myPath\\',
'//myPath has spaces//',
'/',
'.secret_file',
].each do |path|
it do
params['install_secret_file'] = path
is_expected.to raise_error(Puppet::PreformattedError, %r{'#{Regexp.escape(path)}' is not a valid path.})
end
end
end
end

context 'with a valid install_secret_file path' do
let(:params) { {} }

[
'/tmp/foo.txt',
'/foo.txt',
'/.secret_file',
].each do |path|
it do
params['install_secret_file'] = path
is_expected.to contain_exec('remove install pass')
.with(
command: "mysqladmin -u root --password=$(grep -o \'[^ ]\\+$\' #{path}) password \'\' && rm -f #{path}",
onlyif: "test -f #{path}",
path: '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin',
)
end
end
end

context 'mysql::server::service' do
Expand Down

0 comments on commit b60b76c

Please sign in to comment.