MQConnection connectToServer(Uri uri, string user, string password) { try { MQConnection con = MQBuilder.BuildConnection(uri, user, password); Assert.IsTrue(con != null, "Successfully Connected"); return(con); } catch (Exception e) { Assert.IsTrue(e == null, e.ToString()); } return(null); }
public void test_EmptyPassword() { SSLContext ctx = setupSSL(); MQConnection con; try { con = MQBuilder.BuildConnection(simpleAddress, user, "", ctx); con.Close(); } catch (Exception e) { Assert.IsTrue(e == null, "Connect attempt with x.509 ident, name empty password " + e.ToString()); } }
public void test_NullLogin() { SSLContext ctx = setupSSL(); MQConnection con; try { con = MQBuilder.BuildConnection(simpleAddress, null, null, ctx); con.Close(); } catch (Exception e) { Assert.IsTrue(e == null, "Reconnect with x.509 ident null ident " + e.ToString()); } }
public void test_BadPassword() { SSLContext ctx = setupSSL(); MQConnection con; try { con = MQBuilder.BuildConnection(simpleAddress, user, "12345", ctx); con.Close(); } catch (MQException e) { Assert.IsTrue(e.getErrorcode() == ErrorCode.EC_NOTAUTHORIZED, "Reconnect with x.509 ident, name wrong password" + e.ToString()); } catch (Exception e) { Assert.IsTrue(false, "Connect attempt with x.509 ident, name wrong password" + e.ToString()); // this is the correct case } }
MQConnection connectToServer(Uri uri, string user, string password) { try { SSLContext ctx = new SSLContext(); ctx.ServerValidator = SafmqSSLTest.ServerValidator; MQBuilder.ctx = ctx; MQConnection con = MQBuilder.BuildConnection(uri, user, password); Assert.IsTrue(con != null, "Successfully Connected"); return(con); } catch (Exception e) { Assert.IsTrue(e == null, e.ToString()); } return(null); }
public void test_DefaultSharedContext() { SSLContext ctx = setupSSL(); MQConnection con; MQBuilder.ctx = ctx; try { con = MQBuilder.BuildConnection(simpleAddress, null, null); con.Close(); } catch (Exception e) { Assert.IsTrue(e == null, "Connect attempt with x.509 ident null ident" + e.ToString()); } try { con = MQBuilder.BuildConnection(simpleAddress, "", ""); con.Close(); } catch (Exception e) { Assert.IsTrue(e == null, "Connect attempt with x.509 ident empty string" + e.ToString()); } try { con = MQBuilder.BuildConnection(simpleAddress, user, null); con.Close(); } catch (Exception e) { Assert.IsTrue(e == null, "Connect attempt with x.509 ident name, null password" + e.ToString()); } try { con = MQBuilder.BuildConnection(simpleAddress, user, ""); con.Close(); } catch (Exception e) { Assert.IsTrue(e == null, "Connect attempt with x.509 ident, name empty password" + e.ToString()); } try { con = MQBuilder.BuildConnection(simpleAddress, user, "12345"); con.Close(); } catch (MQException e) { Assert.IsTrue(e.getErrorcode() == ErrorCode.EC_NOTAUTHORIZED, "Reconnect with x.509 ident, name wrong password" + e.ToString()); } catch (Exception e) { Assert.IsTrue(e != null, "Connect attempt with x.509 ident, name wrong password" + e.ToString()); } }