public void GetMatchedIntegrationConfig_OneTrigger_And_NotMatched_UserAgent()
        {
            var testObject = new IntegrationEvaluator();

            var customerIntegration = new CustomerIntegration()
            {
                Integrations = new List <IntegrationConfigModel> {
                    new IntegrationConfigModel()
                    {
                        Name     = "integration1",
                        Triggers = new List <TriggerModel>()
                        {
                            new TriggerModel()
                            {
                                LogicalOperator = LogicalOperatorType.And,
                                TriggerParts    = new List <TriggerPart>()
                                {
                                    new TriggerPart()
                                    {
                                        CookieName     = "c1",
                                        Operator       = ComparisonOperatorType.EqualS,
                                        IsIgnoreCase   = true,
                                        ValueToCompare = "value1",
                                        ValidatorType  = ValidatorType.CookieValidator
                                    },
                                    new TriggerPart()
                                    {
                                        UrlPart        = UrlPartType.PageUrl,
                                        ValidatorType  = ValidatorType.UrlValidator,
                                        ValueToCompare = "test",
                                        Operator       = ComparisonOperatorType.Contains
                                    },
                                    new TriggerPart()
                                    {
                                        ValidatorType  = ValidatorType.UserAgentValidator,
                                        ValueToCompare = "Googlebot",
                                        Operator       = ComparisonOperatorType.Contains,
                                        IsIgnoreCase   = true,
                                        IsNegative     = true
                                    }
                                }
                            }
                        }
                    }
                }
            };


            var url = new Uri("http://test.tesdomain.com:8080/test?q=2");

            var httpRequestMock = MockRepository.GenerateMock <HttpRequestBase>();

            httpRequestMock.Stub(r => r.Cookies).Return(new HttpCookieCollection()
            {
                new HttpCookie("c1", "Value1")
            });
            httpRequestMock.Stub(r => r.UserAgent).Return("bot.html google.com googlebot test");

            Assert.True(testObject.GetMatchedIntegrationConfig(customerIntegration, url.AbsoluteUri, httpRequestMock) == null);
        }
示例#2
0
        public void GetMatchedIntegrationConfig_OneTrigger_And_NotMatched_UserAgent()
        {
            var testObject = new IntegrationEvaluator();

            var customerIntegration = new CustomerIntegration
            {
                Integrations = new List <IntegrationConfigModel>
                {
                    new IntegrationConfigModel
                    {
                        Name     = "integration1",
                        Triggers = new List <TriggerModel>
                        {
                            new TriggerModel
                            {
                                LogicalOperator = LogicalOperatorType.And,
                                TriggerParts    = new List <TriggerPart>
                                {
                                    new TriggerPart
                                    {
                                        CookieName     = "c1",
                                        Operator       = ComparisonOperatorType.EqualS,
                                        IsIgnoreCase   = true,
                                        ValueToCompare = "value1",
                                        ValidatorType  = ValidatorType.CookieValidator
                                    },
                                    new TriggerPart
                                    {
                                        UrlPart        = UrlPartType.PageUrl,
                                        ValidatorType  = ValidatorType.UrlValidator,
                                        ValueToCompare = "test",
                                        Operator       = ComparisonOperatorType.Contains
                                    },
                                    new TriggerPart
                                    {
                                        ValidatorType  = ValidatorType.UserAgentValidator,
                                        ValueToCompare = "Googlebot",
                                        Operator       = ComparisonOperatorType.Contains,
                                        IsIgnoreCase   = true,
                                        IsNegative     = true
                                    }
                                }
                            }
                        }
                    }
                }
            };

            var url = new Uri("http://test.tesdomain.com:8080/test?q=2");

            var httpRequestMock = new KnownUserTest.MockHttpRequest
            {
                CookiesValue = new NameValueCollection {
                    { "c1", "Value1" }
                },
                UserAgent = "bot.html google.com googlebot test"
            };

            Assert.True(testObject.GetMatchedIntegrationConfig(customerIntegration, url.AbsoluteUri, httpRequestMock) == null);
        }
        // PUT api/customers/{$id}?token={$token}/
        // FEATURE: Modificar cliente existente
        public HttpResponseMessage Put(string id, [FromBody] Customer jsonObject, [FromUri] string token)
        {
            if (Authentication.VerifyToken(token))
            {
                try
                {
                    var operationResult = CustomerIntegration.Update(Authentication.GetRepresentative(token), Encoding.UTF8.GetString(Convert.FromBase64String(id)), jsonObject);

                    if (operationResult == null)
                    {
                        return(Request.CreateResponse(HttpStatusCode.NotFound));
                    }
                    else
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, operationResult));
                    }
                }
                catch (Exception ex)
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message));
                }
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.Forbidden));
            }
        }
        public void GetMatchedIntegrationConfig_TwoTriggers_Matched()
        {
            var testObject          = new IntegrationEvaluator();
            var customerIntegration = new CustomerIntegration()
            {
                Integrations = new List <IntegrationConfigModel> {
                    new IntegrationConfigModel()
                    {
                        Name     = "integration1",
                        Triggers = new List <TriggerModel>()
                        {
                            new TriggerModel()
                            {
                                LogicalOperator = LogicalOperatorType.And,
                                TriggerParts    = new List <TriggerPart>()
                                {
                                    new TriggerPart()
                                    {
                                        CookieName     = "c1",
                                        Operator       = ComparisonOperatorType.EqualS,
                                        ValueToCompare = "value1",
                                        ValidatorType  = ValidatorType.CookieValidator
                                    }
                                }
                            },
                            new TriggerModel()
                            {
                                LogicalOperator = LogicalOperatorType.And,
                                TriggerParts    = new List <TriggerPart>()
                                {
                                    new TriggerPart()
                                    {
                                        UrlPart        = UrlPartType.PageUrl,
                                        ValidatorType  = ValidatorType.UrlValidator,
                                        ValueToCompare = "*",
                                        Operator       = ComparisonOperatorType.Contains
                                    }
                                }
                            }
                        }
                    }
                }
            };


            var url = new Uri("http://test.tesdomain.com:8080/test?q=2");

            var httpRequestMock = MockRepository.GenerateMock <HttpRequestBase>();

            httpRequestMock.Stub(r => r.Cookies).Return(new HttpCookieCollection());
            httpRequestMock.Stub(r => r.UserAgent).Return(string.Empty);

            Assert.True(testObject.GetMatchedIntegrationConfig(customerIntegration, url.AbsoluteUri, httpRequestMock).Name == "integration1", string.Empty);
        }
