From 47fad7ac009899d4b2f3e43ec16dda3e2a3196ca Mon Sep 17 00:00:00 2001 From: Michael Grosser Date: Tue, 14 Jan 2025 09:21:54 -0800 Subject: [PATCH] fix ci --- lib/recaptcha/configuration.rb | 6 ++++-- test/verify_enterprise_test.rb | 8 ++++---- test/verify_test.rb | 9 ++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/recaptcha/configuration.rb b/lib/recaptcha/configuration.rb index 156250f0..1cdafa19 100644 --- a/lib/recaptcha/configuration.rb +++ b/lib/recaptcha/configuration.rb @@ -37,8 +37,10 @@ class Configuration 'enterprise_verify_url' => 'https://recaptchaenterprise.googleapis.com/v1/projects' }.freeze - attr_accessor :default_env, :skip_verify_env, :proxy, :secret_key, :site_key, :handle_timeouts_gracefully, - :hostname, :enterprise, :enterprise_api_key, :enterprise_project_id, :response_limit, :response_minimum + attr_accessor( + :default_env, :skip_verify_env, :proxy, :secret_key, :site_key, :handle_timeouts_gracefully, + :hostname, :enterprise, :enterprise_api_key, :enterprise_project_id, :response_limit, :response_minimum + ) attr_writer :api_server_url, :verify_url def initialize # :nodoc: diff --git a/test/verify_enterprise_test.rb b/test/verify_enterprise_test.rb index 1e257ca2..097702bd 100644 --- a/test/verify_enterprise_test.rb +++ b/test/verify_enterprise_test.rb @@ -20,7 +20,7 @@ def initialize @controller = EnterpriseTestController.new @controller.request = stub(remote_ip: "1.1.1.1", format: :html) - @controller.params = {:recaptcha_response_field => "response", 'g-recaptcha-response-data' => 'string'} + @controller.params = {:recaptcha_response_field => "response", 'g-recaptcha-response-data' => "a" * 200} end after do @@ -184,7 +184,7 @@ def initialize # this returns a 400 or 413 instead of a 200 response with error code # typical response length is less than 400 characters str = "a" * 4001 - @controller.params = { 'g-recaptcha-response' => "#{str}"} + @controller.params = { 'g-recaptcha-response' => str} assert_not_requested :get, %r{\.google\.com} assert_equal false, @controller.verify_recaptcha assert_equal "reCAPTCHA verification failed, please try again.", @controller.flash[:recaptcha_error] @@ -192,9 +192,9 @@ def initialize it "does not verify via http call when response length below limit" do # this returns a 400 or 413 instead of a 200 response with error code - # typical response length is less than 100 characters + # typical response length is more than 100 characters str = "a" * 99 - @controller.params = { 'g-recaptcha-response' => "#{str}"} + @controller.params = { 'g-recaptcha-response' => str} assert_not_requested :get, %r{\.google\.com} assert_equal false, @controller.verify_recaptcha assert_equal "reCAPTCHA verification failed, please try again.", @controller.flash[:recaptcha_error] diff --git a/test/verify_test.rb b/test/verify_test.rb index 37e8f9b7..eae691a0 100644 --- a/test/verify_test.rb +++ b/test/verify_test.rb @@ -20,7 +20,7 @@ def initialize before do @controller = TestController.new @controller.request = stub(remote_ip: "1.1.1.1", format: :html) - @controller.params = {:recaptcha_response_field => "response", 'g-recaptcha-response-data' => 'string'} + @controller.params = {:recaptcha_response_field => "response", 'g-recaptcha-response-data' => "a" * 200} end describe "#verify_recaptcha!" do @@ -106,7 +106,7 @@ def initialize secret_key = Recaptcha.configuration.secret_key stub_request( :get, - "https://www.recaptcha.net/recaptcha/api/siteverify?response=string&secret=#{secret_key}" + "https://www.recaptcha.net/recaptcha/api/siteverify?response=#{"a" * 200}&secret=#{secret_key}" ).to_return(body: '{"success":true}') assert @controller.verify_recaptcha(skip_remote_ip: true) @@ -453,8 +453,7 @@ def initialize end it "returns the g-recaptcha-response when response is valid and no action is provided" do - @controller.params = { "g-recaptcha-response" => "recaptcha-response" } - assert_equal @controller.recaptcha_response_token, "recaptcha-response" + assert_equal @controller.recaptcha_response_token, "a" * 200 end it "returns an empty string when params are empty and an action is provided" do @@ -503,7 +502,7 @@ def initialize def expect_http_post(secret_key: Recaptcha.configuration.secret_key) stub_request( :get, - "https://www.recaptcha.net/recaptcha/api/siteverify?remoteip=1.1.1.1&response=string&secret=#{secret_key}" + "https://www.recaptcha.net/recaptcha/api/siteverify?remoteip=1.1.1.1&response=#{"a" * 200}&secret=#{secret_key}" ) end