Skip to content

Commit

Permalink
Merge pull request wvanbergen#4 from camilo/master
Browse files Browse the repository at this point in the history
Hiding password when inspecting
  • Loading branch information
Willem van Bergen committed Nov 11, 2011
2 parents c846e2e + 6b8f9a9 commit 25ae69d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/vertica/connection.rb
Expand Up @@ -129,6 +129,11 @@ def copy(sql, source = nil, &block)
end
return job.run
end

def inspect
safe_options = @options.reject{ |name, _| name == :password }
"#<Vertica::Connection:#{object_id} @parameters=#{@parameters.inspect} @backend_pid=#{@backend_pid}, @backend_key=#{@backend_key}, @transaction_status=#{@transaction_status}, @socket=#{@socket}, @options=#{safe_options.inspect}, @row_style=#{@row_style}>"
end

protected

Expand Down
6 changes: 6 additions & 0 deletions test/functional/connection_test.rb
Expand Up @@ -68,4 +68,10 @@ def test_new_with_error_response
Vertica::Connection.new(TEST_CONNECTION_HASH.merge('database' => 'nonexistant_db'))
end
end

def test_connection_inspect_should_not_print_password
@connection = Vertica::Connection.new(TEST_CONNECTION_HASH)
inspected_string = @connection.inspect
assert_no_match /:password=>#{TEST_CONNECTION_HASH[:password]}/, inspected_string
end
end

0 comments on commit 25ae69d

Please sign in to comment.