From 0702a0edca47bef27e8beeac0aad5f7a5da4f14c Mon Sep 17 00:00:00 2001 From: Derf Null Date: Mon, 26 Jun 2023 19:40:29 +0200 Subject: Move hash_password to Model/Users --- t/22-visibility.t | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 't') diff --git a/t/22-visibility.t b/t/22-visibility.t index 6e3fd38..6e827c5 100644 --- a/t/22-visibility.t +++ b/t/22-visibility.t @@ -11,7 +11,6 @@ use Mojo::Base -strict; use Test::More; use Test::Mojo; -use Crypt::Eksblowfish::Bcrypt qw(bcrypt en_base64); use DateTime; use Travel::Status::DE::IRIS::Result; @@ -41,14 +40,6 @@ $t->app->start( 'database', 'migrate' ); my $u = $t->app->users; -sub hash_password { - my ($password) = @_; - my @salt_bytes = map { int( rand(255) ) + 1 } ( 1 .. 16 ); - my $salt = en_base64( pack( 'C[16]', @salt_bytes ) ); - - return bcrypt( substr( $password, 0, 10000 ), '$2a$12$' . $salt ); -} - sub login { my %opt = @_; my $csrf_token @@ -202,24 +193,24 @@ sub test_visibility { } my $uid1 = $u->add( - name => 'test1', - email => 'test1@example.org', - token => 'abcd', - password_hash => hash_password('password1'), + name => 'test1', + email => 'test1@example.org', + token => 'abcd', + password => 'password1', ); my $uid2 = $u->add( - name => 'test2', - email => 'test2@example.org', - token => 'efgh', - password_hash => hash_password('password2'), + name => 'test2', + email => 'test2@example.org', + token => 'efgh', + password => 'password2', ); my $uid3 = $u->add( - name => 'test3', - email => 'test3@example.org', - token => 'ijkl', - password_hash => hash_password('password3'), + name => 'test3', + email => 'test3@example.org', + token => 'ijkl', + password => 'password3', ); $u->verify_registration_token( -- cgit v1.2.3