Skip to content

Commit 165fdaa

Browse files
committed
Add tests for externalAuth
1 parent 0cdaf21 commit 165fdaa

File tree

1 file changed

+78
-18
lines changed

1 file changed

+78
-18
lines changed

test/pool.js

Lines changed: 78 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,16 @@
3434
'use strict';
3535

3636
var oracledb = require('oracledb');
37-
var async = require('async');
37+
var async = require('async');
3838
var should = require('should');
3939
var dbConfig = require('./dbconfig.js');
4040

4141
describe('2. pool.js', function() {
4242

43-
describe('2.1 default values', function() {
44-
it('2.1.1 set properties to default values if not explicitly specified', function(done) {
43+
describe('2.1 default settting', function() {
44+
45+
it('2.1.1 testing default values of pool properties', function(done) {
46+
4547
oracledb.createPool(dbConfig, function(err, pool) {
4648
should.not.exist(err);
4749
pool.should.be.ok();
@@ -66,10 +68,13 @@ describe('2. pool.js', function() {
6668
done();
6769
});
6870
});
69-
})
70-
})
7171

72-
describe('2.2 poolMin', function(){
72+
});
73+
74+
});
75+
76+
describe('2.2 poolMin', function() {
77+
7378
it('2.2.1 poolMin cannot be a negative number', function(done){
7479
oracledb.createPool(
7580
{
@@ -211,12 +216,12 @@ describe('2. pool.js', function() {
211216
}
212217
);
213218

214-
215219
})
216220

217-
})
221+
}); // 2.2
218222

219223
describe('2.3 poolMax', function(){
224+
220225
it('2.3.1 poolMax cannot be a negative value', function(done){
221226
oracledb.createPool(
222227
{
@@ -339,7 +344,7 @@ describe('2. pool.js', function() {
339344
);
340345
})
341346

342-
})
347+
}); // 2.3
343348

344349
describe('2.4 poolIncrement', function(){
345350
it('2.4.1 poolIncrement cannot be a negative value', function(done){
@@ -471,9 +476,10 @@ describe('2. pool.js', function() {
471476
);
472477
})
473478

474-
})
479+
}) // 2.4
480+
481+
describe('2.5 poolTimeout', function() {
475482

476-
describe('2.5 poolTimeout', function(){
477483
it('2.5.1 poolTimeout cannot be a negative number', function(done){
478484
oracledb.createPool(
479485
{
@@ -545,7 +551,8 @@ describe('2. pool.js', function() {
545551

546552
})
547553

548-
describe('2.6 stmtCacheSize', function(){
554+
describe('2.6 stmtCacheSize', function() {
555+
549556
it('2.6.1 stmtCacheSize cannot be a negative value', function(done){
550557
oracledb.createPool(
551558
{
@@ -639,18 +646,18 @@ describe('2. pool.js', function() {
639646
);
640647
});
641648

642-
// Skipping this test because assertions were added to the JS layer for all
643-
// public methods. This now throws NJS-009: invalid number of parameters.
644-
it.skip('2.7.1 throws error if called after pool is terminated and a callback is not provided', function(done) {
649+
// This case was skipped. JavaScript layer conducts assertions for all public methods.
650+
// The case used to throw NJS-002 error.
651+
it('2.7.1 throws error if called after pool is terminated and a callback is not provided', function(done) {
645652
pool1.terminate(function(err) {
646653
should.not.exist(err);
647654

648655
try {
649656
pool1.getConnection();
650657
} catch (err) {
651658
should.exist(err);
652-
(err.message).should.startWith('NJS-002:');
653-
// NJS-002: invalid pool
659+
(err.message).should.startWith('NJS-009:');
660+
// NJS-009: invalid number of parameters
654661
done();
655662
}
656663
});
@@ -982,5 +989,58 @@ describe('2. pool.js', function() {
982989
}
983990
);
984991
});
985-
});
992+
}); // 2.10
993+
994+
describe('2.11 External Authentication', function() {
995+
996+
// need to skip these tests if external authentication is enable for the whole suite
997+
var it = (!dbConfig.externalAuth) ? global.it : global.it.skip;
998+
999+
it('2.11.1 throws error when providing username and password with external authentication', function(done) {
1000+
1001+
if(!dbConfig.user || !dbConfig.password) {
1002+
console.error("user/password required.");
1003+
} else {
1004+
oracledb.createPool(
1005+
{
1006+
externalAuth: true,
1007+
user: dbConfig.user,
1008+
password: dbConfig.password,
1009+
connectString: dbConfig.connectString
1010+
},
1011+
function(err, pool) {
1012+
should.exist(err);
1013+
(err.message).should.startWith("DPI-006:");
1014+
// DPI-006: user and password should not be set when using external authentication
1015+
should.not.exist(pool);
1016+
done();
1017+
}
1018+
);
1019+
}
1020+
1021+
});
1022+
1023+
it('2.11.2 throws error when providing username', function(done) {
1024+
1025+
if(!dbConfig.user) {
1026+
console.error("user/password required.");
1027+
} else {
1028+
oracledb.createPool(
1029+
{
1030+
externalAuth: true,
1031+
user: dbConfig.user,
1032+
connectString: dbConfig.connectString
1033+
},
1034+
function(err, pool) {
1035+
should.exist(err);
1036+
(err.message).should.startWith("DPI-006:");
1037+
should.not.exist(pool);
1038+
done();
1039+
}
1040+
);
1041+
}
1042+
});
1043+
1044+
}); // 2.11
1045+
9861046
});

0 commit comments

Comments
 (0)