示例#5
0
        public void GetMatchedIntegrationConfig_TwoTriggers_Matched()
        {
            var testObject          = new IntegrationEvaluator();
            var customerIntegration = new CustomerIntegration()
            {
                Integrations = new List <IntegrationConfigModel> {
                    new IntegrationConfigModel()
                    {
                        Name     = "integration1",
                        Triggers = new List <TriggerModel>()
                        {
                            new TriggerModel()
                            {
                                LogicalOperator = LogicalOperatorType.And,
                                TriggerParts    = new List <TriggerPart>()
                                {
                                    new TriggerPart()
                                    {
                                        CookieName     = "c1",
                                        Operator       = ComparisonOperatorType.EqualS,
                                        ValueToCompare = "value1",
                                        ValidatorType  = ValidatorType.CookieValidator
                                    }
                                }
                            },
                            new TriggerModel()
                            {
                                LogicalOperator = LogicalOperatorType.And,
                                TriggerParts    = new List <TriggerPart>()
                                {
                                    new TriggerPart()
                                    {
                                        UrlPart        = UrlPartType.PageUrl,
                                        ValidatorType  = ValidatorType.UrlValidator,
                                        ValueToCompare = "*",
                                        Operator       = ComparisonOperatorType.Contains
                                    }
                                }
                            }
                        }
                    }
                }
            };


            var url = new Uri("http://test.tesdomain.com:8080/test?q=2");


            Assert.True(testObject.GetMatchedIntegrationConfig(customerIntegration, url.AbsoluteUri,
                                                               new HttpCookieCollection()
            {
            }).Name == "integration1");
        }
        public void GetMatchedIntegrationConfig_OneTrigger_And_Matched()
        {
            var testObject = new IntegrationEvaluator();

            var customerIntegration = new CustomerIntegration()
            {
                Integrations = new List <IntegrationConfigModel> {
                    new IntegrationConfigModel()
                    {
                        Name     = "integration1",
                        Triggers = new List <TriggerModel>()
                        {
                            new TriggerModel()
                            {
                                LogicalOperator = LogicalOperatorType.And,
                                TriggerParts    = new List <TriggerPart>()
                                {
                                    new TriggerPart()
                                    {
                                        CookieName     = "c1",
                                        Operator       = ComparisonOperatorType.EqualS,
                                        IsIgnoreCase   = true,
                                        ValueToCompare = "value1",
                                        ValidatorType  = ValidatorType.CookieValidator
                                    },
                                    new TriggerPart()
                                    {
                                        UrlPart        = UrlPartType.PageUrl,
                                        ValidatorType  = ValidatorType.UrlValidator,
                                        ValueToCompare = "test",
                                        Operator       = ComparisonOperatorType.Contains
                                    }
                                }
                            }
                        }
                    }
                }
            };


            var url = new Uri("http://test.tesdomain.com:8080/test?q=2");


            var httpRequestMock = new KnownUserTest.MockHttpRequest()
            {
                CookiesValue = new NameValueCollection()
                {
                    { "c1", "Value1" }
                }
            };

            Assert.True(testObject.GetMatchedIntegrationConfig(customerIntegration, url.AbsoluteUri, httpRequestMock).Name == "integration1");
        }
        public void ValidateRequestByIntegrationConfig_Test()
        {
            // Arrange
            UserInQueueServiceMock mock = new UserInQueueServiceMock();

            KnownUser._UserInQueueService = (mock);

            TriggerPart triggerPart = new TriggerPart();

            triggerPart.Operator       = "Contains";
            triggerPart.ValueToCompare = "event1";
            triggerPart.UrlPart        = "PageUrl";
            triggerPart.ValidatorType  = "UrlValidator";
            triggerPart.IsNegative     = false;
            triggerPart.IsIgnoreCase   = true;

            TriggerModel trigger = new TriggerModel();

            trigger.LogicalOperator = "And";
            trigger.TriggerParts    = new TriggerPart[] { triggerPart };

            IntegrationConfigModel config = new IntegrationConfigModel();

            config.Name = "event1action";
            //config.ActionType = "Queue";
            config.EventId              = "event1";
            config.CookieDomain         = ".test.com";
            config.LayoutName           = "Christmas Layout by Queue-it";
            config.Culture              = "da-DK";
            config.ExtendCookieValidity = true;
            config.CookieValidityMinute = 20;
            config.Triggers             = new TriggerModel[] { trigger };
            config.QueueDomain          = "knownusertest.queue-it.net";
            config.RedirectLogic        = "AllowTParameter";
            config.ForcedTargetUrl      = "";

            CustomerIntegration customerIntegration = new CustomerIntegration();

            customerIntegration.Integrations = new IntegrationConfigModel[] { config };
            customerIntegration.Version      = 3;

            // Act
            KnownUser.ValidateRequestByIntegrationConfig("http://test.com?event1=true", "queueitToken", customerIntegration, "customerId", "secretKey");

            // Assert
            Assert.True(mock.validateRequestCalls.Count == 1);
            Assert.Equal("http://test.com?event1=true", mock.validateRequestCalls[0][0]);
            Assert.Equal("queueitToken", mock.validateRequestCalls[0][1]);
            Assert.Equal(".test.com:Christmas Layout by Queue-it:da-DK:event1:knownusertest.queue-it.net:true:20:3", mock.validateRequestCalls[0][2]);
            Assert.Equal("customerId", mock.validateRequestCalls[0][3]);
            Assert.Equal("secretKey", mock.validateRequestCalls[0][4]);
        }
