Skip to content

Commit 1f0d3d5

Browse files
committedAug 26, 2020
Add test for pgpass check function scope
1 parent 0758b76 commit 1f0d3d5

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
'use strict'
22

3+
const helper = require('./test-helper')
34
const createClient = require('./test-helper').createClient
45

5-
/*
6-
* TODO: Add _some_ comments to explain what it is we're testing, and how the
7-
* code-being-tested works behind the scenes.
8-
*/
9-
106
test('cleartext password authentication', function () {
11-
var client = createClient()
12-
client.password = '!'
13-
client.connection.stream.packets = []
14-
client.connection.emit('authenticationCleartextPassword')
157
test('responds with password', function () {
8+
var client = createClient()
9+
client.password = '!'
10+
client.connection.stream.packets = []
11+
client.connection.emit('authenticationCleartextPassword')
1612
var packets = client.connection.stream.packets
1713
assert.lengthIs(packets, 1)
1814
var packet = packets[0]
1915
assert.equalBuffers(packet, [0x70, 0, 0, 0, 6, 33, 0])
2016
})
17+
18+
test('does not crash with null password using pg-pass', function () {
19+
process.env.PGPASSFILE = `${__dirname}/pgpass.file`
20+
var client = new helper.Client({
21+
host: 'foo',
22+
port: 5432,
23+
database: 'bar',
24+
user: 'baz',
25+
stream: new MemoryStream(),
26+
})
27+
client.connect()
28+
client.connection.emit('authenticationCleartextPassword')
29+
})
2130
})
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
foo:5432:bar:baz:quz

0 commit comments

Comments
 (0)
Please sign in to comment.