Exemplo n.º 1
0
        public void AssertScriptInvisibleDivIsCorrectWithAdditionalClassesOverrideConfiguration()
        {
            ReCaptcha.Configure("my-public-key", "my-secret-key", ReCaptchaLanguage.EnglishUs);
            IHtmlString captcha       = ReCaptcha.GetInvisibleCaptcha("callback", "SUBMIT", additionalClasses: new [] { "btn", "btn-autosize" });
            string      captchaString = captcha.ToHtmlString();

            Assert.AreEqual("<button class='g-recaptcha btn btn-autosize' data-sitekey='my-public-key' data-callback='callback'>SUBMIT</button><script src='https://www.google.com/recaptcha/api.js?hl=en'></script>", captchaString);
        }
Exemplo n.º 2
0
 public void InvalidSecretKeyException()
 {
     Assert.Throws <ReCaptchaException>(() =>
     {
         ReCaptcha.Configure("something", "Invalid-Secret-Key");
         bool answer = ReCaptcha.ValidateCaptcha("resposta-fajuta");
     });
 }
Exemplo n.º 3
0
        public void AssertScriptDivIsCorrectWithLanguage()
        {
            ReCaptcha.Configure("my-public-key", "my-secret-key", ReCaptchaLanguage.German);
            IHtmlString captcha       = ReCaptcha.GetCaptcha();
            string      captchaString = captcha.ToHtmlString();

            Assert.AreEqual("<div class='g-recaptcha' data-sitekey='my-public-key'></div><script src='https://www.google.com/recaptcha/api.js?hl=de'></script>", captchaString);
        }
Exemplo n.º 4
0
        public void AssertScriptInvisibleDivIsCorrectWithLanguageOverrideConfiguration()
        {
            ReCaptcha.Configure("my-public-key", "my-secret-key", ReCaptchaLanguage.EnglishUs);
            IHtmlString captcha       = ReCaptcha.GetInvisibleCaptcha("callback", "SUBMIT", ReCaptchaLanguage.PortugueseBrazil);
            string      captchaString = captcha.ToHtmlString();

            Assert.AreEqual("<button class='g-recaptcha' data-sitekey='my-public-key' data-callback='callback'>SUBMIT</button><script src='https://www.google.com/recaptcha/api.js?hl=pt-BR'></script>", captchaString);
        }
Exemplo n.º 5
0
        public void AssertScriptDivIsCorrectWithLanguageOverrideConfiguration()
        {
            ReCaptcha.Configure("my-public-key", "my-secret-key", ReCaptchaLanguage.EnglishUs);
            IHtmlString captcha       = ReCaptcha.GetCaptcha(ReCaptchaLanguage.PortugueseBrazil);
            string      captchaString = captcha.ToHtmlString();

            Assert.AreEqual("<div class='g-recaptcha' data-sitekey='my-public-key'></div><script src='https://www.google.com/recaptcha/api.js?hl=pt-BR'></script>", captchaString);
        }
Exemplo n.º 6
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            ReCaptcha.Configure("6LegPs0ZAAAAAHDKN5W79pZFKzIOcJgDakzyUXIp", "6LegPs0ZAAAAAKRIrijST2g_ynusrLydXvscnyo4");
        }
Exemplo n.º 7
0
 protected void Application_Start()
 {
     DependencyRegistrar.Register();
     AreaRegistration.RegisterAllAreas();
     GlobalConfiguration.Configure(WebApiConfig.Register);
     GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(RequiredIfAttribute), typeof(RequiredAttributeAdapter));
     DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(RequiredToBeTrueAttribute), typeof(RequiredAttributeAdapter));
     ModelBinders.Binders.Add(typeof(TradeSatoshi.Common.DataTables.DataTablesModel), new TradeSatoshi.Web.ModelBinder.DataTablesModelBinder());
     ReCaptcha.Configure(_ReCaptchaPublicKey, _ReCaptchaPrivateKey);
 }
        protected void Application_Start()
        {
            //         < add key = "recaptcha-secret-key" value = "6LdxS5oUAAAAAHr167UZm48MSP7GpAZclQqpxlgK" />

            //< add key = "recaptcha-public-key" value = "6LdxS5oUAAAAAJw5GMqEsbec55ZcVzgw1kSiZ1qZ" />
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            string publicKey = "6LfjTJoUAAAAAOVruGxPn4U9K_mNEsmkw7uxw0_9";
            string secretKey = "6LfjTJoUAAAAABJehsQyP5xDWktDFKanoQWcreiE";

            ReCaptcha.Configure(publicKey, secretKey);
        }
