Esempio n. 1
0
        public void RuleMinderAddsExistingRuleMinder()
        {
            var existingRuleMinder = SiteMinder.Create().AddRule <UrlIsValidRuleSet, UrlIsValidRuleHandler, UrlRequest>(x =>
                                                                                                                        x.Using <UrlRequest>(request => request.Url = ("/SampleWebServiceEndPoint"))
                                                                                                                        .Build());

            Assert.Equal(1, existingRuleMinder.Rules.Count);
        }
Esempio n. 2
0
        public void RuleMinderAddsExistingRule()
        {
            var ruleSet =
                CreateRule <UrlIsValidRuleHandler, UrlRequest> .On <UrlRequest>(request => request.Url = "/SomeWebService")
                .Build();

            var rm =
                SiteMinder.Create()
                .AddRule <UrlIsValidRuleSet, UrlIsValidRuleHandler, UrlRequest>(webServiceUpRuleSet => ruleSet);

            Assert.Equal(1, rm.Rules.Count);
        }
Esempio n. 3
0
        public void RuleMinderCanChainRules()
        {
            // Fluent builder to add many custom or inbuilt rules in  global.asax application_onstart
            var siteMinder = SiteMinder.Create()
                             .WithSslEnabled() // predefined rule redirect all http traffic to https
                             .WithNoSpam(maxAttemptsWithinDuration: 100, withinDuration: TimeSpan.FromHours(1))
                             .AddRule <UrlIsValidRuleSet, UrlIsValidRuleHandler, UrlRequest>(webServiceUpRuleSet =>
                                                                                             webServiceUpRuleSet.Using <UrlRequest>(request => request.Url = "/SomeWebService").Build()) // build a custom rule
            ;

            siteMinder.VerifyAllRules(); // global.asax  run via Application_BeginRequest

            //siteMinder.VerifyRule(IpAddressRequest.GetCurrentIpAddress(recordBadIp: true)); // or verify individual request on demand  / via attribute
            Assert.Equal(2, siteMinder.Rules.Count);
        }