[Issue(1398, OS = OSID.AnyOSX)] // Cert installation on OSX does not work yet public static void IRequestChannel_Https_NetHttpsBinding() { #if FULLXUNIT_NOTSUPPORTED bool root_Certificate_Installed = Root_Certificate_Installed(); bool ssl_Available = SSL_Available(); if (!root_Certificate_Installed || !ssl_Available) { Console.WriteLine("---- Test SKIPPED --------------"); Console.WriteLine("Attempting to run the test in ToF, a ConditionalFact evaluated as FALSE."); Console.WriteLine("Root_Certificate_Installed evaluated as {0}", root_Certificate_Installed); Console.WriteLine("SSL_Available evaluated as {0}", ssl_Available); return; } #endif IChannelFactory <IRequestChannel> factory = null; IRequestChannel channel = null; Message replyMessage = null; try { // *** SETUP *** \\ NetHttpsBinding binding = new NetHttpsBinding(BasicHttpsSecurityMode.Transport); // Create the channel factory factory = binding.BuildChannelFactory <IRequestChannel>(new BindingParameterCollection()); factory.Open(); // Create the channel. channel = factory.CreateChannel(new EndpointAddress(Endpoints.HttpBaseAddress_NetHttps)); channel.Open(); // Create the Message object to send to the service. Message requestMessage = Message.CreateMessage( binding.MessageVersion, action, new CustomBodyWriter(clientMessage)); // *** EXECUTE *** \\ // Send the Message and receive the Response. replyMessage = channel.Request(requestMessage); // *** VALIDATE *** \\ var replyReader = replyMessage.GetReaderAtBodyContents(); string actualResponse = replyReader.ReadElementContentAsString(); string expectedResponse = "[client] This is my request.[service] Request received, this is my Reply."; Assert.Equal(expectedResponse, actualResponse); // *** CLEANUP *** \\ replyMessage.Close(); channel.Close(); factory.Close(); } finally { // *** ENSURE CLEANUP *** \\ ScenarioTestHelpers.CloseCommunicationObjects(channel, factory); } }
public static void IDuplexSessionChannel_Https_NetHttpsBinding() { IChannelFactory <IDuplexSessionChannel> factory = null; IDuplexSessionChannel channel = null; Message replyMessage = null; try { // *** SETUP *** \\ NetHttpsBinding binding = new NetHttpsBinding(BasicHttpsSecurityMode.Transport); // Create the channel factory factory = binding.BuildChannelFactory <IDuplexSessionChannel>(new BindingParameterCollection()); factory.Open(); // Create the channel. channel = factory.CreateChannel(new EndpointAddress(Endpoints.HttpBaseAddress_NetHttpsWebSockets)); channel.Open(); // Create the Message object to send to the service. Message requestMessage = Message.CreateMessage( binding.MessageVersion, action, new CustomBodyWriter(clientMessage)); requestMessage.Headers.MessageId = new UniqueId(Guid.NewGuid()); // *** EXECUTE *** \\ // Send the Message and receive the Response. channel.Send(requestMessage); replyMessage = channel.Receive(TimeSpan.FromSeconds(5)); // *** VALIDATE *** \\ // If the incoming Message did not contain the same UniqueId used for the MessageId of the outgoing Message we would have received a Fault from the Service string expectedMessageID = requestMessage.Headers.MessageId.ToString(); string actualMessageID = replyMessage.Headers.RelatesTo.ToString(); Assert.True(String.Equals(expectedMessageID, actualMessageID), String.Format("Expected Message ID was {0}. Actual was {1}", expectedMessageID, actualMessageID)); // Validate the Response var replyReader = replyMessage.GetReaderAtBodyContents(); string actualResponse = replyReader.ReadElementContentAsString(); string expectedResponse = "[client] This is my request.[service] Request received, this is my Reply."; Assert.Equal(expectedResponse, actualResponse); // *** CLEANUP *** \\ replyMessage.Close(); channel.Session.CloseOutputSession(); channel.Close(); factory.Close(); } finally { // *** ENSURE CLEANUP *** \\ ScenarioTestHelpers.CloseCommunicationObjects(channel, factory); } }
public static void IRequestChannel_Https_NetHttpsBinding() { IChannelFactory <IRequestChannel> factory = null; IRequestChannel channel = null; Message replyMessage = null; try { // *** SETUP *** \\ NetHttpsBinding binding = new NetHttpsBinding(BasicHttpsSecurityMode.Transport); // Create the channel factory factory = binding.BuildChannelFactory <IRequestChannel>(new BindingParameterCollection()); factory.Open(); // Create the channel. channel = factory.CreateChannel(new EndpointAddress(Endpoints.HttpBaseAddress_NetHttps_Binary)); channel.Open(); // Create the Message object to send to the service. Message requestMessage = Message.CreateMessage( binding.MessageVersion, action, new CustomBodyWriter(clientMessage)); // *** EXECUTE *** \\ // Send the Message and receive the Response. replyMessage = channel.Request(requestMessage); // *** VALIDATE *** \\ var replyReader = replyMessage.GetReaderAtBodyContents(); string actualResponse = replyReader.ReadElementContentAsString(); string expectedResponse = "[client] This is my request.[service] Request received, this is my Reply."; Assert.Equal(expectedResponse, actualResponse); // *** CLEANUP *** \\ replyMessage.Close(); channel.Close(); factory.Close(); } finally { // *** ENSURE CLEANUP *** \\ ScenarioTestHelpers.CloseCommunicationObjects(channel, factory); } }