示例#8
0
        public void GetMatchedIntegrationConfig_TwoTriggers_NotMatched()
        {
            var testObject          = new IntegrationEvaluator();
            var customerIntegration = new CustomerIntegration
            {
                Integrations = new List <IntegrationConfigModel>
                {
                    new IntegrationConfigModel
                    {
                        Name     = "integration1",
                        Triggers = new List <TriggerModel>
                        {
                            new TriggerModel
                            {
                                LogicalOperator = LogicalOperatorType.And,
                                TriggerParts    = new List <TriggerPart>
                                {
                                    new TriggerPart
                                    {
                                        CookieName     = "c1",
                                        Operator       = ComparisonOperatorType.EqualS,
                                        ValueToCompare = "value1",
                                        ValidatorType  = ValidatorType.CookieValidator
                                    }
                                }
                            },
                            new TriggerModel
                            {
                                LogicalOperator = LogicalOperatorType.And,
                                TriggerParts    = new List <TriggerPart>
                                {
                                    new TriggerPart
                                    {
                                        UrlPart        = UrlPartType.PageUrl,
                                        ValidatorType  = ValidatorType.UrlValidator,
                                        ValueToCompare = "tesT",
                                        Operator       = ComparisonOperatorType.Contains
                                    }
                                }
                            }
                        }
                    }
                }
            };

            var url = new Uri("http://test.tesdomain.com:8080/test?q=2");

            var httpRequestMock = new KnownUserTest.MockHttpRequest();

            Assert.True(testObject.GetMatchedIntegrationConfig(customerIntegration, url.AbsoluteUri, httpRequestMock) == null);
        }
