Skip to content

Commit 7e876b3

Browse files
committed
Add some tests for 'privilege'
1 parent aa204d6 commit 7e876b3

File tree

3 files changed

+140
-0
lines changed

3 files changed

+140
-0
lines changed

test/connection.js

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,4 +827,119 @@ describe('1. connection.js', function(){
827827
});
828828
}); // 1.8
829829

830+
describe('1.9 privileged connnections', function() {
831+
832+
it('1.9.1 Negative value - null', function(done) {
833+
834+
oracledb.getConnection(
835+
{
836+
user: dbConfig.user,
837+
password: dbConfig.password,
838+
connectString: dbConfig.connectString,
839+
privilege: null
840+
},
841+
function(err, connection) {
842+
should.exist(err);
843+
should.strictEqual(
844+
err.message,
845+
'NJS-007: invalid value for "privilege" in parameter 1'
846+
);
847+
should.not.exist(connection);
848+
done();
849+
}
850+
);
851+
}); // 1.9.1
852+
853+
it('1.9.2 Negative - invalid type, a String', function(done) {
854+
855+
oracledb.getConnection(
856+
{
857+
user: dbConfig.user,
858+
password: dbConfig.password,
859+
connectString: dbConfig.connectString,
860+
privilege: 'sysdba'
861+
},
862+
function(err, connection) {
863+
should.exist(err);
864+
should.not.exist(connection);
865+
should.strictEqual(
866+
err.message,
867+
'NJS-008: invalid type for "privilege" in parameter 1'
868+
);
869+
done();
870+
}
871+
);
872+
}); // 1.9.2
873+
874+
it('1.9.3 Negative value - random constants', function(done) {
875+
876+
oracledb.getConnection(
877+
{
878+
user: dbConfig.user,
879+
password: dbConfig.password,
880+
connectString: dbConfig.connectString,
881+
privilege: 23
882+
},
883+
function(err, connection) {
884+
should.exist(err);
885+
(err.message).should.startWith('ORA-24300');
886+
// ORA-24300: bad value for mode
887+
should.not.exist(connection);
888+
done();
889+
}
890+
);
891+
}); // 1.9.3
892+
893+
it('1.9.4 Negative value - NaN', function(done) {
894+
895+
oracledb.getConnection(
896+
{
897+
user: dbConfig.user,
898+
password: dbConfig.password,
899+
connectString: dbConfig.connectString,
900+
privilege: NaN
901+
},
902+
function(err, connection) {
903+
should.exist(err);
904+
should.strictEqual(
905+
err.message,
906+
'NJS-007: invalid value for "privilege" in parameter 1'
907+
);
908+
should.not.exist(connection);
909+
done();
910+
}
911+
);
912+
}); // 1.9.4
913+
914+
it('1.9.5 gets ignored when acquiring a connection from Pool', function(done) {
915+
916+
oracledb.createPool(
917+
{
918+
user: dbConfig.user,
919+
password: dbConfig.password,
920+
connectString: dbConfig.connectString,
921+
privilege: null,
922+
poolMin: 1
923+
},
924+
function(err, pool) {
925+
should.not.exist(err);
926+
927+
pool.getConnection(function(err, conn) {
928+
should.not.exist(err);
929+
930+
conn.close(function(err) {
931+
should.not.exist(err);
932+
933+
pool.close(function(err) {
934+
should.not.exist(err);
935+
done();
936+
});
937+
});
938+
});
939+
}
940+
);
941+
}); // 1.9.5
942+
943+
}); // 1.9
944+
830945
});

test/list.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ Overview of node-oracledb functional tests
2828
1.8 connectionString alias
2929
1.8.1 allows connectionString to be used as an alias for connectString
3030
1.8.2 favors connectString if both connectString and connectionString are passed
31+
1.9 privileged connnections
32+
1.9.1 Negative value - null
33+
1.9.2 Negative - invalid type, a String
34+
1.9.3 Negative value - random constants
35+
1.9.4 Negative value - NaN
36+
1.9.5 gets ignored when acquiring a connection from Pool
3137

3238
2. pool.js
3339
2.1 default values
@@ -3653,6 +3659,7 @@ Overview of node-oracledb functional tests
36533659
140.8.1 String type: user
36543660
140.8.2 String type: password
36553661
140.8.3 String type: connectionString
3662+
140.8.4 Constant type: privilege
36563663

36573664
141. insertNaNToNumber.js
36583665
141.1 SQL, stores NaN

test/v8Getter.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,24 @@ describe('140. v8Getter.js', function() {
734734
done();
735735
});
736736

737+
it('140.8.4 Constant type: privilege', function(done) {
738+
739+
var cred = JSON.parse(JSON.stringify(dbConfig));
740+
Object.defineProperty (cred, 'privilege', {
741+
get : function () {
742+
throw 'Nope';
743+
}
744+
});
745+
746+
should.throws(
747+
function() {
748+
oracledb.getConnection(cred, function(){ });
749+
},
750+
/Nope/
751+
);
752+
done();
753+
});
754+
737755
}); // 140.8
738756

739757
});

0 commit comments

Comments
 (0)