Class: Authentication::Logic::TestCase::MockSignedCookieJar
- Inherits:
-
MockCookieJar
- Object
- Hash
- MockCookieJar
- Authentication::Logic::TestCase::MockSignedCookieJar
- Defined in:
- lib/auth/logic/test_case/mock_cookie_jar.rb
Overview
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
Instance Attribute Summary collapse
-
#parent_jar ⇒ Object
readonly
helper for testing.
Attributes inherited from MockCookieJar
Instance Method Summary collapse
- #[](val) ⇒ Object
- #[]=(key, options) ⇒ Object
-
#initialize(parent_jar) ⇒ MockSignedCookieJar
constructor
A new instance of MockSignedCookieJar.
Methods inherited from MockCookieJar
Constructor Details
#initialize(parent_jar) ⇒ MockSignedCookieJar
Returns a new instance of MockSignedCookieJar.
56 57 58 59 |
# File 'lib/auth/logic/test_case/mock_cookie_jar.rb', line 56 def initialize(parent_jar) @parent_jar = parent_jar parent_jar.each { |k, v| self[k] = v } end |
Instance Attribute Details
#parent_jar ⇒ Object (readonly)
helper for testing
54 55 56 |
# File 'lib/auth/logic/test_case/mock_cookie_jar.rb', line 54 def parent_jar @parent_jar end |
Instance Method Details
#[](val) ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/auth/logic/test_case/mock_cookie_jar.rb', line 61 def [](val) = @parent_jar[val] return unless payload, signature = .split("--") raise "Invalid signature" unless Digest::SHA1.hexdigest(payload) == signature payload end |
#[]=(key, options) ⇒ Object
71 72 73 74 75 |
# File 'lib/auth/logic/test_case/mock_cookie_jar.rb', line 71 def []=(key, ) opt = () opt[:value] = "#{opt[:value]}--#{Digest::SHA1.hexdigest opt[:value]}" @parent_jar[key] = opt end |