Sha256: 7f56cc2b4d882a0217431c9b51563b7d27cccc6d240bd4fa8d0f702328f4f7bc
Contents?: true
Size: 1.39 KB
Versions: 1
Compression:
Stored size: 1.39 KB
Contents
require 'spec_helper' require 'fernet' describe Fernet do let(:token_data) do { email: 'harold@heroku.com', id: '123', arbitrary: 'data' } end let(:secret) { 'sekrit123' } it 'can verify tokens it generates' do token = Fernet.generate(secret) do |generator| generator.data = token_data end Fernet.verify(secret, token) do |verifier| verifier.data['email'] == 'harold@heroku.com' end.should be_true end it 'fails with a bad secret' do token = Fernet.generate(secret) do |generator| generator.data = token_data end Fernet.verify('bad', token) do |verifier| verifier.data['email'] == 'harold@heroku.com' end.should be_false end it 'fails with a bad custom verification' do token = Fernet.generate(secret) do |generator| generator.data = token_data end Fernet.verify('bad', token) do |verifier| verifier.data['email'] == 'harold@gmail.com' end.should be_false end it 'fails if the token is too old' do token = Fernet.generate(secret) do |generator| generator.data = token_data end Fernet.verify('bad', token) do |verifier| verifier.seconds_valid = 0 end.should be_false end it 'verifies without a custom verification' do token = Fernet.generate(secret) do |generator| generator.data = token_data end Fernet.verify(secret, token).should be_true end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fernet-0.0.2 | spec/fernet_spec.rb |