Files
discourse/spec/lib/secure_session_spec.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
635 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2022-07-28 05:27:38 +03:00
RSpec.describe SecureSession do
2016-12-19 18:00:22 +11:00
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-11 11:18:12 +11:00
it "can override expiry" do
s = SecureSession.new("abc")
key = SecureRandom.hex
s.set(key, "test2", expires: 5.minutes)
2023-12-06 23:25:00 +01:00
expect(s.ttl(key)).to be_within(1.second).of(5.minutes)
2019-11-11 11:18:12 +11:00
key = SecureRandom.hex
s.set(key, "test2")
2023-12-06 23:25:00 +01:00
expect(s.ttl(key)).to be_within(1.second).of(SecureSession.expiry)
2019-11-11 11:18:12 +11:00
end
2016-12-19 18:00:22 +11:00
end