34
34
'use strict' ;
35
35
36
36
var oracledb = require ( 'oracledb' ) ;
37
- var async = require ( 'async' ) ;
37
+ var async = require ( 'async' ) ;
38
38
var should = require ( 'should' ) ;
39
39
var dbConfig = require ( './dbconfig.js' ) ;
40
40
41
41
describe ( '2. pool.js' , function ( ) {
42
42
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
+
45
47
oracledb . createPool ( dbConfig , function ( err , pool ) {
46
48
should . not . exist ( err ) ;
47
49
pool . should . be . ok ( ) ;
@@ -66,10 +68,13 @@ describe('2. pool.js', function() {
66
68
done ( ) ;
67
69
} ) ;
68
70
} ) ;
69
- } )
70
- } )
71
71
72
- describe ( '2.2 poolMin' , function ( ) {
72
+ } ) ;
73
+
74
+ } ) ;
75
+
76
+ describe ( '2.2 poolMin' , function ( ) {
77
+
73
78
it ( '2.2.1 poolMin cannot be a negative number' , function ( done ) {
74
79
oracledb . createPool (
75
80
{
@@ -211,12 +216,12 @@ describe('2. pool.js', function() {
211
216
}
212
217
) ;
213
218
214
-
215
219
} )
216
220
217
- } )
221
+ } ) ; // 2.2
218
222
219
223
describe ( '2.3 poolMax' , function ( ) {
224
+
220
225
it ( '2.3.1 poolMax cannot be a negative value' , function ( done ) {
221
226
oracledb . createPool (
222
227
{
@@ -339,7 +344,7 @@ describe('2. pool.js', function() {
339
344
) ;
340
345
} )
341
346
342
- } )
347
+ } ) ; // 2.3
343
348
344
349
describe ( '2.4 poolIncrement' , function ( ) {
345
350
it ( '2.4.1 poolIncrement cannot be a negative value' , function ( done ) {
@@ -471,9 +476,10 @@ describe('2. pool.js', function() {
471
476
) ;
472
477
} )
473
478
474
- } )
479
+ } ) // 2.4
480
+
481
+ describe ( '2.5 poolTimeout' , function ( ) {
475
482
476
- describe ( '2.5 poolTimeout' , function ( ) {
477
483
it ( '2.5.1 poolTimeout cannot be a negative number' , function ( done ) {
478
484
oracledb . createPool (
479
485
{
@@ -545,7 +551,8 @@ describe('2. pool.js', function() {
545
551
546
552
} )
547
553
548
- describe ( '2.6 stmtCacheSize' , function ( ) {
554
+ describe ( '2.6 stmtCacheSize' , function ( ) {
555
+
549
556
it ( '2.6.1 stmtCacheSize cannot be a negative value' , function ( done ) {
550
557
oracledb . createPool (
551
558
{
@@ -639,18 +646,18 @@ describe('2. pool.js', function() {
639
646
) ;
640
647
} ) ;
641
648
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 ) {
645
652
pool1 . terminate ( function ( err ) {
646
653
should . not . exist ( err ) ;
647
654
648
655
try {
649
656
pool1 . getConnection ( ) ;
650
657
} catch ( err ) {
651
658
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
654
661
done ( ) ;
655
662
}
656
663
} ) ;
@@ -982,5 +989,58 @@ describe('2. pool.js', function() {
982
989
}
983
990
) ;
984
991
} ) ;
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
+
986
1046
} ) ;
0 commit comments