git ssb

0+

dangerousbeans / %aPBe2k3ugtjBr4rrsU1…



Commit 28e13759ae318586d9c771b02402579b343c97cb

Increase test coverage. We now have 100% C0 coverage.

Signed-off-by: Coda Hale <coda.hale@gmail.com>
Hongli Lai (Phusion) authored on 8/4/2009, 8:39:27 PM
Coda Hale committed on 8/12/2009, 9:50:39 PM
Parent: f01304abbeb445a3710fb3e15e69dee1b4637519

Files changed

spec/bcrypt/engine_spec.rbchanged
spec/bcrypt/engine_spec.rbView
@@ -28,8 +28,12 @@
2828 end
2929
3030 context "Generating BCrypt hashes" do
3131
32+ class MyInvalidSecret
33+ undef to_s
34+ end
35+
3236 before :each do
3337 @salt = BCrypt::Engine.generate_salt(4)
3438 @password = "woo"
3539 end
@@ -42,12 +46,17 @@
4246 lambda { BCrypt::Engine.hash_secret(@password, 'nino') }.should raise_error(BCrypt::Errors::InvalidSalt)
4347 end
4448
4549 specify "should raise an InvalidSecret error if the secret is invalid" do
50+ lambda { BCrypt::Engine.hash_secret(MyInvalidSecret.new, @salt) }.should raise_error(BCrypt::Errors::InvalidSecret)
4651 lambda { BCrypt::Engine.hash_secret(nil, @salt) }.should_not raise_error(BCrypt::Errors::InvalidSecret)
4752 lambda { BCrypt::Engine.hash_secret(false, @salt) }.should_not raise_error(BCrypt::Errors::InvalidSecret)
4853 end
4954
55+ specify "should call #to_s on the secret and use the return value as the actual secret data" do
56+ BCrypt::Engine.hash_secret(false, @salt).should == BCrypt::Engine.hash_secret("false", @salt)
57+ end
58+
5059 specify "should be interoperable with other implementations" do
5160 # test vectors from the OpenWall implementation <http://www.openwall.com/crypt/>
5261 test_vectors = [
5362 ["U*U", "$2a$05$CCCCCCCCCCCCCCCCCCCCC.", "$2a$05$CCCCCCCCCCCCCCCCCCCCC.E5YPO9kmyuRGyh0XouQYb4YMJKvyOeW"],

Built with git-ssb-web