-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathdbconfig.js
160 lines (139 loc) · 5.29 KB
/
dbconfig.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/* Copyright (c) 2015, 2025, Oracle and/or its affiliates. */
/******************************************************************************
*
* This software is dual-licensed to you under the Universal Permissive License
* (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
* 2.0 as shown at https://www.apache.org/licenses/LICENSE-2.0. You may choose
* either license.
*
* If you elect to accept the software under the Apache License, Version 2.0,
* the following applies:
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* NAME
* dbconfig.js
*
* DESCRIPTION
* This file provides the configuration for all the tests.
* There are TWO options for users to choose:
*
* 1. Edit the credentials section of this file.
* 2. Set these environment variables:
* NODE_ORACLEDB_USER, NODE_ORACLEDB_PASSWORD, NODE_ORACLEDB_CONNECTIONSTRING,
* NODE_ORACLEDB_DBA_PRIVILEGE,
* NODE_ORACLEDB_DBA_USER, NODE_ORACLEDB_DBA_PASSWORD
* If required:
* NODE_ORACLEDB_EXTERNALAUTH,
* NODE_ORACLEDB_PROXY_SESSION_USER, NODE_ORACLEDB_DRCP,
* NODE_ORACLEDB_IMPLICIT_POOL
* NODE_ORACLEDB_WALLET_LOCATION, NODE_ORACLEDB_WALLET_PASSWORD
*
*****************************************************************************/
const oracledb = require('oracledb');
const config = {
test: {
externalAuth: false,
DBA_PRIVILEGE: false,
printDebugMsg: false,
mode: 'thin',
instantClientPath: '',
isCloudService: false,
isCmanTdm: false,
drcp: false,
implicitPool: false
}
};
let counter = 0;
if (process.env.NODE_ORACLEDB_CLIENT_LIB_DIR) {
config.test.instantClientPath = process.env.NODE_ORACLEDB_CLIENT_LIB_DIR;
}
if (process.env.NODE_ORACLEDB_DRIVER_MODE === 'thick') {
config.test.mode = 'thick';
console.log("Thick mode selected");
oracledb.initOracleClient({ libDir: config.test.instantClientPath });
} else {
console.log("Thin mode selected");
}
if (process.env.NODE_ORACLEDB_CONNECTIONSTRING) {
config.connectString = process.env.NODE_ORACLEDB_CONNECTIONSTRING;
} else {
throw new Error("Database Connect String is not set! Set the Environment Variable NODE_ORACLEDB_CONNECTIONSTRING.");
}
if (process.env.NODE_ORACLEDB_EXTERNALAUTH) {
const eauth = process.env.NODE_ORACLEDB_EXTERNALAUTH;
if (eauth.toLowerCase() === 'true') {
config.test.externalAuth = true;
}
}
if (process.env.NODE_ORACLEDB_DRCP) {
config.test.drcp = (process.env.NODE_ORACLEDB_DRCP.toLowerCase() === 'true');
}
if (process.env.NODE_ORACLEDB_IMPLICIT_POOL) {
if (!process.env.NODE_ORACLEDB_DRCP)
throw new Error("For Implicit pooling tests, NODE_ORACLEDB_DRCP needs to be enabled! Set the Environment Variable NODE_ORACLEDB_DRCP");
else
config.test.implicitPool = (process.env.NODE_ORACLEDB_IMPLICIT_POOL.toLowerCase() === 'true');
}
if (process.env.NODE_ORACLEDB_USER) {
config.user = process.env.NODE_ORACLEDB_USER;
} else {
throw new Error("Schema User name is not set! Set the Environment Variable NODE_ORACLEDB_USER.");
}
if (process.env.NODE_ORACLEDB_PASSWORD) {
config.password = process.env.NODE_ORACLEDB_PASSWORD;
} else {
throw new Error("Schema User Password is not set! Set the Environment Variable NODE_ORACLEDB_PASSWORD.");
}
if (process.env.NODE_ORACLEDB_QA) {
const isQA = process.env.NODE_ORACLEDB_QA;
if (isQA.toLowerCase() === 'true') {
config.test.NODE_ORACLEDB_QA = true;
}
}
if (process.env.NODE_ORACLEDB_DBA_PRIVILEGE) {
const priv = process.env.NODE_ORACLEDB_DBA_PRIVILEGE;
if (priv.toLowerCase() == 'true') {
config.test.DBA_PRIVILEGE = true;
}
}
if (process.env.NODE_ORACLEDB_WALLET_PASSWORD) {
config.walletPassword = process.env.NODE_ORACLEDB_WALLET_PASSWORD;
}
if (process.env.NODE_ORACLEDB_WALLET_LOCATION) {
config.walletLocation = process.env.NODE_ORACLEDB_WALLET_LOCATION;
}
if (process.env.NODE_ORACLEDB_DBA_USER) {
config.test.DBA_user = process.env.NODE_ORACLEDB_DBA_USER;
} else if (config.test.DBA_PRIVILEGE) {
throw new Error("DBA Privilege is set to True but DBA username is not set! Set the Environment Variable NODE_ORACLEDB_DBA_USER.");
}
if (process.env.NODE_ORACLEDB_DBA_PASSWORD) {
config.test.DBA_password = process.env.NODE_ORACLEDB_DBA_PASSWORD;
} else if (config.test.DBA_PRIVILEGE) {
throw new Error("DBA Privilege is set to True but DBA Password is not set! Set the Environment Variable NODE_ORACLEDB_DBA_PASSWORD.");
}
if (process.env.NODE_ORACLEDB_PROXY_SESSION_USER) {
config.test.proxySessionUser = process.env.NODE_ORACLEDB_PROXY_SESSION_USER;
}
if (process.env.NODE_PRINT_DEBUG_MESSAGE) {
const printDebugMsg = process.env.NODE_PRINT_DEBUG_MESSAGE;
if (printDebugMsg.toLowerCase() == 'true') {
config.test.printDebugMsg = true;
}
}
config.createUser = () => {
++counter;
return "NJS_" + counter.toString() + config.user;
};
module.exports = config;