X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Ft%2Fapi%2Fpassword-types.t;h=3278b488de1c5978d46070dccd4bcc870cae1b8e;hp=4cb634248512f13eb0bc9d99fefbd5251bace5a1;hb=7322f2afedcc2f427e997d1535a503613a83f088;hpb=4e7efe58f1a20dfc4fd306fad2c14c8040585be1 diff --git a/rt/t/api/password-types.t b/rt/t/api/password-types.t index 4cb634248..3278b488d 100644 --- a/rt/t/api/password-types.t +++ b/rt/t/api/password-types.t @@ -4,17 +4,30 @@ use warnings; use RT::Test; use Digest::MD5; -my $default = "sha512"; +my $default = "bcrypt"; my $root = RT::User->new(RT->SystemUser); $root->Load("root"); -# Salted SHA-512 (default) +# bcrypt (default) my $old = $root->__Value("Password"); like($old, qr/^\!$default\!/, "Stored as salted $default"); ok($root->IsPassword("password")); is($root->__Value("Password"), $old, "Unchanged after password check"); +# bcrypt (smaller number of rounds) +my $rounds = RT->Config->Get("BcryptCost"); +my $salt = Crypt::Eksblowfish::Bcrypt::en_base64("a"x16); +$root->_Set( Field => "Password", Value => RT::User->_GeneratePassword_bcrypt("smaller", 6, $salt) ); +like($root->__Value("Password"), qr/^\!$default\!06\!/, "Stored with a smaller number of rounds"); +ok($root->IsPassword("smaller"), "Smaller number of bcrypt rounds works"); +like($root->__Value("Password"), qr/^\!$default\!$rounds\!/, "And is now upgraded to $rounds rounds"); + +# Salted SHA-512, one round +$root->_Set( Field => "Password", Value => RT::User->_GeneratePassword_sha512("other", "salt") ); +ok($root->IsPassword("other"), "SHA-512 password works"); +like($root->__Value("Password"), qr/^\!$default\!/, "And is now upgraded to salted $default"); + # Crypt $root->_Set( Field => "Password", Value => crypt("something", "salt")); ok($root->IsPassword("something"), "crypt()ed password works");