示例#9
0
        public void GetMatchedIntegrationConfig_OneTrigger_Or_NotMatched()
        {
            var testObject          = new IntegrationEvaluator();
            var customerIntegration = new CustomerIntegration()
            {
                Integrations = new List <IntegrationConfigModel> {
                    new IntegrationConfigModel()
                    {
                        Name     = "integration1",
                        Triggers = new List <TriggerModel>()
                        {
                            new TriggerModel()
                            {
                                LogicalOperator = LogicalOperatorType.Or,
                                TriggerParts    = new List <TriggerPart>()
                                {
                                    new TriggerPart()
                                    {
                                        CookieName     = "c1",
                                        Operator       = ComparisonOperatorType.EqualS,
                                        ValueToCompare = "value1",
                                        ValidatorType  = ValidatorType.CookieValidator
                                    },
                                    new TriggerPart()
                                    {
                                        UrlPart        = UrlPartType.PageUrl,
                                        ValidatorType  = ValidatorType.UrlValidator,
                                        IsIgnoreCase   = true,
                                        IsNegative     = true,
                                        ValueToCompare = "tesT",
                                        Operator       = ComparisonOperatorType.Contains
                                    }
                                }
                            }
                        }
                    }
                }
            };


            var url = new Uri("http://test.tesdomain.com:8080/test?q=2");



            Assert.True(testObject.GetMatchedIntegrationConfig(customerIntegration, url.AbsoluteUri,
                                                               new HttpCookieCollection()
            {
                new HttpCookie("c2", "value1")
            }) == null);
        }
        private static void RefreshCache(bool init)
        {
            int tryCount = 0;

            while (tryCount < 5)
            {
                var configUrl = string.Format("https://{0}.queue-it.net/status/integrationconfig/secure/{0}", _customerId);
                try
                {
                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(configUrl);
                    request.Headers.Add("api-key", _apiKey);
                    request.Timeout = _downloadTimeoutMS;
                    using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                    {
                        if (response.StatusCode != HttpStatusCode.OK)
                        {
                            throw new Exception($"It was not sucessful retriving config file status code {response.StatusCode} from {configUrl}");
                        }
                        using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                        {
                            JavaScriptSerializer deserializer = new JavaScriptSerializer();
                            var deserialized = deserializer.Deserialize <CustomerIntegration>(reader.ReadToEnd());
                            if (deserialized == null)
                            {
                                throw new Exception("CustomerIntegration is null");
                            }
                            _cachedIntegrationConfig = deserialized;
                        }
                        return;
                    }
                }
                catch (Exception ex)
                {
                    ++tryCount;
                    if (tryCount >= 5)
                    {
                        //Use your favorit logging framework to log the exceptoin
                        break;
                    }
                    if (!init)
                    {
                        System.Threading.Thread.Sleep(TimeSpan.FromSeconds(_RetryExceptionSleepS));
                    }
                    else
                    {
                        System.Threading.Thread.Sleep(TimeSpan.FromSeconds(0.200 * tryCount));
                    }
                }
            }
        }
示例#11
0
        private static void RefreshCache(bool init)
        {
            int tryCount = 0;

            while (tryCount < 5)
            {
                var timeBaseQueryString = (DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds.ToString();
                var configUrl           = string.Format("https://assets.queue-it.net/{0}/integrationconfig/json/integrationInfo.json?qr={1}", _customerId, timeBaseQueryString);
                try
                {
                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(configUrl);
                    request.Timeout = _downloadTimeoutMS;
                    using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                    {
                        if (response.StatusCode != HttpStatusCode.OK)
                        {
                            throw new Exception($"It was not sucessful retriving config file status code {response.StatusCode} from {configUrl}");
                        }
                        using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                        {
                            JavaScriptSerializer deserializer = new JavaScriptSerializer();
                            var deserialized = deserializer.Deserialize <CustomerIntegration>(reader.ReadToEnd());
                            if (deserialized == null)
                            {
                                throw new Exception("CustomerIntegration is null");
                            }
                            _cachedIntegrationConfig = deserialized;
                        }
                        return;
                    }
                }
                catch (Exception ex)
                {
                    ++tryCount;
                    if (tryCount >= 5)
                    {
                        //Use your favorit logging framework to log the exceptoin
                        break;
                    }
                    if (!init)
                    {
                        System.Threading.Thread.Sleep(TimeSpan.FromSeconds(_RetryExceptionSleepS));
                    }
                    else
                    {
                        System.Threading.Thread.Sleep(TimeSpan.FromSeconds(0.200 * tryCount));
                    }
                }
            }
        }
        private static RequestValidationResult HandleCancelAction(
            string currentUrlWithoutQueueITToken, string queueitToken,
            CustomerIntegration customerIntegrationInfo, string customerId,
            string secretKey, Dictionary <string, string> debugEntries,
            IntegrationConfigModel matchedConfig)
        {
            var cancelEventConfig = new CancelEventConfig()
            {
                QueueDomain  = matchedConfig.QueueDomain,
                EventId      = matchedConfig.EventId,
                Version      = customerIntegrationInfo.Version,
                CookieDomain = matchedConfig.CookieDomain
            };
            var targetUrl = GenerateTargetUrl(currentUrlWithoutQueueITToken);

            return(CancelRequestByLocalConfig(targetUrl, queueitToken, cancelEventConfig, customerId, secretKey, debugEntries));
        }
示例#13
0
        private static RequestValidationResult HandleQueueAction(
            string currentUrlWithoutQueueITToken,
            string queueitToken,
            CustomerIntegration customerIntegrationInfo,
            string customerId,
            string secretKey,
            Dictionary <string, string> debugEntries,
            IntegrationConfigModel matchedConfig,
            bool isDebug)
        {
            var targetUrl = "";

            switch (matchedConfig.RedirectLogic)
            {
            case "ForcedTargetUrl":
            case "ForecedTargetUrl":
                targetUrl = matchedConfig.ForcedTargetUrl;
                break;

            case "EventTargetUrl":
                targetUrl = "";
                break;

            default:
                targetUrl = GenerateTargetUrl(currentUrlWithoutQueueITToken);
                break;
            }

            var queueEventConfig = new QueueEventConfig
            {
                QueueDomain          = matchedConfig.QueueDomain,
                Culture              = matchedConfig.Culture,
                EventId              = matchedConfig.EventId,
                ExtendCookieValidity = matchedConfig.ExtendCookieValidity.Value,
                LayoutName           = matchedConfig.LayoutName,
                CookieValidityMinute = matchedConfig.CookieValidityMinute.Value,
                CookieDomain         = matchedConfig.CookieDomain,
                IsCookieHttpOnly     = matchedConfig.IsCookieHttpOnly ?? false,
                IsCookieSecure       = matchedConfig.IsCookieSecure ?? false,
                Version              = customerIntegrationInfo.Version,
                ActionName           = matchedConfig.Name
            };

            return(ResolveQueueRequestByLocalConfig(targetUrl, queueitToken, queueEventConfig, customerId, secretKey, debugEntries, isDebug));
        }
 // GET api/customers?token={$token}/
 // FEATURE: Listar clientes
 public HttpResponseMessage Get([FromUri] string token)
 {
     if (Authentication.VerifyToken(token))
     {
         try
         {
             return(Request.CreateResponse(HttpStatusCode.OK, CustomerIntegration.List(Authentication.GetRepresentative(token))));
         }
         catch (Exception ex)
         {
             return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message));
         }
     }
     else
     {
         return(Request.CreateResponse(HttpStatusCode.Forbidden));
     }
 }
