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); }
public void InvalidSecretKeyException() { Assert.Throws <ReCaptchaException>(() => { ReCaptcha.Configure("something", "Invalid-Secret-Key"); bool answer = ReCaptcha.ValidateCaptcha("resposta-fajuta"); }); }
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); }
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); }
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); }
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"); }
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); }
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); }
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); }
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); }
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; } }); }
public static void Configure() { ReCaptcha.Configure(PublicKey, SecretKey); }
public void AssertTestWillConectAndFailInvalidUserAnswerWithProxy() { ReCaptcha.Configure(SiteKey, SecretKey); Assert.Throws <ReCaptchaException>(() => ReCaptcha.ValidateCaptcha("resposta-fajuta", new WebProxy(TestProxyIp, PortProxy))); }
public void AssertTestWillConectAndFailInvalidUserAnswer() { ReCaptcha.Configure(SiteKey, SecretKey); Assert.Throws <ReCaptchaException>(() => ReCaptcha.ValidateCaptcha("resposta-fajuta")); }
public void WrongSecretKeyArgumentException() { Assert.Throws <ArgumentNullException>(() => ReCaptcha.Configure("something", null)); }
public void WrongSiteKeyArgumentException() { Assert.Throws <ArgumentNullException>(() => ReCaptcha.Configure("", "something")); }
public static void RegisterCaptcha(string key, string secret) { ReCaptcha.Configure(key, secret); }