mirror of
https://github.com/inspec/inspec
synced 2024-11-10 15:14:23 +00:00
Fix postgres_session error Unable to connect to database
Signed-off-by: Vasu1105 <vasundhara.jagdale@chef.io>
This commit is contained in:
parent
d85bdbc4e1
commit
d1bc86a214
2 changed files with 1 additions and 8 deletions
|
@ -46,8 +46,6 @@ module Inspec::Resources
|
|||
@host = host || "localhost"
|
||||
@port = port || 5432
|
||||
raise Inspec::Exceptions::ResourceFailed, "Can't run PostgreSQL SQL checks without authentication." if @user.nil? || @pass.nil?
|
||||
|
||||
test_connection
|
||||
end
|
||||
|
||||
def query(query, db = [])
|
||||
|
@ -65,10 +63,6 @@ module Inspec::Resources
|
|||
|
||||
private
|
||||
|
||||
def test_connection
|
||||
query("select now()\;")
|
||||
end
|
||||
|
||||
def escaped_query(query)
|
||||
Shellwords.escape(query)
|
||||
end
|
||||
|
|
|
@ -35,7 +35,6 @@ describe "Inspec::Resources::PostgresSession" do
|
|||
end
|
||||
it "fails when no connection established" do
|
||||
resource = load_resource("postgres_session", "postgres", "postgres", "localhost", 5432)
|
||||
_(resource.resource_failed?).must_equal true
|
||||
_(resource.resource_exception_message).must_include "PostgreSQL query with errors"
|
||||
_(proc { resource.send(:query, "Select 5;", ["mydatabase"]) }).must_raise Inspec::Exceptions::ResourceFailed
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue