Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #13229 from vipulnsward/fix-10635-tests

Fix test-error introduced by #10635.
  • Loading branch information...
commit 6e2b734f56e4c789763b9a8e3922272a004a325f 2 parents 07fd25c + 1f80e8d
@rafaelfranca rafaelfranca authored
View
5 activesupport/lib/active_support/message_verifier.rb
@@ -39,8 +39,9 @@ def verify(signed_message)
if data.present? && digest.present? && secure_compare(digest, generate_digest(data))
begin
@serializer.load(::Base64.strict_decode64(data))
- rescue ArgumentError
- raise InvalidSignature
+ rescue ArgumentError => argument_error
+ raise InvalidSignature if argument_error.message =~ %r{invalid base64}
+ raise
end
else
raise InvalidSignature
View
14 activesupport/test/message_verifier_test.rb
@@ -55,6 +55,20 @@ def test_alternative_serialization_method
ActiveSupport.use_standard_json_time_format = prev
end
+ def test_raise_error_when_argument_class_is_not_loaded
+ # To generate the valid message below:
+ #
+ # AutoloadClass = Struct.new(:foo)
+ # valid_message = @verifier.generate(foo: AutoloadClass.new('foo'))
+ #
+ valid_message = "BAh7BjoIZm9vbzonTWVzc2FnZVZlcmlmaWVyVGVzdDo6QXV0b2xvYWRDbGFzcwY6CUBmb29JIghmb28GOgZFVA==--f3ef39a5241c365083770566dc7a9eb5d6ace914"
+ exception = assert_raise(ArgumentError, NameError) do
+ @verifier.verify(valid_message)
+ end
+ assert_includes ["uninitialized constant MessageVerifierTest::AutoloadClass",
+ "undefined class/module MessageVerifierTest::AutoloadClass"], exception.message
+ end
+
def assert_not_verified(message)
assert_raise(ActiveSupport::MessageVerifier::InvalidSignature) do
@verifier.verify(message)
Please sign in to comment.
Something went wrong with that request. Please try again.