Skip to content

Commit

Permalink
Add test cases for min response limit validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Akashkarmakar787 authored Jan 13, 2025
1 parent 2d1064d commit a6dd839
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion test/verify_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def initialize
assert_equal "reCAPTCHA verification failed, please try again.", @controller.flash[:recaptcha_error]
end

it "does not verify via http call when response length exceeds G_RESPONSE_LIMIT" do
it "does not verify via http call when response length exceeds G_RESPONSE_MAX_LIMIT" do
# 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
Expand All @@ -209,6 +209,16 @@ def initialize
assert_equal "reCAPTCHA verification failed, please try again.", @controller.flash[:recaptcha_error]
end

it "does not verify via http call when response length below G_RESPONSE_MIN_LIMIT" do
# this returns a 400 or 413 instead of a 200 response with error code
# typical response length is less than 100 characters
str = "a" * 99
@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]
end

describe ':hostname' do
let(:hostname) { 'fake.hostname.com' }

Expand Down

0 comments on commit a6dd839

Please sign in to comment.