Skip to content

Commit

Permalink
Add marginalia-style comment to obfuscation test
Browse files Browse the repository at this point in the history
  • Loading branch information
kaylareopelle committed Sep 19, 2023
1 parent c694e55 commit c28e297
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions helpers/sql-obfuscation/test/helpers/sql_obfuscation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@
end
end

describe 'when sql has marginalia-style prepended comments' do
let(:sql) do
'/*application:web,controller:blob,action:show,correlation_id:01EZVMR923313VV44ZJDJ7PMEZ,' \
'endpoint_id:Projects::BlobController#show*/ SELECT "routes".* FROM "routes" WHERE "routes"' \
'."source_id" = 75 AND "routes"."source_type" = \'Namespace\' LIMIT 1'
end

let(:expected) { '? SELECT ?.* FROM ? WHERE ?.? = ? AND ?.? = ? LIMIT ?' }

it 'obfuscates the comment' do
assert_equal(expected, obfuscate_sql)
end
end

describe 'when sql exceeds obfuscation_limit' do
let(:obfuscation_limit) { 42 }
let(:expected) { "SELECT * from users where users.id = ...\nSQL truncated (> #{obfuscation_limit} characters)" }
Expand Down

0 comments on commit c28e297

Please sign in to comment.