Skip to content
  • maximerety's avatar
    d0f3b007
    [Fix #48685] Make the encryptor agnostic of the type of data to decrypt · d0f3b007
    maximerety authored
    It is the role of the underlying serializer to accept or reject the data
    to decrypt depending on its type. This behavior mirrors what is done at
    encryption, where the serializer asserts that the input is an
    ActiveRecord::Encryption::Message.
    
    This change allows for a wider variety of custom serializers, but does
    not change the behavior when using the default MessageSerializer class.
    Indeed, the default message serializer will raise a TypeError when
    invoking JSON.parse on any non-String input. This error will subsequently
    be translated into an ActiveRecord::Encryption::Errors::Encoding error
    by the encryptor, which does not change the current behavior at the
    encryptor level.
    
    A new test asserts that the default MessageSerializer is able to reject
    unexpected data types on its own at decryption time, just as it does at
    encryption time (test already present). The test also asserts that an
    exception is translated into an ActiveRecord::Encryption::Error::Encoding
    error at the encryptor level.
    d0f3b007
    [Fix #48685] Make the encryptor agnostic of the type of data to decrypt
    maximerety authored
    It is the role of the underlying serializer to accept or reject the data
    to decrypt depending on its type. This behavior mirrors what is done at
    encryption, where the serializer asserts that the input is an
    ActiveRecord::Encryption::Message.
    
    This change allows for a wider variety of custom serializers, but does
    not change the behavior when using the default MessageSerializer class.
    Indeed, the default message serializer will raise a TypeError when
    invoking JSON.parse on any non-String input. This error will subsequently
    be translated into an ActiveRecord::Encryption::Errors::Encoding error
    by the encryptor, which does not change the current behavior at the
    encryptor level.
    
    A new test asserts that the default MessageSerializer is able to reject
    unexpected data types on its own at decryption time, just as it does at
    encryption time (test already present). The test also asserts that an
    exception is translated into an ActiveRecord::Encryption::Error::Encoding
    error at the encryptor level.
Loading