Skip to content

Commit 8544904

Browse files
committed
Enable test suite for DRCP
1 parent 4d05ad3 commit 8544904

10 files changed

+63
-23
lines changed

test/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ Set the following environment variables to provide credentials for the test suit
110110

111111
* `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.
112112

113+
* `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.
114+
113115
Note: the test suite requires the schema to have these privileges: CREATE TABLE, CREATE SESSION,
114116
CREATE PROCEDURE, CREATE SEQUENCE, CREATE TRIGGER, and CREATE TYPE.
115117

test/changePassword.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ const dbConfig = require('./dbconfig.js');
3939
const testsUtil = require('./testsUtil.js');
4040

4141
describe('161. changePassword.js', function() {
42-
4342
let DBA_config;
4443
let dbaConn;
4544
let sql;
@@ -54,7 +53,7 @@ describe('161. changePassword.js', function() {
5453
}
5554

5655
before (async function() {
57-
if (!dbConfig.test.DBA_PRIVILEGE) this.skip();
56+
if (dbConfig.test.drcp || !dbConfig.test.DBA_PRIVILEGE) this.skip();
5857
sql = "BEGIN \n" +
5958
" DECLARE \n" +
6059
" e_user_missing EXCEPTION; \n" +
@@ -79,7 +78,7 @@ describe('161. changePassword.js', function() {
7978
}); // before
8079

8180
after(async function() {
82-
if (dbConfig.test.DBA_PRIVILEGE) {
81+
if (dbConfig.test.DBA_PRIVILEGE && !dbConfig.test.drcp) {
8382
sql = "DROP USER " + myUser + " CASCADE";
8483
dbaConn = await oracledb.getConnection(DBA_config);
8584
await dbaConn.execute(sql);
@@ -439,10 +438,13 @@ describe('161. changePassword.js', function() {
439438
}
440439

441440
before (async function() {
442-
if (!dbConfig.test.DBA_PRIVILEGE) this.skip();
443-
444-
isRunnable = await testsUtil.checkPrerequisites(2300000000, 2300000000);
445-
if (!isRunnable) this.skip();
441+
isRunnable = (!dbConfig.test.drcp && dbConfig.test.DBA_PRIVILEGE);
442+
if (isRunnable) {
443+
isRunnable = await testsUtil.checkPrerequisites(2100000000, 2300000000);
444+
}
445+
if (!isRunnable) {
446+
this.skip();
447+
}
446448
}); // before
447449

448450
after(async function() {

test/dbconfig.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* 1. Edit the credential section of this file.
3333
* 2. Set these environment variables:
3434
* NODE_ORACLEDB_USER, NODE_ORACLEDB_PASSWORD, NODE_ORACLEDB_CONNECTIONSTRING,
35-
* NODE_ORACLEDB_EXTERNALAUTH,
35+
* NODE_ORACLEDB_EXTERNALAUTH, NODE_ORACLEDB_DRCP,
3636
* NODE_ORACLEDB_DBA_PRIVILEGE,
3737
* NODE_ORACLEDB_DBA_USER, NODE_ORACLEDB_DBA_PASSWORD
3838
*
@@ -47,7 +47,8 @@ const config = {
4747
printDebugMsg: false,
4848
mode: 'thin',
4949
instantClientPath: '',
50-
isCloudService: false
50+
isCloudService: false,
51+
drcp: false
5152
}
5253
};
5354

@@ -66,6 +67,10 @@ if (process.env.NODE_ORACLEDB_EXTERNALAUTH) {
6667
}
6768
}
6869

70+
if (process.env.NODE_ORACLEDB_DRCP) {
71+
config.test.drcp = (process.env.NODE_ORACLEDB_DRCP.toLowerCase() === 'true');
72+
}
73+
6974
if (!config.test.externalAuth) {
7075
if (process.env.NODE_ORACLEDB_USER) {
7176
config.user = process.env.NODE_ORACLEDB_USER;

test/jsonDualityViews1.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,9 @@ describe('272. jsonDualityView1.js', function() {
753753
)`;
754754

755755
before(async function() {
756+
if (dbConfig.test.drcp) {
757+
this.skip();
758+
}
756759
const credential = {
757760
user : dbConfig.test.DBA_user,
758761
password : dbConfig.test.DBA_password,
@@ -768,12 +771,16 @@ describe('272. jsonDualityView1.js', function() {
768771
});
769772

770773
after(async function() {
774+
if (dbConfig.test.drcp) {
775+
return;
776+
}
771777
await connection.execute(`drop user njs_test1 cascade`);
772778
await connection.execute(`drop user njs_test2 cascade`);
773779
await connection.close();
774780
});
775781

776782
it('272.3.11.1 Query with test1 user', async function() {
783+
777784
const studentView = `CREATE OR REPLACE JSON RELATIONAL DUALITY VIEW student_ov
778785
AS
779786
student @insert @update @delete

test/jsonDualityViews2.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ describe('273. jsonDualityView2.js', function() {
4343
let isRunnable = false;
4444

4545
before(async function() {
46-
isRunnable = await testsUtil.checkPrerequisites(2100000000, 2300000000);
46+
isRunnable = (!dbConfig.test.drcp);
47+
if (isRunnable) {
48+
isRunnable = await testsUtil.checkPrerequisites(2100000000, 2300000000);
49+
}
4750
if (!isRunnable) {
4851
this.skip();
4952
}
@@ -326,6 +329,9 @@ describe('273. jsonDualityView2.js', function() {
326329
`constraint pk_student primary key (stuid) \n` +
327330
`)`;
328331
before(async function() {
332+
if (dbConfig.test.drcp) {
333+
this.skip();
334+
}
329335
await dbaConn.execute(createUser1);
330336
await dbaConn.execute(grantPriv1);
331337
await dbaConn.execute(createUser2);
@@ -342,6 +348,9 @@ describe('273. jsonDualityView2.js', function() {
342348
});
343349

344350
after(async function() {
351+
if (dbConfig.test.drcp) {
352+
return;
353+
}
345354
await conn2.close();
346355
await conn1.close();
347356
await dbaConn.execute(`drop user njs_test1 cascade`);
@@ -471,12 +480,18 @@ describe('273. jsonDualityView2.js', function() {
471480
let conn = null;
472481
const pwd = testsUtil.generateRandomPassword();
473482
before(async function() {
483+
if (dbConfig.test.drcp) {
484+
this.skip();
485+
}
474486
await dbaConn.execute(`create user njs_testuser1 identified by ${pwd}`);
475487
await dbaConn.execute(`grant create session,resource,create table,unlimited tablespace to njs_testuser1`);
476488
await dbaConn.execute(`grant execute on sys.dbms_redact to njs_testuser1`);
477489
});
478490

479491
after(async function() {
492+
if (dbConfig.test.drcp) {
493+
return;
494+
}
480495
await dbaConn.execute(`drop user njs_testuser1 cascade`);
481496
});
482497

test/jsonDualityViews3.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ describe('274 jsonDualityView3.js', function() {
4343
let isRunnable = false;
4444
const pwd = testsUtil.generateRandomPassword();
4545
before(async function() {
46-
isRunnable = await testsUtil.checkPrerequisites(2100000000, 2300000000);
46+
isRunnable = (!dbConfig.test.drcp);
47+
if (isRunnable) {
48+
isRunnable = await testsUtil.checkPrerequisites(2100000000, 2300000000);
49+
}
4750
if (!isRunnable) {
4851
this.skip();
4952
}

test/jsonDualityViews4.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ describe('275. jsonDualityView4.js', function() {
4343
let isRunnable = false;
4444

4545
before(async function() {
46-
isRunnable = await testsUtil.checkPrerequisites(2100000000, 2300000000);
47-
if (!(isRunnable && dbConfig.test.DBA_PRIVILEGE)) {
46+
isRunnable = (!dbConfig.test.drcp);
47+
if (isRunnable) {
48+
isRunnable = await testsUtil.checkPrerequisites(2100000000, 2300000000);
49+
}
50+
if (!isRunnable) {
4851
this.skip();
4952
}
5053

test/jsonDualityViews5.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ describe('276. jsonDualityView5.js', function() {
4343
let isRunnable = false;
4444

4545
before(async function() {
46-
isRunnable = await testsUtil.checkPrerequisites(2100000000, 2300000000);
47-
if (!(isRunnable && dbConfig.test.DBA_PRIVILEGE)) {
46+
isRunnable = (!dbConfig.test.drcp);
47+
if (isRunnable) {
48+
isRunnable = await testsUtil.checkPrerequisites(2100000000, 2300000000);
49+
}
50+
if (!isRunnable) {
4851
this.skip();
4952
}
5053

test/jsonDualityViews6.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('277. jsonDualityView6.js', function() {
4444

4545
before(async function() {
4646
isRunnable = await testsUtil.checkPrerequisites(2100000000, 2300000000);
47-
if (!(isRunnable && dbConfig.test.DBA_PRIVILEGE)) {
47+
if (dbConfig.test.drcp || !(isRunnable && dbConfig.test.DBA_PRIVILEGE)) {
4848
this.skip();
4949
}
5050

@@ -65,7 +65,7 @@ describe('277. jsonDualityView6.js', function() {
6565
});
6666

6767
after(async function() {
68-
if (!isRunnable) return;
68+
if (dbConfig.test.drcp || !isRunnable) return;
6969
await connection.close();
7070

7171
await dbaConn.execute(`drop user njs_jsonDv6 cascade`);

test/userName.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ describe('248. userName.js', function() {
6868
describe('248.1 test with different size of username', () => {
6969

7070
it('248.1.1 test with username size 30', async function() {
71-
if (!dbConfig.test.DBA_PRIVILEGE) this.skip();
71+
if (dbConfig.test.drcp || !dbConfig.test.DBA_PRIVILEGE) this.skip();
7272

7373
const userSchema = assist.createSchemaString(30);
7474
const password = testsUtil.generateRandomPassword();
@@ -90,7 +90,7 @@ describe('248. userName.js', function() {
9090

9191
it('248.1.2 test with username size 100', async function() {
9292
let runnable = await testsUtil.isLongUserNameRunnable();
93-
if (!runnable) {
93+
if (dbConfig.test.drcp || !runnable) {
9494
this.skip();
9595
}
9696

@@ -114,7 +114,7 @@ describe('248. userName.js', function() {
114114

115115
it('248.1.3 test with username size 128', async function() {
116116
let runnable = await testsUtil.isLongUserNameRunnable();
117-
if (!runnable) {
117+
if (dbConfig.test.drcp || !runnable) {
118118
this.skip();
119119
}
120120

@@ -248,7 +248,7 @@ describe('248. userName.js', function() {
248248
describe('248.2 test with different size of user', () => {
249249

250250
it('248.2.1 test with user size 30', async function() {
251-
if (!dbConfig.test.DBA_PRIVILEGE) this.skip();
251+
if (dbConfig.test.drcp || !dbConfig.test.DBA_PRIVILEGE) this.skip();
252252

253253
const userSchema = assist.createSchemaString(30);
254254
const password = testsUtil.generateRandomPassword();
@@ -267,7 +267,7 @@ describe('248. userName.js', function() {
267267

268268
it('248.2.2 test with user size 100', async function() {
269269
let runnable = await testsUtil.isLongUserNameRunnable();
270-
if (!runnable) {
270+
if (dbConfig.test.drcp || !runnable) {
271271
this.skip();
272272
}
273273

@@ -290,7 +290,7 @@ describe('248. userName.js', function() {
290290

291291
it('248.2.3 test with user size 128', async function() {
292292
let runnable = await testsUtil.isLongUserNameRunnable();
293-
if (!runnable) {
293+
if (dbConfig.test.drcp || !runnable) {
294294
this.skip();
295295
}
296296

0 commit comments

Comments
 (0)