Exemplo n.º 9
0
        public void AssertScriptDivIsCorrectWithAutoLanguage()
        {
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("no");
            ReCaptcha.Configure("my-public-key", "my-secret-key", ReCaptchaLanguage.Auto);

            IHtmlString captcha       = ReCaptcha.GetCaptcha();
            string      captchaString = captcha.ToHtmlString();

            Assert.AreEqual("<div class='g-recaptcha' data-sitekey='my-public-key'></div><script src='https://www.google.com/recaptcha/api.js?hl=no'></script>", captchaString);

            captcha       = ReCaptcha.GetCaptcha(ReCaptchaLanguage.PortugueseBrazil);
            captchaString = captcha.ToHtmlString();
            Assert.AreEqual("<div class='g-recaptcha' data-sitekey='my-public-key'></div><script src='https://www.google.com/recaptcha/api.js?hl=pt-BR'></script>", captchaString);

            Thread.CurrentThread.CurrentUICulture = new CultureInfo("nl");
            captcha       = ReCaptcha.GetCaptcha();
            captchaString = captcha.ToHtmlString();
            Assert.AreEqual("<div class='g-recaptcha' data-sitekey='my-public-key'></div><script src='https://www.google.com/recaptcha/api.js?hl=nl'></script>", captchaString);
        }
Exemplo n.º 10
0
        protected void Application_Start()
        {
            MvcHandler.DisableMvcResponseHeader = true;
            ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(new RazorViewEngine());
            DependencyRegistrar.Register("Web.Admin");
            //DependencyRegistrar.Container
            AreaRegistration.RegisterAllAreas();
            //GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(RequiredIfAttribute), typeof(RequiredAttributeAdapter));
            ModelMetadataProviders.Current = new CachedDataAnnotationsModelMetadataProvider();
            System.Web.Mvc.ModelBinders.Binders.Add(typeof(DataTablesModel), new DataTablesModelBinder());

            string publicKey = WebConfigurationManager.AppSettings["RecaptchaPublicKey"];
            string secretKey = WebConfigurationManager.AppSettings["RecaptchaPrivateKey"];

            ReCaptcha.Configure(publicKey, secretKey);
        }
Exemplo n.º 11
0
        protected void Application_Start()
        {
            string l4Net = Server.MapPath("~/web.config");

            log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(l4Net));

            // Check to see what logging levels are active
            _logger.Info("Application Start - Info Logging level Check");
            _logger.Warn("Application Start - Warn Logging level Check");
            _logger.Error("Application Start - Error Logging level Check");
            _logger.Fatal("Application Start - Fatal Logging level Check");
            _logger.Debug("Application Start - Debug Logging level Check");

            _logger.Info($"Version: {Assembly.GetExecutingAssembly().GetName()}");

            // Configure and activate the ReCaptcha code in the application
            string reCaptchaPublic = Environment.GetEnvironmentVariable("ReCaptchaPublic");
            string reCaptchaSecret = Environment.GetEnvironmentVariable("ReCaptchaSecret");

#if DEBUG
            if (string.IsNullOrEmpty(reCaptchaPublic))
            {
                reCaptchaPublic = Settings.Default.ReCaptchaPublic;
            }

            if (string.IsNullOrEmpty(reCaptchaSecret))
            {
                reCaptchaSecret = Settings.Default.ReCaptchaSecret;
            }
#endif

            ReCaptcha.Configure(reCaptchaPublic, reCaptchaSecret);


            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
Exemplo n.º 12
0
        public void AssertTestWillConectAndFailInvalidUserAnswerAsyncWithProxy()
        {
            Assert.Throws <ReCaptchaException>(() =>
            {
                try
                {
                    ReCaptcha.Configure(SiteKey, SecretKey);
                    var task = ReCaptcha.ValidateCaptchaAsync("resposta-fajuta", new WebProxy(TestProxyIp, PortProxy));

                    while (task.IsCompleted == false)
                    {
                        Thread.Sleep(1);
                    }

                    var answer = task.Result;
                    Assert.IsFalse(answer);
                }
                catch (AggregateException e)
                {
                    throw e.InnerException;
                }
            });
        }
Exemplo n.º 13
0
 public static void Configure()
 {
     ReCaptcha.Configure(PublicKey, SecretKey);
 }
Exemplo n.º 14
0
 public void AssertTestWillConectAndFailInvalidUserAnswerWithProxy()
 {
     ReCaptcha.Configure(SiteKey, SecretKey);
     Assert.Throws <ReCaptchaException>(() => ReCaptcha.ValidateCaptcha("resposta-fajuta", new WebProxy(TestProxyIp, PortProxy)));
 }
Exemplo n.º 15
0
 public void AssertTestWillConectAndFailInvalidUserAnswer()
 {
     ReCaptcha.Configure(SiteKey, SecretKey);
     Assert.Throws <ReCaptchaException>(() => ReCaptcha.ValidateCaptcha("resposta-fajuta"));
 }
Exemplo n.º 16
0
 public void WrongSecretKeyArgumentException()
 {
     Assert.Throws <ArgumentNullException>(() => ReCaptcha.Configure("something", null));
 }
Exemplo n.º 17
0
 public void WrongSiteKeyArgumentException()
 {
     Assert.Throws <ArgumentNullException>(() => ReCaptcha.Configure("", "something"));
 }
Exemplo n.º 18
0
 public static void RegisterCaptcha(string key, string secret)
 {
     ReCaptcha.Configure(key, secret);
 }