Skip to content

Commit 79cf6cd

Browse files
authored
Update BaseTestCase.java
Fix for the security issue : DBC-14691 Enhance Java Reactive driver to read Db2 credential from Env var for testing
1 parent fdc0f36 commit 79cf6cd

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

tests/com/ibm/db2/r2dbc/BaseTestCase.java

+35-2
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,44 @@ public static void setup() throws FileNotFoundException, IOException
6363
String configPath = Thread.currentThread().getContextClassLoader().getResource("config.properties").getPath();
6464
_config.load(new FileInputStream(configPath));
6565

66-
_database = _config.getProperty("database").trim();
67-
_host = _config.getProperty("host").trim();
66+
_database = System.getenv("DB2_DATABASE");
67+
68+
if(_database == null || _database.length() < 1 ) {
69+
_baselogger.error("Environment variable DB2_DATABASE not set. Please set it before running test file.");
70+
}
71+
72+
_host = System.getenv("DB2_HOST");
73+
if(_host == null || _host.length() <1) {
74+
_baselogger.error("Environment variable DB2_HOST not set. Please set it before running test file.");
75+
}
76+
77+
String prt = System.getenv("DB2_PORT");
78+
if(prt == null || prt.length() < 1) {
79+
_baselogger.error("Environment variable DB2_PORT not set. Please set it before running test file.");
80+
}
81+
_port = Integer.parseInt(prt);
82+
83+
84+
_userid = System.getenv("DB2_USERID");
85+
if(_userid == null || _userid.length() <1) {
86+
_baselogger.error("Environment variable DB2_USERID not set. Please set it before running test file.");
87+
}
88+
if(_userid == null || _userid.length() < 1) {
89+
90+
}
91+
92+
_password = System.getenv("DB2_PASSWORD");
93+
if(_password == null || _password.length() <1) {
94+
_baselogger.error("Environment variable DB2_PASSWORD not set. Please set it before running test file.");
95+
}
96+
97+
/*
98+
99+
_host = _config.getProperty("host").trim();
68100
_port = Integer.parseInt(_config.getProperty("port").trim());
69101
_userid = _config.getProperty("userid").trim();
70102
_password = _config.getProperty("password").trim();
103+
*/
71104

72105
String value = _config.getProperty("keepDynamic");
73106
if (value != null && value.trim().equalsIgnoreCase("true")) {

0 commit comments

Comments
 (0)