-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for pgpass check function scope
- Loading branch information
Showing
2 changed files
with
19 additions
and
9 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') | ||
}) | ||
}) |
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 @@ | ||
foo:5432:bar:baz:quz |