OmniSciDB  06b3bd477c
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
com.omnisci.jdbc.OmniSciConnectionTest Class Reference
+ Collaboration diagram for com.omnisci.jdbc.OmniSciConnectionTest:

Public Member Functions

void tst1_binary_unencrypted ()
 
void tst2_http_unencrypted ()
 
void tst3_connect_fail ()
 
void tst4_connect_url_override ()
 
void tst5_properties_connection ()
 
void tst1b_binary_encrypted_default ()
 
void tst1c_binary_encrypted_supplied_truststore_pkiauth_valid ()
 
void tst1e_binary_encrypted_supplied_truststore_pkiauth_invalid ()
 
void tst3a_https_encrypted_without_server_validation_default_truststore ()
 
void tst3b_https_encrypted_without_server_validation_supplied_truststore ()
 
void tst3c_https_encrypted_server_validation_default_truststore ()
 
void tst3d_https_encrypted_with_server_validation_supplied_truststore ()
 
void tst3e_https_insecure_encrypted_supplied_truststore_pkiauth_valid ()
 

Static Public Member Functions

static void setUpBeforeClass () throws Exception
 

Static Package Attributes

static Properties PROPERTIES = new Property_loader("connection_test.properties")
 
static final String user = PROPERTIES.getProperty("default_super_user")
 
static final String password = PROPERTIES.getProperty("default_user_password")
 
static Properties base_properties
 

Detailed Description

Definition at line 18 of file OmniSciConnectionTest.java.

Member Function Documentation

static void com.omnisci.jdbc.OmniSciConnectionTest.setUpBeforeClass ( ) throws Exception
inlinestatic

Definition at line 26 of file OmniSciConnectionTest.java.

References com.omnisci.jdbc.OmniSciConnectionTest.base_properties.

26  {
27  String fileName = System.getProperty("propertiesFileName");
28  base_properties = new Properties();
29  if (fileName == null || fileName.equals("")) {
30  return;
31  }
32  File initialFile = new File(fileName);
33  InputStream inputStream = new FileInputStream(initialFile);
34  base_properties.load(inputStream);
35  }
void com.omnisci.jdbc.OmniSciConnectionTest.tst1_binary_unencrypted ( )
inline

Definition at line 37 of file OmniSciConnectionTest.java.

References Testing.fail, com.omnisci.jdbc.OmniSciConnectionTest.password, com.omnisci.jdbc.OmniSciConnectionTest.PROPERTIES, and com.omnisci.jdbc.OmniSciConnectionTest.user.

37  {
38  try {
39  String url = PROPERTIES.getProperty("binary_connection_url") + ":"
40  + PROPERTIES.getProperty("default_db");
41  Connection conn = DriverManager.getConnection(url, user, password);
42  assertNotEquals(null, conn);
43  conn.close();
44  boolean closed = conn.isClosed();
45  assertEquals(true, closed);
46  } catch (SQLException sq) {
47  String err = "Connection test failed " + sq.toString();
48  fail(err);
49  }
50  }
static unsigned fail
Definition: testing.h:30
void com.omnisci.jdbc.OmniSciConnectionTest.tst1b_binary_encrypted_default ( )
inline

Definition at line 116 of file OmniSciConnectionTest.java.

References Testing.fail, com.omnisci.jdbc.OmniSciConnectionTest.password, com.omnisci.jdbc.OmniSciConnectionTest.PROPERTIES, and com.omnisci.jdbc.OmniSciConnectionTest.user.

116  {
117  try {
118  String url = PROPERTIES.getProperty("binary_connection_url") + ":"
119  + PROPERTIES.getProperty("default_db") + ":binary_tls";
120 
121  Properties pt = new Properties();
122  pt.setProperty("user", user);
123  pt.setProperty("password", password);
124  Connection conn = DriverManager.getConnection(url, pt);
125  assertNotEquals(null, conn);
126  conn.close();
127  boolean closed = conn.isClosed();
128  assertEquals(true, closed);
129  } catch (SQLException sq) {
130  String err = "Connection test failed " + sq.toString();
131  fail(err);
132  }
133  }
static unsigned fail
Definition: testing.h:30
void com.omnisci.jdbc.OmniSciConnectionTest.tst1c_binary_encrypted_supplied_truststore_pkiauth_valid ( )
inline

