From e696bbee48a065cdd3b50b0b04c49862aadbfbec Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Mon, 29 Sep 2025 14:11:19 +0300 Subject: [PATCH] Bug 40736: Restore commented out tests Commented out by https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=143438 (or https://github.com/Koha-Community/Koha/commit/9c5f6e8c1772ecb1c2ec8c25d6d32010ce6c263b#diff-9e449131ec9eb973ff6a851c0fda9a426255591e3f579c79b047fb2763f33e80R275 ) To test: 1. prove t/db_dependent/api/v1/idp.t --- t/db_dependent/api/v1/idp.t | 55 +++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/t/db_dependent/api/v1/idp.t b/t/db_dependent/api/v1/idp.t index 51e12776e62..7bfe970382f 100755 --- a/t/db_dependent/api/v1/idp.t +++ b/t/db_dependent/api/v1/idp.t @@ -20,7 +20,7 @@ use Modern::Perl; use Test::NoWarnings; -use Test::More tests => 3; +use Test::More tests => 4; use Test::Mojo; use Test::Warn; use Mojo::JWT; @@ -281,43 +281,44 @@ subtest 'domain endpoint tests' => sub { $schema->storage->txn_rollback; }; -# subtest 'oauth login tests' => sub { -# plan tests => 4; +subtest 'oauth login tests' => sub { + plan tests => 4; -# $schema->storage->txn_begin; + $schema->storage->txn_begin; -# Koha::Auth::Identity::Provider::Domains->delete; -# Koha::Auth::Identity::Providers->delete; + Koha::Auth::Identity::Provider::Domains->delete; + Koha::Auth::Identity::Providers->delete; -# my ( $borrowernumber, $session_id ) = create_user_and_session({ authorized => 1 }); + my ( $borrowernumber, $session_id ) = create_user_and_session( { authorized => 1 } ); -# my $t = Test::Mojo->new('Koha::REST::V1'); + my $t = Test::Mojo->new('Koha::REST::V1'); -# # Build provider -# my $tx = $t->ua->build_tx( POST => "/api/v1/auth/identity_providers", json => $oauth_provider_data ); -# $tx->req->cookies( { name => 'CGISESSID', value => $session_id } ); -# $tx->req->env( { REMOTE_ADDR => $remote_address } ); + # Build provider + my $tx = $t->ua->build_tx( POST => "/api/v1/auth/identity_providers", json => $oauth_provider_data ); + $tx->req->cookies( { name => 'CGISESSID', value => $session_id } ); + $tx->req->env( { REMOTE_ADDR => $remote_address } ); -# $t->request_ok($tx); -# my $provider_id = $t->tx->res->json->{identity_provider_id}; + $t->request_ok($tx); + my $provider_id = $t->tx->res->json->{identity_provider_id}; -# # Build domain -# $tx = $t->ua->build_tx( POST => "/api/v1/auth/identity_providers/$provider_id/domains", json => $domain_not_matching ); -# $tx->req->cookies( { name => 'CGISESSID', value => $session_id } ); -# $tx->req->env( { REMOTE_ADDR => $remote_address } ); + # Build domain + $tx = $t->ua->build_tx( + POST => "/api/v1/auth/identity_providers/$provider_id/domains", + json => $domain_not_matching + ); + $tx->req->cookies( { name => 'CGISESSID', value => $session_id } ); + $tx->req->env( { REMOTE_ADDR => $remote_address } ); -# $t->request_ok($tx); + $t->request_ok($tx); -# t::lib::Mocks::mock_preference( 'RESTPublicAPI', 1 ); + t::lib::Mocks::mock_preference( 'RESTPublicAPI', 1 ); -# # Simulate server restart -# $t = Test::Mojo->new('Koha::REST::V1'); + # Simulate server restart + $t = Test::Mojo->new('Koha::REST::V1'); -# #$t->ua->max_redirects(10); -# $t->get_ok("/api/v1/public/oauth/login/oauth_test/opac") -# ->status_is(302); -# $schema->storage->txn_rollback; -# }; + $t->get_ok("/api/v1/public/oauth/login/oauth_test/opac")->status_is(302); + $schema->storage->txn_rollback; +}; sub create_user_and_session { -- 2.34.1