diff --git a/test/README.md b/test/README.md index 381d3a3a..33c4d777 100644 --- a/test/README.md +++ b/test/README.md @@ -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. diff --git a/test/changePassword.js b/test/changePassword.js index 83bd5a02..74c3ce2f 100644 --- a/test/changePassword.js +++ b/test/changePassword.js @@ -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() { diff --git a/test/dbconfig.js b/test/dbconfig.js index c5933acb..1e4b547c 100644 --- a/test/dbconfig.js +++ b/test/dbconfig.js @@ -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; diff --git a/test/jsonDualityViews1.js b/test/jsonDualityViews1.js index 96ef7a4c..6e94858e 100644 --- a/test/jsonDualityViews1.js +++ b/test/jsonDualityViews1.js @@ -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 diff --git a/test/jsonDualityViews2.js b/test/jsonDualityViews2.js index d67583f6..3769e502 100644 --- a/test/jsonDualityViews2.js +++ b/test/jsonDualityViews2.js @@ -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`); }); diff --git a/test/jsonDualityViews3.js b/test/jsonDualityViews3.js index 290e7c38..11f87d21 100644 --- a/test/jsonDualityViews3.js +++ b/test/jsonDualityViews3.js @@ -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(); } diff --git a/test/jsonDualityViews4.js b/test/jsonDualityViews4.js index 3fbf2b4f..72da64c1 100644 --- a/test/jsonDualityViews4.js +++ b/test/jsonDualityViews4.js @@ -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(); } diff --git a/test/jsonDualityViews5.js b/test/jsonDualityViews5.js index 610af00f..07a2bed7 100644 --- a/test/jsonDualityViews5.js +++ b/test/jsonDualityViews5.js @@ -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(); } diff --git a/test/jsonDualityViews6.js b/test/jsonDualityViews6.js index 182cfe77..c8ea24ac 100644 --- a/test/jsonDualityViews6.js +++ b/test/jsonDualityViews6.js @@ -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`); diff --git a/test/userName.js b/test/userName.js index ca4aacd3..e2110c86 100644 --- a/test/userName.js +++ b/test/userName.js @@ -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(); }