Definition at line 136 of file OmniSciConnectionTest.java.

References Testing.fail, and com.omnisci.jdbc.OmniSciConnectionTest.PROPERTIES.

136  {
137  try {
138  Properties pt = new Properties();
139  String url = PROPERTIES.getProperty("binary_connection_url") + ":"
140  + PROPERTIES.getProperty("default_db") + ":binary_tls";
141 
142  ClassLoader cl = getClass().getClassLoader();
143  String trust_store = PROPERTIES.getProperty("server_trust_store");
144  trust_store = cl.getResource(trust_store).getPath();
145  pt.setProperty("server_trust_store", trust_store);
146 
147  String sslcert_cl1 = PROPERTIES.getProperty("sslcert_cl1_pkcs12");
148  sslcert_cl1 = cl.getResource(sslcert_cl1).getPath();
149  pt.setProperty("sslcert", sslcert_cl1);
150 
151  pt.setProperty("sslkey_password", PROPERTIES.getProperty("sslkey_password_cl1"));
152 
153  pt.setProperty("user", "pki");
154  pt.setProperty("password", "");
155  pt.setProperty("server_trust_store_pwd",
156  PROPERTIES.getProperty("server_trust_store_password"));
157  pt.setProperty("pkiauth", PROPERTIES.getProperty("pkiauth"));
158 
159  Connection conn = DriverManager.getConnection(url, pt);
160  assertNotEquals(null, conn);
161 
162  Statement statement = conn.createStatement();
163  statement.executeUpdate("drop table if exists test_jdbc_tm_tble");
164 
165  conn.close();
166  boolean closed = conn.isClosed();
167  assertEquals(true, closed);
168  } catch (SQLException sq) {
169  String err = "Connection test failed " + sq.toString();
170  fail(err);
171  }
172  }
static unsigned fail
Definition: testing.h:30
void com.omnisci.jdbc.OmniSciConnectionTest.tst1e_binary_encrypted_supplied_truststore_pkiauth_invalid ( )
inline

Definition at line 175 of file OmniSciConnectionTest.java.

References Testing.fail, and com.omnisci.jdbc.OmniSciConnectionTest.PROPERTIES.

175  {
176  try {
177  Properties pt = new Properties();
178  String url = PROPERTIES.getProperty("binary_connection_url") + ":"
179  + PROPERTIES.getProperty("default_db") + ":binary_tls";
180 
181  ClassLoader cl = getClass().getClassLoader();
182  String trust_store = PROPERTIES.getProperty("server_trust_store");
183  trust_store = cl.getResource(trust_store).getPath();
184  pt.setProperty("server_trust_store", trust_store);
185 
186  // Connect client 1 whose cert is signed by primary and should work
187  String sslcert_cl2 = PROPERTIES.getProperty("sslcert_cl2");
188  sslcert_cl2 = cl.getResource(sslcert_cl2).getPath();
189  pt.setProperty("sslcert", sslcert_cl2);
190 
191  String sslkey_cl2 = PROPERTIES.getProperty("sslkey_cl2");
192  sslkey_cl2 = cl.getResource(sslkey_cl2).getPath();
193  pt.setProperty("sslkey", sslkey_cl2);
194 
195  pt.setProperty("user", "pki");
196  pt.setProperty("password", "");
197  pt.setProperty("server_trust_store_pwd",
198  PROPERTIES.getProperty("server_trust_store_password"));
199  pt.setProperty("pkiauth", PROPERTIES.getProperty("pkiauth"));
200 
201  Connection conn = DriverManager.getConnection(url, pt);
202  assertNotEquals(null, conn);
203  conn.close();
204  boolean closed = conn.isClosed();
205  fail("Credential should not have been accepted");
206  } catch (SQLException sq) {
207  String err = "Connection test failed " + sq.toString();
208  assertTrue(err.contains("Invalid credentials"));
209  }
210  }
static unsigned fail
Definition: testing.h:30
void com.omnisci.jdbc.OmniSciConnectionTest.tst2_http_unencrypted ( )
inline

