public void UnknownAuthenticationStep() { var url = "tcp://localhost:8091/CustomAuthenticationTestHost_TcpSimplex"; var protocol = new TcpCustomClientProtocolSetup(true); var credentials = new AnotherBrokenSrpCredentials(); var conn = new ZyanConnection(url, protocol, credentials, true, true); }
public void InvalidLoginUsingTcpSimplexChannel_NoAuthClient() { var url = "tcp://localhost:8091/CustomAuthenticationTestHost_TcpSimplex"; var protocol = new TcpCustomClientProtocolSetup(true); var credentials = new AuthCredentials(UserName, Password); var connection = new ZyanConnection(url, protocol, credentials, true, true); }
public void TestTcpCustomVulnerability(bool encryption, object payload) { var portNumber = 23456; var serverUrl = $"tcp://localhost:{portNumber}/{HostName}"; var serverSetup = new TcpCustomServerProtocolSetup(portNumber, null, encryption); var clientSetup = new TcpCustomClientProtocolSetup(encryption); TestVulnerability(HostName, serverUrl, serverSetup, clientSetup, payload); }
public void InvalidLoginUsingTcpSimplexChannel_NoCredentials() { var url = "tcp://localhost:8091/CustomAuthenticationTestHost_TcpSimplex"; var protocol = new TcpCustomClientProtocolSetup(true); Assert.Throws <SecurityException>(() => { var connection = new ZyanConnection(url, protocol); }); }
public void AuthenticationStep1WasNotPerformed() { var url = "tcp://localhost:8091/CustomAuthenticationTestHost_TcpSimplex"; var protocol = new TcpCustomClientProtocolSetup(true); var credentials = new BrokenSrpCredentials(); Assert.Throws <SecurityException>(() => { var conn = new ZyanConnection(url, protocol, credentials, true, true); }); }
public void InvalidLoginUsingTcpSimplexChannel_NoCredentials() { var url = "tcp://localhost:8091/CustomAuthenticationTestHost_TcpSimplex"; var protocol = new TcpCustomClientProtocolSetup(true); using (var connection = new ZyanConnection(url, protocol)) { var proxy1 = connection.CreateProxy <ISampleServer>("SampleServer"); Assert.AreEqual("Hallo", proxy1.Echo("Hallo")); proxy1 = null; } }
public void TcpCustomUrlValidation() { var protocol = new TcpCustomClientProtocolSetup(); Assert.IsTrue(protocol.IsUrlValid("tcp://localhost:123/server")); Assert.IsTrue(protocol.IsUrlValid("tcp://www.example.com:8080/server")); Assert.IsTrue(protocol.IsUrlValid("tcp://127.0.0.1:8888/index")); Assert.IsTrue(protocol.IsUrlValid("tcp://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index")); Assert.IsFalse(protocol.IsUrlValid(null)); Assert.IsFalse(protocol.IsUrlValid(string.Empty)); Assert.IsFalse(protocol.IsUrlValid("tcp://")); Assert.IsFalse(protocol.IsUrlValid("tcp://host/server")); }
public void InvalidPasswordUsingTcpSimplexChannel() { var url = "tcp://localhost:8091/CustomAuthenticationTestHost_TcpSimplex"; var protocol = new TcpCustomClientProtocolSetup(true); var credentials = new SrpCredentials(UserName, Password + "1", CustomSrpParameters); try { new ZyanConnection(url, protocol, credentials, true, true); } catch (SecurityException ex) { Assert.AreEqual("Authentication failed: bad password or user name", ex.Message); } }
public void CreateDisposeAndRecreateConnectionUsingTcpSimplexChannel() { string url = "tcp://localhost:8085/RecreateClientConnectionTestHost_TcpSimplex"; var protocol = new TcpCustomClientProtocolSetup(true); using (var connection = new ZyanConnection(url, protocol)) { var proxy1 = connection.CreateProxy <ISampleServer>("SampleServer"); Assert.AreEqual("Hallo", proxy1.Echo("Hallo")); proxy1 = null; } using (var connection = new ZyanConnection(url, protocol)) { var proxy2 = connection.CreateProxy <ISampleServer>("SampleServer"); Assert.AreEqual("Hallo", proxy2.Echo("Hallo")); } }
public void InvalidLoginUsingTcpSimplexChannel_NoAuthClient() { var url = "tcp://*****:*****@", "Hello" } }; Assert.Throws <SecurityException>(() => { using (var connection = new ZyanConnection(url, protocol, credentials, true, true)) { var proxy1 = connection.CreateProxy <ISampleServer>("SampleServer"); Assert.AreEqual("Hallo", proxy1.Echo("Hallo")); proxy1 = null; } }); }
public void ValidLoginUsingTcpSimplexChannel() { var url = "tcp://localhost:8091/CustomAuthenticationTestHost_TcpSimplex"; var protocol = new TcpCustomClientProtocolSetup(true); var credentials = new SrpCredentials(UserName, Password, CustomSrpParameters); using (var connection = new ZyanConnection(url, protocol, credentials, true, true)) { var proxy1 = connection.CreateProxy <ISampleServer>("SampleServer"); Assert.AreEqual("Hallo", proxy1.Echo("Hallo")); proxy1 = null; } // reconnect using (var connection = new ZyanConnection(url, protocol, credentials, true, true)) { var proxy2 = connection.CreateProxy <ISampleServer>("SampleServer"); Assert.AreEqual("Hallo", proxy2.Echo("Hallo")); } }
public static int RunTest() { var protocol = new TcpCustomClientProtocolSetup(true) { CompressionThreshold = 1, // compress data packets of any size CompressionMethod = CompressionMethod.LZF }; _connection = new ZyanConnection("tcp://localhost:8083/TcpCustomEventTest", protocol); _proxySingleton = _connection.CreateProxy <IEventComponentSingleton>(); _proxySingleCall = _connection.CreateProxy <IEventComponentSingleCall>(); _proxyCallbackSingleton = _connection.CreateProxy <ICallbackComponentSingleton>(); _proxyCallbackSingleCall = _connection.CreateProxy <ICallbackComponentSingleCall>(); _proxyRequestResponseSingleCall = _connection.CreateProxy <IRequestResponseCallbackSingleCall>(); int successCount = 0; _proxyCallbackSingleton.Out_Callback = CallBackSingleton; _proxyCallbackSingleCall.Out_Callback = CallBackSingleCall; _proxyCallbackSingleton.DoSomething(); if (_callbackCountSingleton == 1) { successCount++; Console.WriteLine("[TCP Custom] Singleton Callback Test passed."); } _proxyCallbackSingleCall.DoSomething(); if (_callbackCountSingleCall == 1) { successCount++; Console.WriteLine("[TCP Custom] SingleCall Callback Test passed."); } RegisterEvents(); if (_registrationsSingleton == _proxySingleton.Registrations) { successCount++; } if (_registrationsSingleCall == _proxySingleCall.Registrations) { successCount++; } _proxySingleton.TriggerEvent(); if (_firedCountSingleton == 1) { successCount++; Console.WriteLine("[TCP Custom] Singleton Event Test passed."); } _proxySingleCall.TriggerEvent(); if (_firedCountSingleCall == 1) { successCount++; Console.WriteLine("[TCP Custom] SingleCall Event Test passed."); } UnregisterEvents(); if (_registrationsSingleton == _proxySingleton.Registrations) { successCount++; } if (_registrationsSingleCall == _proxySingleCall.Registrations) { successCount++; } RequestResponseResult requestResponseResult = new RequestResponseResult("TCP Custom"); _proxyRequestResponseSingleCall.DoRequestResponse("Success", requestResponseResult.ReceiveResponseSingleCall); Thread.Sleep(1000); if (requestResponseResult.Count == 1) { successCount++; } _connection.Dispose(); if (successCount == 9) { return(0); } else { return(1); } }