Support for non-friendly chars in url username and password (#858)
* Support for non-friendly chars in url username and password - Added auth option to Connection class - Updated pool.addConnection * Updated test
This commit is contained in:
committed by
delvedor
parent
a83cf7b26f
commit
06b3a1ceb7
@ -61,8 +61,23 @@ test('API', t => {
|
||||
t.deepEqual(pool._auth, { username: 'foo', password: 'bar' })
|
||||
|
||||
pool.addConnection('http://localhost:9201')
|
||||
t.strictEqual(pool.connections.get('http://localhost:9201/').url.username, 'foo')
|
||||
t.strictEqual(pool.connections.get('http://localhost:9201/').url.password, 'bar')
|
||||
const conn = pool.connections.get('http://localhost:9201/')
|
||||
t.strictEqual(conn.url.username, 'foo')
|
||||
t.strictEqual(conn.url.password, 'bar')
|
||||
t.strictEqual(conn.auth.username, 'foo')
|
||||
t.strictEqual(conn.auth.password, 'bar')
|
||||
t.end()
|
||||
})
|
||||
|
||||
t.test('addConnection should handle not-friendly url parameters for user and password', t => {
|
||||
const pool = new ConnectionPool({ Connection })
|
||||
const href = 'http://us"er:p@assword@localhost:9200/'
|
||||
pool.addConnection(href)
|
||||
const conn = pool.getConnection()
|
||||
t.strictEqual(conn.url.username, 'us%22er')
|
||||
t.strictEqual(conn.url.password, 'p%40assword')
|
||||
t.strictEqual(conn.auth.username, 'us"er')
|
||||
t.strictEqual(conn.auth.password, 'p@assword')
|
||||
t.end()
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user