mirror of
https://github.com/knex/knex.git
synced 2025-12-29 07:59:31 +00:00
Adding external authentication capability when using oracledb driver (#1716)
* Adding external authentication capability as mentioned in https://github.com/oracle/node-oracledb/blob/master/doc/api.md#extauth * Add unit test for externalAuth * Cover the connection string part * Update documentation * fix spaces * Hide the fake Oracle server error * minor grammar changes and spaces changes
This commit is contained in:
parent
2ddcf64ef1
commit
da5ed96825
@ -8,7 +8,7 @@
|
||||
|
||||
> **A SQL query builder that is _flexible_, _portable_, and _fun_ to use!**
|
||||
|
||||
A batteries-included, multi-dialect (MSSQL, MySQL, PostgreSQL, SQLite3, WebSQL, Oracle) query builder for
|
||||
A batteries-included, multi-dialect (MSSQL, MySQL, PostgreSQL, SQLite3, Oracle(including Oracle Wallet Authentication), WebSQL) query builder for
|
||||
Node.js and the Browser, featuring:
|
||||
|
||||
- [transactions](http://knexjs.org/#Transactions)
|
||||
|
||||
@ -65,15 +65,23 @@ Client_Oracledb.prototype.acquireRawConnection = function() {
|
||||
const client = this;
|
||||
const asyncConnection = new Promise(function(resolver, rejecter) {
|
||||
|
||||
const oracleDbConfig = {
|
||||
user: client.connectionSettings.user,
|
||||
password: client.connectionSettings.password,
|
||||
connectString: client.connectionSettings.connectString ||
|
||||
(client.connectionSettings.host + '/' + client.connectionSettings.database)
|
||||
}
|
||||
// If external authentication dont have to worry about username/password and
|
||||
// if not need to set the username and password
|
||||
const oracleDbConfig = client.connectionSettings.externalAuth ?
|
||||
{ externalAuth : client.connectionSettings.externalAuth } :
|
||||
{
|
||||
user : client.connectionSettings.user,
|
||||
password : client.connectionSettings.password
|
||||
}
|
||||
|
||||
// In the case of external authentication connection string will be given
|
||||
oracleDbConfig.connectString = client.connectionSettings.connectString ||
|
||||
(client.connectionSettings.host + '/' + client.connectionSettings.database);
|
||||
|
||||
if (client.connectionSettings.prefetchRowCount) {
|
||||
oracleDbConfig.prefetchRows = client.connectionSettings.prefetchRowCount
|
||||
}
|
||||
|
||||
if (!_.isUndefined(client.connectionSettings.stmtCacheSize)) {
|
||||
oracleDbConfig.stmtCacheSize = client.connectionSettings.stmtCacheSize;
|
||||
}
|
||||
|
||||
@ -31,6 +31,11 @@ describe('Query Building Tests', function() {
|
||||
require('./unit/schema/oracledb')
|
||||
})
|
||||
|
||||
describe('ExternalAuth ORACLE Tests', function() {
|
||||
this.timeout(process.env.KNEX_TEST_TIMEOUT || 5000);
|
||||
require('./unit/dialects/oracledb')
|
||||
})
|
||||
|
||||
describe('Integration Tests', function() {
|
||||
this.timeout(process.env.KNEX_TEST_TIMEOUT || 5000);
|
||||
require('./integration')
|
||||
|
||||
42
test/unit/dialects/oracledb.js
Normal file
42
test/unit/dialects/oracledb.js
Normal file
@ -0,0 +1,42 @@
|
||||
/*global it, describe, expect*/
|
||||
|
||||
'use strict';
|
||||
var expect = require('chai').expect;
|
||||
var knex = require('../../../knex');
|
||||
var knexInstance = knex(
|
||||
{
|
||||
client: 'oracledb',
|
||||
connection: {
|
||||
user : "user",
|
||||
password : "password",
|
||||
connectString : 'connect-string',
|
||||
externalAuth : true,
|
||||
host : "host",
|
||||
database : "database"
|
||||
}
|
||||
}
|
||||
);
|
||||
var spy;
|
||||
|
||||
beforeEach(function() {
|
||||
spy = sinon.spy(knexInstance.client.driver, "getConnection");
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
sinon.restore(knexInstance.client.driver.getConnection);
|
||||
});
|
||||
|
||||
describe("OracleDb externalAuth", function() {
|
||||
it('externalAuth and connectString should be sent to the getConnection', function() {
|
||||
var connectionWithExternalAuth = {
|
||||
connectString: "connect-string",
|
||||
externalAuth: true
|
||||
}
|
||||
knexInstance.client.acquireRawConnection().then(
|
||||
function(resolve) {},
|
||||
function(reject) {}
|
||||
);
|
||||
expect(spy).to.have.callCount(1);
|
||||
expect(spy).to.have.been.calledWith(connectionWithExternalAuth);
|
||||
});
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user