Sha256: 85230ca4afc41a9d67ed046fd9ab6b0d7363161cff823080c53d51e7161f9f3b

Contents?: true

Size: 995 Bytes

Versions: 3

Compression:

Stored size: 995 Bytes

Contents

require 'test_helper'

class EncryptedParametersTest < MiniTest::Unit::TestCase
  def test_missing_encrypted_params
    controller = MockController.new({})
    assert_equal({}, controller.encrypted_params)
  end

  def test_invalid_encrypted_params
    controller = MockController.new({"_encrypted" => {"key" => "value"}})
    assert_raises ActiveSupport::MessageVerifier::InvalidSignature do
      controller.encrypted_params
    end
  end

  def test_properly_encrypted_params
    value = EncryptedFormFields.encrypt_and_sign("value")
    controller = MockController.new({"_encrypted" => {"key" => value}})
    assert_equal({"key" => "value"}, controller.encrypted_params)

    controller = MockController.new({"_encrypted" => {"key" => [value]}})
    assert_equal({"key" => ["value"]}, controller.encrypted_params)

    controller = MockController.new({"_encrypted" => {"key" => {"nested" => value}}})
    assert_equal({"key" => {"nested" => "value"}}, controller.encrypted_params)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
encrypted_form_fields-0.2.1 test/encrypted_parameters_test.rb
encrypted_form_fields-0.2.0 test/encrypted_parameters_test.rb
encrypted_form_fields-0.1.0 test/encrypted_parameters_test.rb