Bugzilla – Attachment 153574 Details for
Bug 32739
REST API: Extend endpoint /auth/password/validation for cardnumber
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32739: Unit tests
Bug-32739-Unit-tests.patch (text/plain), 4.66 KB, created by
Tomás Cohen Arazi (tcohen)
on 2023-07-17 18:52:47 UTC
(
hide
)
Description:
Bug 32739: Unit tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2023-07-17 18:52:47 UTC
Size:
4.66 KB
patch
obsolete
>From b41765e775c1140d22fc2404907ead828312aabf Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 17 Jul 2023 15:48:09 -0300 >Subject: [PATCH] Bug 32739: Unit tests > >--- > t/db_dependent/api/v1/password_validation.t | 105 ++++++++------------ > 1 file changed, 43 insertions(+), 62 deletions(-) > >diff --git a/t/db_dependent/api/v1/password_validation.t b/t/db_dependent/api/v1/password_validation.t >index 0464e3a5b73..7a6da04d559 100755 >--- a/t/db_dependent/api/v1/password_validation.t >+++ b/t/db_dependent/api/v1/password_validation.t >@@ -18,7 +18,7 @@ > > use Modern::Perl; > >-use Test::More tests => 6; >+use Test::More tests => 4; > use Test::Mojo; > > use t::lib::TestBuilder; >@@ -45,24 +45,6 @@ my $password = 'thePassword123'; > $librarian->set_password( { password => $password, skip_validation => 1 } ); > my $userid = $librarian->userid; > >-subtest 'password validation - success' => sub { >- >- plan tests => 3; >- >- $schema->storage->txn_begin; >- >- my $json = { >- "userid" => $userid, >- "password" => $password, >- }; >- >- $t->post_ok( "//$userid:$password@/api/v1/auth/password/validation" => json => $json ) >- ->status_is(204) >- ->content_is(q{}); >- >- $schema->storage->txn_rollback; >-}; >- > subtest 'password validation - account lock out' => sub { > > plan tests => 6; >@@ -72,8 +54,8 @@ subtest 'password validation - account lock out' => sub { > t::lib::Mocks::mock_preference( 'FailedLoginAttempts', 1 ); > > my $json = { >- "userid" => $userid, >- "password" => "bad", >+ identifier => $userid, >+ password => "bad", > }; > > $t->post_ok( "//$userid:$password@/api/v1/auth/password/validation" => json => $json ) >@@ -89,43 +71,6 @@ subtest 'password validation - account lock out' => sub { > $schema->storage->txn_rollback; > }; > >- >-subtest 'password validation - bad userid' => sub { >- >- plan tests => 3; >- >- $schema->storage->txn_begin; >- >- my $json = { >- "userid" => '1234567890abcdefghijklmnopqrstuvwxyz@koha-community.org', >- "password" => $password, >- }; >- >- $t->post_ok( "//$userid:$password@/api/v1/auth/password/validation" => json => $json ) >- ->status_is(400) >- ->json_is({ error => q{Validation failed} }); >- >- $schema->storage->txn_rollback; >-}; >- >-subtest 'password validation - bad password' => sub { >- >- plan tests => 3; >- >- $schema->storage->txn_begin; >- >- my $json = { >- "userid" => $userid, >- "password" => 'bad', >- }; >- >- $t->post_ok( "//$userid:$password@/api/v1/auth/password/validation" => json => $json ) >- ->status_is(400) >- ->json_is({ error => q{Validation failed} }); >- >- $schema->storage->txn_rollback; >-}; >- > subtest 'password validation - unauthorized user' => sub { > > plan tests => 3; >@@ -143,8 +88,8 @@ subtest 'password validation - unauthorized user' => sub { > my $userid = $patron->userid; > > my $json = { >- "userid" => $userid, >- "password" => "test", >+ identifier => $userid, >+ password => "test", > }; > > $t->post_ok( "//$userid:$password@/api/v1/auth/password/validation" => json => $json ) >@@ -160,8 +105,8 @@ subtest 'password validation - unauthenticated user' => sub { > $schema->storage->txn_begin; > > my $json = { >- "userid" => "banana", >- "password" => "test", >+ identifier => "banana", >+ password => "test", > }; > > $t->post_ok( "/api/v1/auth/password/validation" => json => $json ) >@@ -171,4 +116,40 @@ subtest 'password validation - unauthenticated user' => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'Password validation - authorized requests tests' => sub { >+ >+ plan tests => 9; >+ >+ $schema->storage->txn_begin; >+ >+ my $json = { >+ identifier => $librarian->userid, >+ password => $password, >+ }; >+ >+ $t->post_ok( "//$userid:$password@/api/v1/auth/password/validation" => json => $json ) >+ ->status_is(204, 'Validating using `cardnumber` works') >+ ->content_is(q{}); >+ >+ $json = { >+ identifier => $librarian->cardnumber, >+ password => $password, >+ }; >+ >+ $t->post_ok( "//$userid:$password@/api/v1/auth/password/validation" => json => $json ) >+ ->status_is(204, 'Validating using `cardnumber` works') >+ ->content_is(q{}); >+ >+ $json = { >+ identifier => 'banana', >+ password => $password, >+ }; >+ >+ $t->post_ok( "//$userid:$password@/api/v1/auth/password/validation" => json => $json ) >+ ->status_is(400, 'Validating using and invalid identifier fails') >+ ->json_is({ error => q{Validation failed} }); >+ >+ $schema->storage->txn_rollback; >+}; >+ > $schema->storage->txn_rollback; >-- >2.41.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 32739
:
153574
|
153575
|
153683
|
153684
|
153776
|
153777
|
153816
|
153817
|
153841
|
153842
|
153885
|
153886
|
153887