Definition at line 52 of file OmniSciConnectionTest.java.

References Testing.fail, com.omnisci.jdbc.OmniSciConnectionTest.password, com.omnisci.jdbc.OmniSciConnectionTest.PROPERTIES, and com.omnisci.jdbc.OmniSciConnectionTest.user.

52  {
53  try {
54  String url = PROPERTIES.getProperty("http_connection_url") + ":"
55  + PROPERTIES.getProperty("default_db") + ":http";
56  Connection conn = DriverManager.getConnection(url, user, password);
57  assertNotEquals(null, conn);
58  conn.close();
59  boolean closed = conn.isClosed();
60  assertEquals(true, closed);
61  } catch (SQLException sq) {
62  String err = "Connection test failed " + sq.toString();
63  fail(err);
64  }
65  }
static unsigned fail
Definition: testing.h:30
void com.omnisci.jdbc.OmniSciConnectionTest.tst3_connect_fail ( )
inline

Definition at line 67 of file OmniSciConnectionTest.java.

References Testing.fail, com.omnisci.jdbc.OmniSciConnectionTest.password, com.omnisci.jdbc.OmniSciConnectionTest.PROPERTIES, and com.omnisci.jdbc.OmniSciConnectionTest.user.

67  {
68  try {
69  String url = PROPERTIES.getProperty("failed_connection_url") + ":"
70  + PROPERTIES.getProperty("default_db");
71  Properties pt = new Properties();
72  pt.setProperty("user", user);
73  pt.setProperty("password", password);
74  Connection conn = DriverManager.getConnection(url, pt);
75  } catch (SQLException sq) {
76  assertEquals(sq.getMessage(),
77  "No suitable driver found for jdbc:NOT_omnisci:localhost:6274:omnisci");
78  return;
79  }
80  String err = "Connection should have thrown";
81  fail(err);
82  }
static unsigned fail
Definition: testing.h:30
void com.omnisci.jdbc.OmniSciConnectionTest.tst3a_https_encrypted_without_server_validation_default_truststore ( )
inline

Definition at line 213 of file OmniSciConnectionTest.java.

References Testing.fail, com.omnisci.jdbc.OmniSciConnectionTest.password, com.omnisci.jdbc.OmniSciConnectionTest.PROPERTIES, and com.omnisci.jdbc.OmniSciConnectionTest.user.

213  {
214  try {
215  Properties pt = new Properties();
216  pt.setProperty("user", user);
217  pt.setProperty("password", password);
218  pt.setProperty("protocol", "https_insecure");
219  String url = PROPERTIES.getProperty("https_connection_url") + ":"
220  + PROPERTIES.getProperty("default_db");
221  Connection conn = DriverManager.getConnection(url, pt);
222  assertNotEquals(null, conn);
223  conn.close();
224  boolean closed = conn.isClosed();
225  assertEquals(true, closed);
226  } catch (SQLException sq) {
227  String err = "Connection test failed " + sq.toString();
228  fail(err);
229  }
230  }
static unsigned fail
Definition: testing.h:30
void com.omnisci.jdbc.OmniSciConnectionTest.tst3b_https_encrypted_without_server_validation_supplied_truststore ( )
inline

Definition at line 233 of file OmniSciConnectionTest.java.

References Testing.fail, com.omnisci.jdbc.OmniSciConnectionTest.password, com.omnisci.jdbc.OmniSciConnectionTest.PROPERTIES, and com.omnisci.jdbc.OmniSciConnectionTest.user.

