class Authlogic::TestCase::MockSignedCookieJar

A mock of `ActionDispatch::Cookies::SignedKeyRotatingCookieJar`

> .. a jar that'll automatically generate a signed representation of > cookie value and verify it when reading from the cookie again. > actionpack/lib/action_dispatch/middleware/cookies.rb

Attributes

parent_jar[R]

Public Class Methods

new(parent_jar) click to toggle source
# File lib/authlogic/test_case/mock_cookie_jar.rb, line 55
def initialize(parent_jar)
  @parent_jar = parent_jar
  parent_jar.each { |k, v| self[k] = v }
end

Public Instance Methods

[](val) click to toggle source
# File lib/authlogic/test_case/mock_cookie_jar.rb, line 60
def [](val)
  signed_message = @parent_jar[val]
  if signed_message
    payload, signature = signed_message.split("--")
    raise "Invalid signature" unless Digest::SHA1.hexdigest(payload) == signature
    payload
  end
end
[]=(key, options) click to toggle source
# File lib/authlogic/test_case/mock_cookie_jar.rb, line 69
def []=(key, options)
  opt = cookie_options_to_hash(options)
  opt[:value] = "#{opt[:value]}--#{Digest::SHA1.hexdigest opt[:value]}"
  @parent_jar[key] = opt
end