Esempio n. 1
0
        public void Can_make_authenticated_requests_with_MQ()
        {
            using (var appHost = new AppHost(() => CreateMqServer()).Init())
            {
                appHost.Start(Config.ListeningOn);

                var client = new JsonServiceClient(Config.ListeningOn);

                var response = client.Post(new Authenticate
                {
                    UserName = "******",
                    Password = "******"
                });

                var sessionId = response.SessionId;

                using (var mqClient = appHost.Resolve <IMessageService>().CreateMessageQueueClient())
                {
                    mqClient.Publish(new MqAuthOnly
                    {
                        Name      = "MQ Auth",
                        SessionId = sessionId,
                    });

                    var responseMsg = mqClient.Get <MqAuthOnlyResponse>(QueueNames <MqAuthOnlyResponse> .In);
                    mqClient.Ack(responseMsg);
                    Assert.That(responseMsg.GetBody().Result,
                                Is.EqualTo("Hello, MQ Auth! Your UserName is mythz"));
                }
            }
        }
Esempio n. 2
0
        public void Can_make_authenticated_requests_with_MQ_BearerToken()
        {
            using var appHost = new AppHost(() => CreateMqServer()).Init();
            appHost.Start(Config.ListeningOn);

            var client = new JsonServiceClient(Config.ListeningOn);

            var response = client.Post(new Authenticate
            {
                provider = "credentials",
                UserName = "******",
                Password = "******"
            });

            using var mqClient = appHost.Resolve <IMessageService>().CreateMessageQueueClient();
            mqClient.Publish(new MqAuthOnlyToken
            {
                Name        = "MQ AuthToken",
                BearerToken = response.BearerToken,
            });

            var responseMsg = mqClient.Get <MqAuthOnlyResponse>(QueueNames <MqAuthOnlyResponse> .In);

            mqClient.Ack(responseMsg);
            Assert.That(responseMsg.GetBody().Result,
                        Is.EqualTo("Hello, MQ AuthToken! Your UserName is mythz"));
        }