233  {
234  try {
235  ClassLoader cl = getClass().getClassLoader();
236  String trust_store = PROPERTIES.getProperty("server_trust_store");
237  trust_store = cl.getResource(trust_store).getPath();
238 
239  Properties pt = new Properties();
240  pt.setProperty("server_trust_store", trust_store);
241  pt.setProperty("server_trust_store_pwd",
242  PROPERTIES.getProperty("server_trust_store_password"));
243 
244  pt.setProperty("user", user);
245  pt.setProperty("password", password);
246  pt.setProperty("protocol", "https_insecure");
247 
248  String url = PROPERTIES.getProperty("https_connection_url") + ":"
249  + PROPERTIES.getProperty("default_db");
250  Connection conn = DriverManager.getConnection(url, pt);
251  assertNotEquals(null, conn);
252  conn.close();
253  boolean closed = conn.isClosed();
254  assertEquals(true, closed);
255  } catch (SQLException sq) {
256  String err = "Connection test failed " + sq.toString();
257  fail(err);
258  }
259  }
static unsigned fail
Definition: testing.h:30
void com.omnisci.jdbc.OmniSciConnectionTest.tst3c_https_encrypted_server_validation_default_truststore ( )
inline

Definition at line 262 of file OmniSciConnectionTest.java.

References Testing.fail, com.omnisci.jdbc.OmniSciConnectionTest.password, com.omnisci.jdbc.OmniSciConnectionTest.PROPERTIES, and com.omnisci.jdbc.OmniSciConnectionTest.user.

262  {
263  try {
264  Properties pt = new Properties();
265  pt.setProperty("user", user);
266  pt.setProperty("password", password);
267  pt.setProperty("protocol", "https");
268  String url = PROPERTIES.getProperty("https_connection_url") + ":"
269  + PROPERTIES.getProperty("default_db");
270  Connection conn = DriverManager.getConnection(url, pt);
271  assertNotEquals(null, conn);
272  conn.close();
273  boolean closed = conn.isClosed();
274  assertEquals(true, closed);
275  } catch (SQLException sq) {
276  String err = "Connection test failed " + sq.toString();
277  fail(err);
278  }
279  }
static unsigned fail
Definition: testing.h:30
void com.omnisci.jdbc.OmniSciConnectionTest.tst3d_https_encrypted_with_server_validation_supplied_truststore ( )
inline

Definition at line 282 of file OmniSciConnectionTest.java.

References Testing.fail, com.omnisci.jdbc.OmniSciConnectionTest.password, com.omnisci.jdbc.OmniSciConnectionTest.PROPERTIES, and com.omnisci.jdbc.OmniSciConnectionTest.user.

282  {
283  try {
284  ClassLoader cl = getClass().getClassLoader();
285  String trust_store = PROPERTIES.getProperty("ca_primary_trust_store");
286  trust_store = cl.getResource(trust_store).getPath();
287  Properties pt = new Properties();
288  pt.setProperty("server_trust_store", trust_store);
289  pt.setProperty("server_trust_store_pwd",
290  PROPERTIES.getProperty("server_trust_store_password"));
291 
292  pt.setProperty("user", user);
293  pt.setProperty("password", password);
294  pt.setProperty("protocol", "https");
295 
296  String url = PROPERTIES.getProperty("https_connection_url") + ":"
297  + PROPERTIES.getProperty("default_db");
298 
299  Connection conn = DriverManager.getConnection(url, pt);
300  conn.close();
301  assertNotEquals(null, conn);
302  boolean closed = conn.isClosed();
303  assertEquals(true, closed);
304 
305  assertNotEquals(null, conn);
306  } catch (SQLException sq) {
307  String err = "Connection test failed " + sq.toString();
308  fail(err);
309  }
310  }
static unsigned fail
Definition: testing.h:30
void com.omnisci.jdbc.OmniSciConnectionTest.tst3e_https_insecure_encrypted_supplied_truststore_pkiauth_valid ( )
inline