示例#15
0
        private static RequestValidationResult HandleCancelAction(
            string currentUrlWithoutQueueITToken, string queueitToken,
            CustomerIntegration customerIntegrationInfo, string customerId,
            string secretKey, Dictionary <string, string> debugEntries,
            IntegrationConfigModel matchedConfig, bool isDebug)
        {
            var cancelEventConfig = new CancelEventConfig
            {
                QueueDomain      = matchedConfig.QueueDomain,
                EventId          = matchedConfig.EventId,
                Version          = customerIntegrationInfo.Version,
                CookieDomain     = matchedConfig.CookieDomain,
                IsCookieHttpOnly = matchedConfig.IsCookieHttpOnly ?? false,
                IsCookieSecure   = matchedConfig.IsCookieSecure ?? false,
                ActionName       = matchedConfig.Name
            };

            return(CancelRequestByLocalConfig(currentUrlWithoutQueueITToken, queueitToken, cancelEventConfig, customerId, secretKey, debugEntries, isDebug));
        }
        public void GetMatchedIntegrationConfig_OneTrigger_And_NotMatched()
        {
            var testObject = new IntegrationEvaluator();

            var customerIntegration = new CustomerIntegration()
            {
                Integrations = new List <IntegrationConfigModel> {
                    new IntegrationConfigModel()
                    {
                        Triggers = new List <TriggerModel>()
                        {
                            new TriggerModel()
                            {
                                LogicalOperator = LogicalOperatorType.Or,
                                TriggerParts    = new List <TriggerPart>()
                                {
                                    new TriggerPart()
                                    {
                                        CookieName     = "c1",
                                        Operator       = ComparisonOperatorType.EqualS,
                                        ValueToCompare = "value1",
                                        ValidatorType  = ValidatorType.CookieValidator
                                    },
                                    new TriggerPart()
                                    {
                                        ValidatorType  = ValidatorType.UserAgentValidator,
                                        ValueToCompare = "test",
                                        Operator       = ComparisonOperatorType.Contains
                                    }
                                }
                            }
                        }
                    }
                }
            };

            var url = new Uri("http://test.tesdomain.com:8080/test?q=2");



            Assert.True(testObject.GetMatchedIntegrationConfig(customerIntegration, url.AbsoluteUri,
                                                               new KnownUserTest.MockHttpRequest()) == null);
        }
        public void ValidateRequestByIntegrationConfig_NotMatch_Test()
        {
            // Arrange
            UserInQueueServiceMock mock = new UserInQueueServiceMock();

            KnownUser._UserInQueueService = (mock);

            CustomerIntegration customerIntegration = new CustomerIntegration();

            customerIntegration.Integrations = new IntegrationConfigModel[0];
            customerIntegration.Version      = 3;

            // Act
            RequestValidationResult result = KnownUser.ValidateRequestByIntegrationConfig("http://test.com?event1=true", "queueitToken", customerIntegration, "customerId", "secretKey");

            // Assert
            Assert.True(mock.validateRequestCalls.Count == 0);
            Assert.False(result.DoRedirect);
        }
