Beispiel #1
0
        public void AuthenticationSuccess()
        {
            JsonFormatter formatter = new JsonFormatter();
            WampCraPlayground<JToken> playground = new WampCraPlayground<JToken>
                (formatter, new MockWampCraAuthenticaticationBuilder<JToken>());

            IWampChannelFactory<JToken> channelFactory = playground.ChannelFactory;

            IWampHost host = playground.Host;

            host.HostService(new Sample());

            host.Open();

            IControlledWampConnection<JToken> connection = playground.CreateClientConnection();

            IWampChannel<JToken> channel = channelFactory.CreateChannel(connection);

            channel.Open();

            channel.GetRpcProxy<IWampCraProcedures>().
                    Authenticate(formatter, "foobar", null, "secret");

            string result = channel.GetRpcProxy<ISample>()
                                   .Hello("Foobar");

            Assert.IsNotNullOrEmpty(result);
        }
Beispiel #2
0
        public void AuthenticationFailure()
        {
            JsonFormatter formatter = new JsonFormatter();
            WampCraPlayground<JToken> playground = new WampCraPlayground<JToken>
                (formatter, new MockWampCraAuthenticaticationBuilder<JToken>());

            IWampChannelFactory<JToken> channelFactory = playground.ChannelFactory;

            IWampHost host = playground.Host;

            host.HostService(new Sample());

            host.Open();

            IControlledWampConnection<JToken> connection = playground.CreateClientConnection();

            IWampChannel<JToken> channel = channelFactory.CreateChannel(connection);

            channel.Open();

            IWampCraProcedures proceduresProxy = channel.GetRpcProxy<IWampCraProcedures>();

            WampRpcCallException callException =
                Assert.Throws<WampRpcCallException>
                    (() => proceduresProxy.Authenticate(formatter, "foobar", null, "secret2"));
        }
Beispiel #3
0
        public void NoAuthenticationThrowsException()
        {
            JsonFormatter formatter = new JsonFormatter();
            WampCraPlayground <JToken> playground = new WampCraPlayground <JToken>
                                                        (formatter, new MockWampCraAuthenticaticationBuilder <JToken>());

            IWampChannelFactory <JToken> channelFactory = playground.ChannelFactory;

            IWampHost host = playground.Host;

            host.HostService(new Sample());

            host.Open();

            IControlledWampConnection <JToken> connection = playground.CreateClientConnection();

            IWampChannel <JToken> channel = channelFactory.CreateChannel(connection);

            channel.Open();

            Task <string> result =
                channel.GetRpcProxy <ISampleAsync>()
                .Hello("Foobar");

            AggregateException   aggregateException = result.Exception;
            Exception            exception          = aggregateException.InnerException;
            WampRpcCallException casted             = exception as WampRpcCallException;

            Assert.IsNotNull(casted);
        }
Beispiel #4
0
        public void AuthenticationFailure()
        {
            JsonFormatter formatter = new JsonFormatter();
            WampCraPlayground <JToken> playground = new WampCraPlayground <JToken>
                                                        (formatter, new MockWampCraAuthenticaticationBuilder <JToken>());

            IWampChannelFactory <JToken> channelFactory = playground.ChannelFactory;

            IWampHost host = playground.Host;

            host.HostService(new Sample());

            host.Open();

            IControlledWampConnection <JToken> connection = playground.CreateClientConnection();

            IWampChannel <JToken> channel = channelFactory.CreateChannel(connection);

            channel.Open();

            IWampCraProcedures proceduresProxy = channel.GetRpcProxy <IWampCraProcedures>();

            WampRpcCallException callException =
                Assert.Throws <WampRpcCallException>
                    (() => proceduresProxy.Authenticate(formatter, "foobar", null, "secret2"));
        }
Beispiel #5
0
        public void AuthenticationSuccess()
        {
            JsonFormatter formatter = new JsonFormatter();
            WampCraPlayground <JToken> playground = new WampCraPlayground <JToken>
                                                        (formatter, new MockWampCraAuthenticaticationBuilder <JToken>());

            IWampChannelFactory <JToken> channelFactory = playground.ChannelFactory;

            IWampHost host = playground.Host;

            host.HostService(new Sample());

            host.Open();

            IControlledWampConnection <JToken> connection = playground.CreateClientConnection();

            IWampChannel <JToken> channel = channelFactory.CreateChannel(connection);

            channel.Open();

            channel.GetRpcProxy <IWampCraProcedures>().
            Authenticate(formatter, "foobar", null, "secret");

            string result = channel.GetRpcProxy <ISample>()
                            .Hello("Foobar");

            Assert.That(result, Is.Not.Null.Or.Empty);
        }
Beispiel #6
0
        public void NoAuthenticationThrowsException()
        {
            JsonFormatter formatter = new JsonFormatter();
            WampCraPlayground<JToken> playground = new WampCraPlayground<JToken>
                (formatter, new MockWampCraAuthenticaticationBuilder<JToken>());

            IWampChannelFactory<JToken> channelFactory = playground.ChannelFactory;

            IWampHost host = playground.Host;

            host.HostService(new Sample());

            host.Open();

            IControlledWampConnection<JToken> connection = playground.CreateClientConnection();

            IWampChannel<JToken> channel = channelFactory.CreateChannel(connection);

            channel.Open();

            Task<string> result =
                channel.GetRpcProxy<ISampleAsync>()
                   .Hello("Foobar");

            AggregateException aggregateException = result.Exception;
            Exception exception = aggregateException.InnerException;
            WampRpcCallException casted = exception as WampRpcCallException;

            Assert.IsNotNull(casted);
        }