Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Removed noisy test log #2583

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 17 additions & 22 deletions test/unit/util/obfuscate-sql.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const tests = require('../../lib/cross_agent_tests/sql_obfuscation/sql_obfuscati
const obfuscate = require('../../../lib/util/sql/obfuscate')

function runTest(t, testCase, dialect) {
t.diagnostic(dialect)
const obfuscated = obfuscate(testCase.sql, dialect)
if (testCase.obfuscated.length === 1) {
assert.equal(obfuscated, testCase.obfuscated[0])
Expand All @@ -19,28 +18,24 @@ function runTest(t, testCase, dialect) {
}
}

test('sql obfuscation', async (t) => {
await Promise.all(
tests.map(async (tc) => {
await t.test(tc.name, (t) => {
for (let i = 0; i < tc.dialects.length; ++i) {
runTest(t, tc, tc.dialects[i])
}
})
for (const testCase of tests) {
for (const dialect of testCase.dialects) {
test(`${dialect}: ${testCase.name}`, (t) => {
runTest(t, testCase, dialect)
})
)
}
}

await t.test('should handle line endings', () => {
const result = obfuscate('select * from foo where --abc\r\nbar=5', 'mysql')
assert.equal(result, 'select * from foo where ?\r\nbar=?')
})
test('should handle line endings', () => {
const result = obfuscate('select * from foo where --abc\r\nbar=5', 'mysql')
assert.equal(result, 'select * from foo where ?\r\nbar=?')
})

await t.test('should handle large JSON inserts', () => {
const JSONData = '{"data": "' + new Array(8400000).fill('a').join('') + '"}'
const result = obfuscate(
'INSERT INTO "Documents" ("data") VALUES (\'' + JSONData + "')",
'postgres'
)
assert.equal(result, 'INSERT INTO "Documents" ("data") VALUES (?)')
})
test('should handle large JSON inserts', () => {
const JSONData = '{"data": "' + new Array(8400000).fill('a').join('') + '"}'
const result = obfuscate(
'INSERT INTO "Documents" ("data") VALUES (\'' + JSONData + "')",
'postgres'
)
assert.equal(result, 'INSERT INTO "Documents" ("data") VALUES (?)')
})
Loading