示例#18
0
        public void GetMatchedIntegrationConfig_ThreeIntegrationsInOrder_SecondMatched()
        {
            var testObject          = new IntegrationEvaluator();
            var customerIntegration = new CustomerIntegration
            {
                Integrations = new List <IntegrationConfigModel>
                {
                    new IntegrationConfigModel
                    {
                        Name     = "integration0",
                        Triggers = new List <TriggerModel>
                        {
                            new TriggerModel
                            {
                                LogicalOperator = LogicalOperatorType.And,
                                TriggerParts    = new List <TriggerPart>
                                {
                                    new TriggerPart
                                    {
                                        CookieName     = "c1",
                                        Operator       = ComparisonOperatorType.EqualS,
                                        ValueToCompare = "value1",
                                        ValidatorType  = ValidatorType.CookieValidator
                                    }
                                }
                            }
                        }
                    },
                    new IntegrationConfigModel
                    {
                        Name     = "integration1",
                        Triggers = new List <TriggerModel>
                        {
                            new TriggerModel
                            {
                                LogicalOperator = LogicalOperatorType.And,
                                TriggerParts    = new List <TriggerPart>
                                {
                                    new TriggerPart
                                    {
                                        CookieName     = "c1",
                                        Operator       = ComparisonOperatorType.EqualS,
                                        ValueToCompare = "Value1",
                                        ValidatorType  = ValidatorType.CookieValidator
                                    }
                                }
                            }
                        }
                    },
                    new IntegrationConfigModel
                    {
                        Name     = "integration2",
                        Triggers = new List <TriggerModel>
                        {
                            new TriggerModel
                            {
                                LogicalOperator = LogicalOperatorType.And,
                                TriggerParts    = new List <TriggerPart>
                                {
                                    new TriggerPart
                                    {
                                        UrlPart  = UrlPartType.PageUrl,
                                        Operator = ComparisonOperatorType.Contains,

                                        ValueToCompare = "test",
                                        ValidatorType  = ValidatorType.UrlValidator
                                    }
                                }
                            }
                        }
                    }
                }
            };

            var url = new Uri("http://test.tesdomain.com:8080/test?q=2");

            var httpRequestMock = new KnownUserTest.MockHttpRequest
            {
                CookiesValue = new NameValueCollection {
                    { "c1", "Value1" }
                }
            };

            Assert.False(testObject.GetMatchedIntegrationConfig(customerIntegration, url.AbsoluteUri, httpRequestMock).Name == "integration2");
        }
 public List <Customer> GetCustomerListByCustomerLoans(bool allOffices, string officeIDs)
 {
     return(CustomerIntegration.GetCustomerListByCustomerLoans(allOffices, officeIDs));
 }
