Ejemplo n.º 1
0
        public void BuildFrontEndTest_Http()
        {
            SessionStartInfoContract info = new SessionStartInfoContract();

            info.ServiceName     = "CcpEchoSvc";
            info.TransportScheme = TransportScheme.Http;
            info.Secure          = true;
            BrokerStartInfo         startInfo = new BrokerStartInfo();
            MockBrokerAuthorization auth      = new MockBrokerAuthorization();

            string filename             = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
            ExeConfigurationFileMap map = new ExeConfigurationFileMap();

            map.ExeConfigFilename = filename;
            Configuration        config       = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
            BrokerConfigurations brokerConfig = BrokerConfigurations.GetSectionGroup(config);

            startInfo.Durable           = false;
            startInfo.SessionId         = "100";
            startInfo.ConfigurationFile = "CcpEchoSvc.config";


            ConfigurationHelper.LoadConfiguration(info, startInfo, out brokerConfig, out var serviceConfig, out var bindings);


            var sharedData = new SharedData(startInfo, info, brokerConfig, serviceConfig);
            var result     = FrontEndBuilder.BuildFrontEnd(sharedData, new BrokerObserver(sharedData, new ClientInfo[0]), null, null, bindings, null);


            Assert.IsTrue(Regex.IsMatch(result.ControllerUriList[1], @"https://.+/100/Http/Controller"));
            Assert.AreEqual(null, result.GetResponseUriList.FirstOrDefault());
            Assert.IsTrue(Regex.IsMatch(result.FrontendUriList[1], @"https://.+/100/Http"));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Send message with security
        /// </summary>
        //[TestMethod]
        public void SendMessageWithSecurity()
        {
            string uri = String.Format("https://{0}:8080", Environment.MachineName);

            // Open frontend
            Uri listenUri            = new Uri(uri);
            BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);

            binding.Security.Message.ClientCredentialType   = BasicHttpMessageCredentialType.UserName;
            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
            MockBrokerAuthorization auth  = new MockBrokerAuthorization();
            MockBrokerQueue         queue = new MockBrokerQueue();

            queue.DirectReply = true;
            RequestReplyFrontEnd <IReplyChannel> target = new RequestReplyFrontEnd <IReplyChannel>(listenUri, binding, auth, queue);

            target.Open();

            // Build channel to send request
            MockWCFClient client = new MockWCFClient(binding, new EndpointAddress(uri));

            client.ClientCredentials.UserName.UserName = "******";
            client.ClientCredentials.UserName.Password = "******";

            auth.Allow = false;
            try
            {
                client.Calc(3);
            }
            catch (FaultException fe)
            {
                Assert.AreEqual(fe.Code.Name, "AuthenticationFailure");
            }

            // Send request which is allowed
            auth.Allow = true;
            try
            {
                client.Calc(4);
            }
            catch (FaultException fe)
            {
                Assert.AreEqual(fe.Code.Name, "DummyReply");
            }

            client.Close();
            target.Close();
        }
Ejemplo n.º 3
0
        public void SendRequestTestWithSecurity()
        {
            string uri = "net.tcp://localhost:8889";

            // Open frontend
            Uri                     listenUri = new Uri(uri);
            NetTcpBinding           binding   = new NetTcpBinding(SecurityMode.Transport);
            MockBrokerQueue         queue     = new MockBrokerQueue();
            MockBrokerAuthorization auth      = new MockBrokerAuthorization();

            queue.DirectReply = true;
            DuplexFrontEnd target = new DuplexFrontEnd(listenUri, binding, auth, queue);

            target.Open();

            MockWCFClient client = new MockWCFClient(binding, new EndpointAddress(uri));

            auth.Allow = true;
            try
            {
                client.Calc(4);
            }
            catch (FaultException fe)
            {
                Assert.AreEqual(fe.Code.SubCode.Name, "DummyReply");
            }

            auth.Allow = false;
            try
            {
                client.Calc(4);
            }
            catch (FaultException fe)
            {
                Assert.AreEqual(fe.Code.SubCode.Name, "AuthenticationFailure");
            }

            target.Close();
        }