spec/fernet_spec.rb in fernet-1.2 vs spec/fernet_spec.rb in fernet-1.3
- old
+ new
@@ -1,9 +1,11 @@
require 'spec_helper'
require 'fernet'
describe Fernet do
+ after { Fernet::Configuration.run }
+
let(:token_data) do
{ :email => 'harold@heroku.com', :id => '123', :arbitrary => 'data' }
end
let(:secret) { 'JrdICDH6x3M7duQeM8dJEMK4Y5TkBIsYDw1lPy35RiY=' }
@@ -114,9 +116,23 @@
payload = Base64.decode64(token)
payload.should match /password1/
Fernet.verify(secret, token, false) do |verifier|
+ verifier.data['password'].should == 'password1'
+ end
+ end
+
+ it 'can disable encryption via global configuration' do
+ Fernet::Configuration.run { |c| c.encrypt = false }
+ token = Fernet.generate(secret) do |generator|
+ generator.data['password'] = 'password1'
+ end
+
+ payload = Base64.decode64(token)
+ payload.should match /password1/
+
+ Fernet.verify(secret, token) do |verifier|
verifier.data['password'].should == 'password1'
end
end
end