Add some tests for 'privilege'

This commit is contained in:
Christopher Jones 2018-02-06 13:59:28 +11:00
parent aa204d6548
commit 7e876b34bd
3 changed files with 140 additions and 0 deletions

View File

@ -827,4 +827,119 @@ describe('1. connection.js', function(){
});
}); // 1.8
describe('1.9 privileged connnections', function() {
it('1.9.1 Negative value - null', function(done) {
oracledb.getConnection(
{
user: dbConfig.user,
password: dbConfig.password,
connectString: dbConfig.connectString,
privilege: null
},
function(err, connection) {
should.exist(err);
should.strictEqual(
err.message,
'NJS-007: invalid value for "privilege" in parameter 1'
);
should.not.exist(connection);
done();
}
);
}); // 1.9.1
it('1.9.2 Negative - invalid type, a String', function(done) {
oracledb.getConnection(
{
user: dbConfig.user,
password: dbConfig.password,
connectString: dbConfig.connectString,
privilege: 'sysdba'
},
function(err, connection) {
should.exist(err);
should.not.exist(connection);
should.strictEqual(
err.message,
'NJS-008: invalid type for "privilege" in parameter 1'
);
done();
}
);
}); // 1.9.2
it('1.9.3 Negative value - random constants', function(done) {
oracledb.getConnection(
{
user: dbConfig.user,
password: dbConfig.password,
connectString: dbConfig.connectString,
privilege: 23
},
function(err, connection) {
should.exist(err);
(err.message).should.startWith('ORA-24300');
// ORA-24300: bad value for mode
should.not.exist(connection);
done();
}
);
}); // 1.9.3
it('1.9.4 Negative value - NaN', function(done) {
oracledb.getConnection(
{
user: dbConfig.user,
password: dbConfig.password,
connectString: dbConfig.connectString,
privilege: NaN
},
function(err, connection) {
should.exist(err);
should.strictEqual(
err.message,
'NJS-007: invalid value for "privilege" in parameter 1'
);
should.not.exist(connection);
done();
}
);
}); // 1.9.4
it('1.9.5 gets ignored when acquiring a connection from Pool', function(done) {
oracledb.createPool(
{
user: dbConfig.user,
password: dbConfig.password,
connectString: dbConfig.connectString,
privilege: null,
poolMin: 1
},
function(err, pool) {
should.not.exist(err);
pool.getConnection(function(err, conn) {
should.not.exist(err);
conn.close(function(err) {
should.not.exist(err);
pool.close(function(err) {
should.not.exist(err);
done();
});
});
});
}
);
}); // 1.9.5
}); // 1.9
});

View File

@ -28,6 +28,12 @@ Overview of node-oracledb functional tests
1.8 connectionString alias
1.8.1 allows connectionString to be used as an alias for connectString
1.8.2 favors connectString if both connectString and connectionString are passed
1.9 privileged connnections
1.9.1 Negative value - null
1.9.2 Negative - invalid type, a String
1.9.3 Negative value - random constants
1.9.4 Negative value - NaN
1.9.5 gets ignored when acquiring a connection from Pool
2. pool.js
2.1 default values
@ -3653,6 +3659,7 @@ Overview of node-oracledb functional tests
140.8.1 String type: user
140.8.2 String type: password
140.8.3 String type: connectionString
140.8.4 Constant type: privilege
141. insertNaNToNumber.js
141.1 SQL, stores NaN

View File

@ -734,6 +734,24 @@ describe('140. v8Getter.js', function() {
done();
});
it('140.8.4 Constant type: privilege', function(done) {
var cred = JSON.parse(JSON.stringify(dbConfig));
Object.defineProperty (cred, 'privilege', {
get : function () {
throw 'Nope';
}
});
should.throws(
function() {
oracledb.getConnection(cred, function(){ });
},
/Nope/
);
done();
});
}); // 140.8
});