示例#20
0
        public static RequestValidationResult ValidateRequestByIntegrationConfig(
            string currentUrlWithoutQueueITToken, string queueitToken,
            CustomerIntegration customerIntegrationInfo, string customerId, string secretKey)
        {
            var debugEntries         = new Dictionary <string, string>();
            var connectorDiagnostics = ConnectorDiagnostics.Verify(customerId, secretKey, queueitToken);

            if (connectorDiagnostics.HasError)
            {
                return(connectorDiagnostics.ValidationResult);
            }
            try
            {
                if (connectorDiagnostics.IsEnabled)
                {
                    debugEntries["SdkVersion"]    = UserInQueueService.SDK_VERSION;
                    debugEntries["Runtime"]       = GetRuntime();
                    debugEntries["ConfigVersion"] = customerIntegrationInfo != null?customerIntegrationInfo.Version.ToString() : "NULL";

                    debugEntries["PureUrl"]      = currentUrlWithoutQueueITToken;
                    debugEntries["QueueitToken"] = queueitToken;
                    debugEntries["OriginalUrl"]  = GetHttpContextProvider().HttpRequest.Url.AbsoluteUri;

                    LogExtraRequestDetails(debugEntries);
                }
                if (string.IsNullOrEmpty(currentUrlWithoutQueueITToken))
                {
                    throw new ArgumentException("currentUrlWithoutQueueITToken can not be null or empty.");
                }
                if (customerIntegrationInfo == null)
                {
                    throw new ArgumentException("customerIntegrationInfo can not be null.");
                }

                var configEvaluater = new IntegrationEvaluator();

                var matchedConfig = configEvaluater.GetMatchedIntegrationConfig(
                    customerIntegrationInfo,
                    currentUrlWithoutQueueITToken,
                    GetHttpContextProvider().HttpRequest);

                if (connectorDiagnostics.IsEnabled)
                {
                    debugEntries["MatchedConfig"] = matchedConfig != null ? matchedConfig.Name : "NULL";
                }
                if (matchedConfig == null)
                {
                    return(new RequestValidationResult(null));
                }

                switch (matchedConfig.ActionType ?? string.Empty)
                {
                case "":    //backward compatibility
                case ActionType.QueueAction:
                {
                    return(HandleQueueAction(currentUrlWithoutQueueITToken, queueitToken, customerIntegrationInfo,
                                             customerId, secretKey, debugEntries, matchedConfig, connectorDiagnostics.IsEnabled));
                }

                case ActionType.CancelAction:
                {
                    return(HandleCancelAction(currentUrlWithoutQueueITToken, queueitToken, customerIntegrationInfo,
                                              customerId, secretKey, debugEntries, matchedConfig, connectorDiagnostics.IsEnabled));
                }

                default:
                {
                    return(HandleIgnoreAction(matchedConfig.Name));
                }
                }
            }
            catch (Exception e)
            {
                if (connectorDiagnostics.IsEnabled)
                {
                    debugEntries["Exception"] = e.Message;
                }
                throw;
            }
            finally
            {
                SetDebugCookie(debugEntries);
            }
        }
 public List <Customer> GetCustomerMediclaimEligibilityList(bool allOffices = false)
 {
     return(CustomerIntegration.GetCustomerMediclaimEligibilityList(allOffices));
 }
 public Customer GetCustomerByID(int customerID)
 {
     //TODO: Cache the customer being requested for first time
     return(CustomerIntegration.GetCustomerByID(customerID));
 }
 public int InsertCustomer(Customer theCustomer)
 {
     return(CustomerIntegration.InsertCustomer(theCustomer));
 }
 public int UpdateCustomer(Customer theCustomer)
 {
     return(CustomerIntegration.UpdateCustomer(theCustomer));
 }
 public int DeleteCustomer(Customer theCustomer)
 {
     return(CustomerIntegration.DeleteCustomer(theCustomer));
 }
        public static RequestValidationResult ValidateRequestByIntegrationConfig(string currentUrlWithoutQueueITToken,
                                                                                 string queueitToken, CustomerIntegration customerIntegrationInfo,
                                                                                 string customerId, string secretKey)
        {
            if (string.IsNullOrEmpty(currentUrlWithoutQueueITToken))
            {
                throw new ArgumentException("currentUrlWithoutQueueITToken can not be null or empty.");
            }
            if (customerIntegrationInfo == null)
            {
                throw new ArgumentException("customerIntegrationInfo can not be null.");
            }

            var configEvaluater = new IntegrationEvaluator();

            var matchedConfig = configEvaluater.GetMatchedIntegrationConfig(
                customerIntegrationInfo,
                currentUrlWithoutQueueITToken,
                GetHttpContextBase()?.Request?.Cookies);

            if (matchedConfig == null)
            {
                return(new RequestValidationResult());
            }

            var targetUrl = "";

            switch (matchedConfig.RedirectLogic)
            {
            case "ForcedTargetUrl":
            case "ForecedTargetUrl":
                targetUrl = matchedConfig.ForcedTargetUrl;
                break;

            case "EventTargetUrl":
                targetUrl = "";
                break;

            default:
                targetUrl = currentUrlWithoutQueueITToken;
                break;
            }

            var eventConfig = new EventConfig()
            {
                QueueDomain          = matchedConfig.QueueDomain,
                Culture              = matchedConfig.Culture,
                EventId              = matchedConfig.EventId,
                ExtendCookieValidity = matchedConfig.ExtendCookieValidity,
                LayoutName           = matchedConfig.LayoutName,
                CookieValidityMinute = matchedConfig.CookieValidityMinute,
                CookieDomain         = matchedConfig.CookieDomain,
                Version              = customerIntegrationInfo.Version
            };

            return(ValidateRequestByLocalEventConfig(targetUrl, queueitToken, eventConfig, customerId, secretKey));
        }
 public List <Customer> GetDuplicateCustomerList(string customerName, string fatherName, string dateofBirth, bool allOffices = false, bool showDeleted = false)
 {
     return(CustomerIntegration.GetDuplicateCustomerList(customerName, fatherName, dateofBirth, allOffices, showDeleted));
 }
