parent
d1c5fc694b
commit
1596a933eb
@ -47,7 +47,7 @@ var ConnectionParameters = function(config) {
|
|||||||
this.host = val('host', config);
|
this.host = val('host', config);
|
||||||
this.password = val('password', config);
|
this.password = val('password', config);
|
||||||
this.binary = val('binary', config);
|
this.binary = val('binary', config);
|
||||||
this.ssl = config.ssl || useSsl();
|
this.ssl = typeof config.ssl === 'boolean' ? config.ssl : useSsl();
|
||||||
this.client_encoding = val("client_encoding", config);
|
this.client_encoding = val("client_encoding", config);
|
||||||
//a domain socket begins with '/'
|
//a domain socket begins with '/'
|
||||||
this.isDomainSocket = (!(this.host||'').indexOf('/'));
|
this.isDomainSocket = (!(this.host||'').indexOf('/'));
|
||||||
|
@ -11,6 +11,7 @@ test('client settings', function() {
|
|||||||
assert.equal(client.user, pguser);
|
assert.equal(client.user, pguser);
|
||||||
assert.equal(client.database, pgdatabase);
|
assert.equal(client.database, pgdatabase);
|
||||||
assert.equal(client.port, pgport);
|
assert.equal(client.port, pgport);
|
||||||
|
assert.equal(client.ssl, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('custom', function() {
|
test('custom', function() {
|
||||||
@ -21,13 +22,37 @@ test('client settings', function() {
|
|||||||
user: user,
|
user: user,
|
||||||
database: database,
|
database: database,
|
||||||
port: 321,
|
port: 321,
|
||||||
password: password
|
password: password,
|
||||||
|
ssl: true
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.equal(client.user, user);
|
assert.equal(client.user, user);
|
||||||
assert.equal(client.database, database);
|
assert.equal(client.database, database);
|
||||||
assert.equal(client.port, 321);
|
assert.equal(client.port, 321);
|
||||||
assert.equal(client.password, password);
|
assert.equal(client.password, password);
|
||||||
|
assert.equal(client.ssl, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('custom ssl default on', function() {
|
||||||
|
var old = process.env.PGSSLMODE;
|
||||||
|
process.env.PGSSLMODE = "prefer";
|
||||||
|
|
||||||
|
var client = new Client();
|
||||||
|
process.env.PGSSLMODE = old;
|
||||||
|
|
||||||
|
assert.equal(client.ssl, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('custom ssl force off', function() {
|
||||||
|
var old = process.env.PGSSLMODE;
|
||||||
|
process.env.PGSSLMODE = "prefer";
|
||||||
|
|
||||||
|
var client = new Client({
|
||||||
|
ssl: false
|
||||||
|
});
|
||||||
|
process.env.PGSSLMODE = old;
|
||||||
|
|
||||||
|
assert.equal(client.ssl, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user