Permalink
Browse files

Updated the BCrypt provider to alias "stretches" to "cost".

When setting up encryption Sorcery checks if the provider responds to "stretches".
Since the BCrypt provider only responded to "stretches=" the cost provided in the Sorcery config was not passed on to the provider.
  • Loading branch information...
scarpenter committed Jul 17, 2012
1 parent 3264e29 commit 78736cb0f65375ff7dfff381048597612d750044
Showing with 10 additions and 0 deletions.
  1. +1 −0 lib/sorcery/crypto_providers/bcrypt.rb
  2. +9 −0 spec/sorcery_crypto_providers_spec.rb
@@ -48,6 +48,7 @@ def cost
@cost ||= 10
end
attr_writer :cost
+ alias :stretches :cost
alias :stretches= :cost=
# Creates a BCrypt hash for the password passed.
@@ -181,6 +181,15 @@
it "matches? returns false when no match" do
Sorcery::CryptoProviders::BCrypt.matches?(@digest, 'Some Dude').should be_false
end
+
+ it "respond_to?(:stretches) returns true" do
+ Sorcery::CryptoProviders::BCrypt.respond_to?(:stretches).should be_true
+ end
+
+ it "sets cost when stretches is set" do
+ Sorcery::CryptoProviders::BCrypt.stretches = 4
+ Sorcery::CryptoProviders::BCrypt.cost.should == 4
+ end
end

0 comments on commit 78736cb

Please sign in to comment.