Enable test suite for DRCP

This commit is contained in:
Sharad Chandran R 2023-05-23 23:31:22 +05:30
parent 4d05ad311a
commit 8544904f65
10 changed files with 63 additions and 23 deletions

View File

@ -110,6 +110,8 @@ Set the following environment variables to provide credentials for the test suit
* `NODE_ORACLEDB_QA`. This boolean environment variable serves as the toggle switch of certain tests. Some tests, such as `callTimeout.js`, use hard-coded variables as assertion condition. The test results may be inconsistent in different network situations.
* `NODE_ORACLEDB_DRCP` provides an option for skipping test run when DRCP is enabled. Setting this environment variable to `true` will skip certain test case run due to DRCP restrictions.
Note: the test suite requires the schema to have these privileges: CREATE TABLE, CREATE SESSION,
CREATE PROCEDURE, CREATE SEQUENCE, CREATE TRIGGER, and CREATE TYPE.

View File

@ -39,7 +39,6 @@ const dbConfig = require('./dbconfig.js');
const testsUtil = require('./testsUtil.js');
describe('161. changePassword.js', function() {
let DBA_config;
let dbaConn;
let sql;
@ -54,7 +53,7 @@ describe('161. changePassword.js', function() {
}
before (async function() {
if (!dbConfig.test.DBA_PRIVILEGE) this.skip();
if (dbConfig.test.drcp || !dbConfig.test.DBA_PRIVILEGE) this.skip();
sql = "BEGIN \n" +
" DECLARE \n" +
" e_user_missing EXCEPTION; \n" +
@ -79,7 +78,7 @@ describe('161. changePassword.js', function() {
}); // before
after(async function() {
if (dbConfig.test.DBA_PRIVILEGE) {
if (dbConfig.test.DBA_PRIVILEGE && !dbConfig.test.drcp) {
sql = "DROP USER " + myUser + " CASCADE";
dbaConn = await oracledb.getConnection(DBA_config);
await dbaConn.execute(sql);
@ -439,10 +438,13 @@ describe('161. changePassword.js', function() {
}
before (async function() {
if (!dbConfig.test.DBA_PRIVILEGE) this.skip();
isRunnable = await testsUtil.checkPrerequisites(2300000000, 2300000000);
if (!isRunnable) this.skip();
isRunnable = (!dbConfig.test.drcp && dbConfig.test.DBA_PRIVILEGE);
if (isRunnable) {
isRunnable = await testsUtil.checkPrerequisites(2100000000, 2300000000);
}
if (!isRunnable) {
this.skip();
}
}); // before
after(async function() {

View File

@ -32,7 +32,7 @@
* 1. Edit the credential section of this file.
* 2. Set these environment variables:
* NODE_ORACLEDB_USER, NODE_ORACLEDB_PASSWORD, NODE_ORACLEDB_CONNECTIONSTRING,
* NODE_ORACLEDB_EXTERNALAUTH,
* NODE_ORACLEDB_EXTERNALAUTH, NODE_ORACLEDB_DRCP,
* NODE_ORACLEDB_DBA_PRIVILEGE,
* NODE_ORACLEDB_DBA_USER, NODE_ORACLEDB_DBA_PASSWORD
*
@ -47,7 +47,8 @@ const config = {
printDebugMsg: false,
mode: 'thin',
instantClientPath: '',
isCloudService: false
isCloudService: false,
drcp: false
}
};
@ -66,6 +67,10 @@ if (process.env.NODE_ORACLEDB_EXTERNALAUTH) {
}
}
if (process.env.NODE_ORACLEDB_DRCP) {
config.test.drcp = (process.env.NODE_ORACLEDB_DRCP.toLowerCase() === 'true');
}
if (!config.test.externalAuth) {
if (process.env.NODE_ORACLEDB_USER) {
config.user = process.env.NODE_ORACLEDB_USER;

View File

@ -753,6 +753,9 @@ describe('272. jsonDualityView1.js', function() {
)`;
before(async function() {
if (dbConfig.test.drcp) {
this.skip();
}
const credential = {
user : dbConfig.test.DBA_user,
password : dbConfig.test.DBA_password,
@ -768,12 +771,16 @@ describe('272. jsonDualityView1.js', function() {
});
after(async function() {
if (dbConfig.test.drcp) {
return;
}
await connection.execute(`drop user njs_test1 cascade`);
await connection.execute(`drop user njs_test2 cascade`);
await connection.close();
});
it('272.3.11.1 Query with test1 user', async function() {
const studentView = `CREATE OR REPLACE JSON RELATIONAL DUALITY VIEW student_ov
AS
student @insert @update @delete

View File

@ -43,7 +43,10 @@ describe('273. jsonDualityView2.js', function() {
let isRunnable = false;
before(async function() {
isRunnable = await testsUtil.checkPrerequisites(2100000000, 2300000000);
isRunnable = (!dbConfig.test.drcp);
if (isRunnable) {
isRunnable = await testsUtil.checkPrerequisites(2100000000, 2300000000);
}
if (!isRunnable) {
this.skip();
}
@ -326,6 +329,9 @@ describe('273. jsonDualityView2.js', function() {
`constraint pk_student primary key (stuid) \n` +
`)`;
before(async function() {
if (dbConfig.test.drcp) {
this.skip();
}
await dbaConn.execute(createUser1);
await dbaConn.execute(grantPriv1);
await dbaConn.execute(createUser2);
@ -342,6 +348,9 @@ describe('273. jsonDualityView2.js', function() {
});
after(async function() {
if (dbConfig.test.drcp) {
return;
}
await conn2.close();
await conn1.close();
await dbaConn.execute(`drop user njs_test1 cascade`);
@ -471,12 +480,18 @@ describe('273. jsonDualityView2.js', function() {
let conn = null;
const pwd = testsUtil.generateRandomPassword();
before(async function() {
if (dbConfig.test.drcp) {
this.skip();
}
await dbaConn.execute(`create user njs_testuser1 identified by ${pwd}`);
await dbaConn.execute(`grant create session,resource,create table,unlimited tablespace to njs_testuser1`);
await dbaConn.execute(`grant execute on sys.dbms_redact to njs_testuser1`);
});
after(async function() {
if (dbConfig.test.drcp) {
return;
}
await dbaConn.execute(`drop user njs_testuser1 cascade`);
});

View File

@ -43,7 +43,10 @@ describe('274 jsonDualityView3.js', function() {
let isRunnable = false;
const pwd = testsUtil.generateRandomPassword();
before(async function() {
isRunnable = await testsUtil.checkPrerequisites(2100000000, 2300000000);
isRunnable = (!dbConfig.test.drcp);
if (isRunnable) {
isRunnable = await testsUtil.checkPrerequisites(2100000000, 2300000000);
}
if (!isRunnable) {
this.skip();
}

View File

@ -43,8 +43,11 @@ describe('275. jsonDualityView4.js', function() {
let isRunnable = false;
before(async function() {
isRunnable = await testsUtil.checkPrerequisites(2100000000, 2300000000);
if (!(isRunnable && dbConfig.test.DBA_PRIVILEGE)) {
isRunnable = (!dbConfig.test.drcp);
if (isRunnable) {
isRunnable = await testsUtil.checkPrerequisites(2100000000, 2300000000);
}
if (!isRunnable) {
this.skip();
}

View File

@ -43,8 +43,11 @@ describe('276. jsonDualityView5.js', function() {
let isRunnable = false;
before(async function() {
isRunnable = await testsUtil.checkPrerequisites(2100000000, 2300000000);
if (!(isRunnable && dbConfig.test.DBA_PRIVILEGE)) {
isRunnable = (!dbConfig.test.drcp);
if (isRunnable) {
isRunnable = await testsUtil.checkPrerequisites(2100000000, 2300000000);
}
if (!isRunnable) {
this.skip();
}

View File

@ -44,7 +44,7 @@ describe('277. jsonDualityView6.js', function() {
before(async function() {
isRunnable = await testsUtil.checkPrerequisites(2100000000, 2300000000);
if (!(isRunnable && dbConfig.test.DBA_PRIVILEGE)) {
if (dbConfig.test.drcp || !(isRunnable && dbConfig.test.DBA_PRIVILEGE)) {
this.skip();
}
@ -65,7 +65,7 @@ describe('277. jsonDualityView6.js', function() {
});
after(async function() {
if (!isRunnable) return;
if (dbConfig.test.drcp || !isRunnable) return;
await connection.close();
await dbaConn.execute(`drop user njs_jsonDv6 cascade`);

View File

@ -68,7 +68,7 @@ describe('248. userName.js', function() {
describe('248.1 test with different size of username', () => {
it('248.1.1 test with username size 30', async function() {
if (!dbConfig.test.DBA_PRIVILEGE) this.skip();
if (dbConfig.test.drcp || !dbConfig.test.DBA_PRIVILEGE) this.skip();
const userSchema = assist.createSchemaString(30);
const password = testsUtil.generateRandomPassword();
@ -90,7 +90,7 @@ describe('248. userName.js', function() {
it('248.1.2 test with username size 100', async function() {
let runnable = await testsUtil.isLongUserNameRunnable();
if (!runnable) {
if (dbConfig.test.drcp || !runnable) {
this.skip();
}
@ -114,7 +114,7 @@ describe('248. userName.js', function() {
it('248.1.3 test with username size 128', async function() {
let runnable = await testsUtil.isLongUserNameRunnable();
if (!runnable) {
if (dbConfig.test.drcp || !runnable) {
this.skip();
}
@ -248,7 +248,7 @@ describe('248. userName.js', function() {
describe('248.2 test with different size of user', () => {
it('248.2.1 test with user size 30', async function() {
if (!dbConfig.test.DBA_PRIVILEGE) this.skip();
if (dbConfig.test.drcp || !dbConfig.test.DBA_PRIVILEGE) this.skip();
const userSchema = assist.createSchemaString(30);
const password = testsUtil.generateRandomPassword();
@ -267,7 +267,7 @@ describe('248. userName.js', function() {
it('248.2.2 test with user size 100', async function() {
let runnable = await testsUtil.isLongUserNameRunnable();
if (!runnable) {
if (dbConfig.test.drcp || !runnable) {
this.skip();
}
@ -290,7 +290,7 @@ describe('248. userName.js', function() {
it('248.2.3 test with user size 128', async function() {
let runnable = await testsUtil.isLongUserNameRunnable();
if (!runnable) {
if (dbConfig.test.drcp || !runnable) {
this.skip();
}