2019-04-29 19:27:42 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-12-19 01:00:22 -06:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe SecureSession do
|
|
|
|
it "operates correctly" do
|
|
|
|
s = SecureSession.new("abc")
|
|
|
|
|
|
|
|
s["hello"] = "world"
|
|
|
|
s["foo"] = "bar"
|
|
|
|
expect(s["hello"]).to eq("world")
|
|
|
|
expect(s["foo"]).to eq("bar")
|
|
|
|
|
|
|
|
s["hello"] = nil
|
|
|
|
expect(s["hello"]).to eq(nil)
|
|
|
|
end
|
2019-11-10 18:18:12 -06:00
|
|
|
|
|
|
|
it "can override expiry" do
|
|
|
|
s = SecureSession.new("abc")
|
|
|
|
key = SecureRandom.hex
|
|
|
|
|
|
|
|
s.set(key, "test2", expires: 5.minutes)
|
|
|
|
expect(s.ttl(key)).to be_within(1.second).of (5.minutes)
|
|
|
|
|
|
|
|
key = SecureRandom.hex
|
|
|
|
s.set(key, "test2")
|
|
|
|
expect(s.ttl(key)).to be_within(1.second).of (SecureSession.expiry)
|
|
|
|
end
|
2016-12-19 01:00:22 -06:00
|
|
|
end
|