示例#28
0
        public void GetMatchedIntegrationConfig_ThreeIntegrationsInOrder_SecondMatched()
        {
            var testObject          = new IntegrationEvaluator();
            var customerIntegration = new CustomerIntegration()
            {
                Integrations = new List <IntegrationConfigModel> {
                    new IntegrationConfigModel()
                    {
                        Name     = "integration0",
                        Triggers = new List <TriggerModel>()
                        {
                            new TriggerModel()
                            {
                                LogicalOperator = LogicalOperatorType.And,
                                TriggerParts    = new List <TriggerPart>()
                                {
                                    new TriggerPart()
                                    {
                                        CookieName     = "c1",
                                        Operator       = ComparisonOperatorType.EqualS,
                                        ValueToCompare = "value1",
                                        ValidatorType  = ValidatorType.CookieValidator
                                    }
                                }
                            }
                        }
                    },
                    new IntegrationConfigModel()
                    {
                        Name     = "integration1",
                        Triggers = new List <TriggerModel>()
                        {
                            new TriggerModel()
                            {
                                LogicalOperator = LogicalOperatorType.And,
                                TriggerParts    = new List <TriggerPart>()
                                {
                                    new TriggerPart()
                                    {
                                        CookieName     = "c1",
                                        Operator       = ComparisonOperatorType.EqualS,
                                        ValueToCompare = "Value1",
                                        ValidatorType  = ValidatorType.CookieValidator
                                    }
                                }
                            }
                        }
                    },
                    new IntegrationConfigModel()
                    {
                        Name     = "integration2",
                        Triggers = new List <TriggerModel>()
                        {
                            new TriggerModel()
                            {
                                LogicalOperator = LogicalOperatorType.And,
                                TriggerParts    = new List <TriggerPart>()
                                {
                                    new TriggerPart()
                                    {
                                        UrlPart  = UrlPartType.PageUrl,
                                        Operator = ComparisonOperatorType.Contains,

                                        ValueToCompare = "test",
                                        ValidatorType  = ValidatorType.UrlValidator
                                    }
                                }
                            }
                        }
                    }
                }
            };

            var url             = new Uri("http://test.tesdomain.com:8080/test?q=2");
            var httpRequestMock = MockRepository.GenerateMock <HttpRequestBase>();

            Assert.False(testObject.GetMatchedIntegrationConfig(customerIntegration, url.AbsoluteUri,
                                                                new HttpCookieCollection()
            {
                new HttpCookie("c1")
                {
                    Value = "Value1"
                }
            }).Name == "integration2");
        }
        public static RequestValidationResult ValidateRequestByIntegrationConfig(
            string currentUrlWithoutQueueITToken, string queueitToken,
            CustomerIntegration customerIntegrationInfo, string customerId, string secretKey)
        {
            var debugEntries = new Dictionary <string, string>();

            try
            {
                var isDebug = GetIsDebug(queueitToken, secretKey);
                if (isDebug)
                {
                    debugEntries["ConfigVersion"] = customerIntegrationInfo.Version.ToString();
                    debugEntries["PureUrl"]       = currentUrlWithoutQueueITToken;
                    debugEntries["QueueitToken"]  = queueitToken;
                    debugEntries["OriginalUrl"]   = GetHttpContextProvider().HttpRequest.Url.AbsoluteUri;

                    LogExtraRequestDetails(debugEntries);
                }
                if (string.IsNullOrEmpty(currentUrlWithoutQueueITToken))
                {
                    throw new ArgumentException("currentUrlWithoutQueueITToken can not be null or empty.");
                }
                if (customerIntegrationInfo == null)
                {
                    throw new ArgumentException("customerIntegrationInfo can not be null.");
                }

                var configEvaluater = new IntegrationEvaluator();

                var matchedConfig = configEvaluater.GetMatchedIntegrationConfig(
                    customerIntegrationInfo,
                    currentUrlWithoutQueueITToken,
                    GetHttpContextProvider().HttpRequest);

                if (isDebug)
                {
                    debugEntries["MatchedConfig"] = matchedConfig != null ? matchedConfig.Name : "NULL";
                }
                if (matchedConfig == null)
                {
                    return(new RequestValidationResult(null));
                }

                switch (matchedConfig.ActionType ?? string.Empty)
                {
                case "":    //baackward compatibility
                case ActionType.QueueAction:
                {
                    return(HandleQueueAction(currentUrlWithoutQueueITToken, queueitToken, customerIntegrationInfo, customerId, secretKey, debugEntries, matchedConfig));
                }

                case ActionType.CancelAction:
                {
                    return(HandleCancelAction(currentUrlWithoutQueueITToken, queueitToken, customerIntegrationInfo, customerId, secretKey, debugEntries, matchedConfig));
                }

                default:    //default IgnoreAction
                {
                    return(HandleIgnoreAction());
                }
                }
            }
            finally
            {
                SetDebugCookie(debugEntries);
            }
        }
 public List <Customer> GetCustomerList(bool allOffices = false, bool showDeleted = false)
 {
     return(CustomerIntegration.GetCustomerList(allOffices, showDeleted));
 }