2018-03-09 13:41:21 +00:00
|
|
|
require 'helper'
|
2019-05-25 08:33:26 +00:00
|
|
|
require 'inspec/resource'
|
|
|
|
require 'inspec/resources/mysql_session'
|
2018-03-09 13:41:21 +00:00
|
|
|
|
|
|
|
describe 'Inspec::Resources::MysqlSession' do
|
|
|
|
it 'verify mysql_session escaped login details with single quotes correctly' do
|
|
|
|
resource = load_resource('mysql_session',
|
|
|
|
'root',
|
|
|
|
%q{'%"'"&^*&()'*%})
|
|
|
|
_(resource.send(:create_mysql_cmd, 'SELECT 1 FROM DUAL;').must_equal(%q{mysql -uroot -p\'\%\"\'\"\&\^\*\&\(\)\'\*\% -h localhost -s -e "SELECT 1 FROM DUAL;"}))
|
|
|
|
end
|
|
|
|
it 'verify mysql_session omits optional username and password' do
|
|
|
|
resource = load_resource('mysql_session')
|
|
|
|
_(resource.send(:create_mysql_cmd, 'SELECT 1 FROM DUAL;').must_equal('mysql -h localhost -s -e "SELECT 1 FROM DUAL;"'))
|
|
|
|
end
|
|
|
|
end
|