forked from rapid7/metasploit-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PostgreSQL multi-line query transform tests
- Loading branch information
1 parent
1fe448f
commit 73dbe2e
Showing
2 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
spec/lib/rex/post/postgresql/ui/console/command_dispatcher/client_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
require 'rex/post/postgresql' | ||
|
||
RSpec.describe Rex::Post::PostgreSQL::Ui::Console::CommandDispatcher::Client do | ||
let (:client) { described_class.new(nil) } | ||
|
||
before(:each) do | ||
allow(client).to receive(:process_query).and_call_original | ||
end | ||
|
||
describe '.process_query' do | ||
[ | ||
{ query: "SELECT \\\nVERSION();", result: 'SELECT VERSION();' }, | ||
{ query: "SELECT \VERSION();", result: 'SELECT VERSION();' }, | ||
{ query: "SELECT * \\\nFROM dummy_table\\\nWHERE name='example_name'\\\n;", result: "SELECT * FROM dummy_table WHERE name='example_name' ;" }, | ||
{ query: "SELECT \\\n* FROM dummy_table\\\n WHERE name='example_name';\n", result: "SELECT * FROM dummy_table WHERE name='example_name';" }, | ||
{ query: "INSERT INTO dummy_table VALUES (\\\n'username' \\\n'password_!@£$%^&*()\\'\\\n);", result: "INSERT INTO dummy_table VALUES ( 'username' 'password_!@£$%^&*()\\' );" }, | ||
{ query: "DELETE\\\n FROM\\\n dummy_table\\\n WHERE\\\n field='\"\\'\\\n;", result: "DELETE FROM dummy_table WHERE field='\"\\' ;" }, | ||
{ query: "SELECT * FROM dummy_table WHERE field='example\\\nfield'", result: "SELECT * FROM dummy_table WHERE field='example field'" }, | ||
].each do |expected| | ||
it 'returns the expected value' do | ||
expect(client.process_query(query: expected[:query])).to eq(expected[:result]) | ||
end | ||
end | ||
end | ||
end |