mirror of
https://github.com/inspec/inspec
synced 2024-12-26 21:13:25 +00:00
1b58763aff
* fixed a small courner case in the error detection - error: vs error fixed resource to use 'shellwords' module to escape the query requested chances in method architecture for testing added unit tests Fixes: #1814 Signed-off-by: Aaron Lippold <lippold@gmail.com> * updated resource and tests with requested review changes Signed-off-by: Aaron Lippold <lippold@gmail.com> * removed unneeded call to `escaped_query` in the `create_sql_cmd`. Signed-off-by: Aaron Lippold <lippold@gmail.com> * removed license info Signed-off-by: Aaron Lippold <lippold@gmail.com>
15 lines
846 B
Ruby
15 lines
846 B
Ruby
# encoding: utf-8
|
|
# author: Aaron Lippold
|
|
|
|
require 'helper'
|
|
|
|
describe 'Inspec::Resources::PostgresSession' do
|
|
it 'verify postgres_session create_psql_cmd with a basic query' do
|
|
resource = load_resource('postgres_session','myuser','mypass','127.0.0.1')
|
|
_(resource.send(:create_psql_cmd,"SELECT * FROM STUDENTS;",['testdb']).must_equal "PGPASSWORD='mypass' psql -U myuser -d testdb -h 127.0.0.1 -A -t -c SELECT\\ \\*\\ FROM\\ STUDENTS\\;")
|
|
end
|
|
it 'verify postgres_session escaped_query with a complex query' do
|
|
resource = load_resource('postgres_session','myuser','mypass','127.0.0.1')
|
|
_(resource.send(:create_psql_cmd,"SELECT current_setting('client_min_messages')",['testdb']).must_equal "PGPASSWORD='mypass' psql -U myuser -d testdb -h 127.0.0.1 -A -t -c SELECT\\ current_setting\\(\\'client_min_messages\\'\\)")
|
|
end
|
|
end
|