Sha256: df9fa4544471f04a69d3b8325f77728a5084e5dbece45042fcbadc41ba703aa0
Contents?: true
Size: 1.81 KB
Versions: 1
Compression:
Stored size: 1.81 KB
Contents
# -*- encoding: utf-8 -*- require 'spec_helper' describe 'SHA encryption' do let(:credential) { ShaCredential.create(:email => 'john.smith@example.com', :password => 'this is a secret', :options => ['foo', 'bar', 'baz']) } context "#to_s" do subject { "#{credential.password}" } it { should eq("70a202166f0a78defe464d810f30b50b767cb89a") } end context "'this is a secret'" do subject { credential.password } it { should be_encrypted } it { should eq('this is a secret') } end context "cipher" do subject { credential.password.cipher } it { should be_an_instance_of(EncryptedStrings::ShaCipher) } end context "use default salt" do subject { credential.password.cipher.salt } it { should eq('salt') } end context "load from database" do subject { ShaCredential.find(credential.id).password } it { should be_encrypted } it { should eq('this is a secret') } context "#to_s" do subject { "#{ShaCredential.find(credential.id).password}" } it { should eq("70a202166f0a78defe464d810f30b50b767cb89a") } end end context "with mass assignment" do let(:credential) { ShaCredential.new(:email => 'john.smith@example.com', :password => 'this is a secret', :options => ['foo', 'bar', 'baz']) } subject { credential.password } it { should eq('this is a secret') } it { should_not be_encrypted } context "after save" do before { credential.save! } subject { credential.password } it { should be_encrypted } it { should eq('this is a secret') } context "#to_s" do subject { "#{credential.password}" } it { should eq('70a202166f0a78defe464d810f30b50b767cb89a') } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mongoid-encryptor-0.0.5 | spec/sha_encryption_spec.rb |