node-oracledb/test/dbconfig.js

115 lines
3.7 KiB
JavaScript
Raw Normal View History

2018-03-27 14:04:00 +08:00
/* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. */
2015-07-20 12:42:12 +08:00
/******************************************************************************
*
* You may not use the identified files except in compliance with the Apache
* License, Version 2.0 (the "License.")
*
* You may obtain a copy of the License at
* http://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.
*
2016-03-24 14:09:53 +08:00
* The node-oracledb test suite uses 'mocha', 'should' and 'async'.
2015-07-21 05:38:41 +08:00
* See LICENSE.md for relevant licenses.
*
2015-07-20 12:42:12 +08:00
* NAME
* dbConfig.js
*
* DESCRIPTION
2018-04-03 05:41:52 +08:00
* This file conduct the configuration work for all the tests.
* There are TWO options for users to choose:
2016-03-24 14:09:53 +08:00
*
2018-04-03 05:41:52 +08:00
* 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_DBA_PRIVILEGE,
* NODE_ORACLEDB_DBA_USER, NODE_ORACLEDB_DBA_PASSWORD
2015-07-20 12:42:12 +08:00
*
*****************************************************************************/
2019-02-08 09:55:21 +08:00
var config = {
test: {
2019-11-19 10:32:40 +08:00
externalAuth: false,
2019-02-08 09:55:21 +08:00
DBA_PRIVILEGE: false,
2019-11-19 10:32:40 +08:00
printDebugMsg: false
2019-02-08 09:55:21 +08:00
}
};
2018-04-03 05:41:52 +08:00
if (process.env.NODE_ORACLEDB_USER) {
config.user = process.env.NODE_ORACLEDB_USER;
2019-02-08 09:55:21 +08:00
} else {
throw new Error("Schema User name is not Set! Try Set Environment Variable NODE_ORACLEDB_USER.");
2018-04-03 05:41:52 +08:00
}
if (process.env.NODE_ORACLEDB_PASSWORD) {
config.password = process.env.NODE_ORACLEDB_PASSWORD;
2019-02-08 09:55:21 +08:00
} else {
throw new Error("Schema User Password is not Set! Try Set Environment Variable NODE_ORACLEDB_PASSWORD.");
2018-04-03 05:41:52 +08:00
}
if (process.env.NODE_ORACLEDB_CONNECTIONSTRING) {
config.connectString = process.env.NODE_ORACLEDB_CONNECTIONSTRING;
2019-02-08 09:55:21 +08:00
} else {
throw new Error("Database Connect String is not Set! Try Set Environment Variable NODE_ORACLEDB_CONNECTIONSTRING.");
2018-04-03 05:41:52 +08:00
}
if (process.env.NODE_ORACLEDB_EXTERNALAUTH) {
var eauth = process.env.NODE_ORACLEDB_EXTERNALAUTH;
eauth = String(eauth);
eauth = eauth.toLowerCase();
if (eauth == 'true') {
config.test.externalAuth = true;
}
}
if (process.env.NODE_ORACLEDB_QA) {
let isQA = process.env.NODE_ORACLEDB_QA;
isQA = String(isQA);
isQA = isQA.toLowerCase();
if (isQA == 'true') {
config.test.NODE_ORACLEDB_QA = true;
}
}
2018-04-03 05:41:52 +08:00
if (process.env.NODE_ORACLEDB_DBA_PRIVILEGE) {
var priv = process.env.NODE_ORACLEDB_DBA_PRIVILEGE;
priv = String(priv);
priv = priv.toLowerCase();
if (priv == 'true') {
config.test.DBA_PRIVILEGE = true;
}
}
if (process.env.NODE_ORACLEDB_DBA_USER) {
config.test.DBA_user = process.env.NODE_ORACLEDB_DBA_USER;
2019-02-08 09:55:21 +08:00
} else if (config.test.DBA_PRIVILEGE) {
throw new Error("DBA Privilege is set to True but DBA username is not Set! Try Set Environment Variable NODE_ORACLEDB_DBA_USER.");
2018-04-03 05:41:52 +08:00
}
if (process.env.NODE_ORACLEDB_DBA_PASSWORD) {
config.test.DBA_password = process.env.NODE_ORACLEDB_DBA_PASSWORD;
2019-02-08 09:55:21 +08:00
} else if (config.test.DBA_PRIVILEGE) {
throw new Error("DBA Privilege is set to True but DBA Password is not Set! Try Set Environment Variable NODE_ORACLEDB_DBA_PASSWORD.");
2018-04-03 05:41:52 +08:00
}
2018-03-27 14:04:00 +08:00
2019-01-03 06:10:21 +08:00
if (process.env.NODE_ORACLEDB_PROXY_SESSION_USER) {
config.test.proxySessionUser = process.env.NODE_ORACLEDB_PROXY_SESSION_USER;
}
2019-03-13 07:48:49 +08:00
if (process.env.NODE_PRINT_DEBUG_MESSAGE) {
var printDebugMsg = process.env.NODE_PRINT_DEBUG_MESSAGE;
printDebugMsg = String(printDebugMsg);
printDebugMsg = printDebugMsg.toLowerCase();
if (printDebugMsg == 'true') {
config.test.printDebugMsg = true;
}
}
2019-11-19 10:32:40 +08:00
module.exports = config;