Definition at line 312 of file OmniSciConnectionTest.java.

References Testing.fail, and com.omnisci.jdbc.OmniSciConnectionTest.PROPERTIES.

312  {
313  try {
314  Properties pt = new Properties();
315  String url = PROPERTIES.getProperty("https_connection_url") + ":"
316  + PROPERTIES.getProperty("default_db") + ":https_insecure";
317 
318  ClassLoader cl = getClass().getClassLoader();
319  String trust_store = PROPERTIES.getProperty("server_trust_store");
320  trust_store = cl.getResource(trust_store).getPath();
321  pt.setProperty("server_trust_store", trust_store);
322 
323  String sslcert_cl1 = PROPERTIES.getProperty("sslcert_cl1_pkcs12");
324  sslcert_cl1 = cl.getResource(sslcert_cl1).getPath();
325  pt.setProperty("sslcert", sslcert_cl1);
326 
327  pt.setProperty("sslkey_password", PROPERTIES.getProperty("sslkey_password_cl1"));
328 
329  pt.setProperty("user", "pki");
330  pt.setProperty("password", "");
331  pt.setProperty("server_trust_store_pwd",
332  PROPERTIES.getProperty("server_trust_store_password"));
333  pt.setProperty("pkiauth", PROPERTIES.getProperty("pkiauth"));
334 
335  Connection conn = DriverManager.getConnection(url, pt);
336  Statement statement = conn.createStatement();
337  statement.executeUpdate("drop table if exists test_jdbc_tm_tble");
338  assertNotEquals(null, conn);
339  conn.close();
340  boolean closed = conn.isClosed();
341  assertEquals(true, closed);
342  } catch (SQLException sq) {
343  String err = "Connection test failed " + sq.toString();
344  fail(err);
345  }
346  }
static unsigned fail
Definition: testing.h:30
void com.omnisci.jdbc.OmniSciConnectionTest.tst4_connect_url_override ( )
inline

Definition at line 85 of file OmniSciConnectionTest.java.

References Testing.fail, com.omnisci.jdbc.OmniSciConnectionTest.password, com.omnisci.jdbc.OmniSciConnectionTest.PROPERTIES, and com.omnisci.jdbc.OmniSciConnectionTest.user.

85  {
86  try {
87  String url = PROPERTIES.getProperty("default_mapd_connection_url") + ":"
88  + PROPERTIES.getProperty("default_db");
89  Properties pt = new Properties();
90  pt.setProperty("user", user);
91  pt.setProperty("password", password);
92  pt.setProperty("db_name", "SomeOtherDB");
93  // Shouldn't fail (url over ride properties.
94  Connection conn = DriverManager.getConnection(url, pt);
95  } catch (SQLException sq) {
96  fail(sq.getMessage());
97  }
98  }
static unsigned fail
Definition: testing.h:30
void com.omnisci.jdbc.OmniSciConnectionTest.tst5_properties_connection ( )
inline

Definition at line 101 of file OmniSciConnectionTest.java.

References com.omnisci.jdbc.OmniSciConnectionTest.base_properties, and Testing.fail.

101  {
102  try {
103  String url = "jdbc:omnisci:" + base_properties.getProperty("host_name");
104  Connection conn = DriverManager.getConnection(url, base_properties);
105  assertNotEquals(null, conn);
106  conn.close();
107  boolean closed = conn.isClosed();
108  assertEquals(true, closed);
109  } catch (SQLException sq) {
110  String err = "Connection test failed " + sq.toString();
111  fail(err);
112  }
113  }
static unsigned fail
Definition: testing.h:30

Member Data Documentation

Properties com.omnisci.jdbc.OmniSciConnectionTest.base_properties
staticpackage

The documentation for this class was generated from the following file: