mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
Add test for pgpass check function scope
This commit is contained in:
parent
0758b766aa
commit
1f0d3d567f
@ -1,21 +1,30 @@
|
||||
'use strict'
|
||||
|
||||
const helper = require('./test-helper')
|
||||
const createClient = require('./test-helper').createClient
|
||||
|
||||
/*
|
||||
* TODO: Add _some_ comments to explain what it is we're testing, and how the
|
||||
* code-being-tested works behind the scenes.
|
||||
*/
|
||||
|
||||
test('cleartext password authentication', function () {
|
||||
var client = createClient()
|
||||
client.password = '!'
|
||||
client.connection.stream.packets = []
|
||||
client.connection.emit('authenticationCleartextPassword')
|
||||
test('responds with password', function () {
|
||||
var client = createClient()
|
||||
client.password = '!'
|
||||
client.connection.stream.packets = []
|
||||
client.connection.emit('authenticationCleartextPassword')
|
||||
var packets = client.connection.stream.packets
|
||||
assert.lengthIs(packets, 1)
|
||||
var packet = packets[0]
|
||||
assert.equalBuffers(packet, [0x70, 0, 0, 0, 6, 33, 0])
|
||||
})
|
||||
|
||||
test('does not crash with null password using pg-pass', function () {
|
||||
process.env.PGPASSFILE = `${__dirname}/pgpass.file`
|
||||
var client = new helper.Client({
|
||||
host: 'foo',
|
||||
port: 5432,
|
||||
database: 'bar',
|
||||
user: 'baz',
|
||||
stream: new MemoryStream(),
|
||||
})
|
||||
client.connect()
|
||||
client.connection.emit('authenticationCleartextPassword')
|
||||
})
|
||||
})
|
||||
|
||||
1
packages/pg/test/unit/client/pgpass.file
Normal file
1
packages/pg/test/unit/client/pgpass.file
Normal file
@ -0,0 +1 @@
|
||||
foo:5432:bar:baz:quz
|
||||
Loading…
x
Reference in New Issue
Block a user