Lines 37-43
my $schema = Koha::Database->new->schema;
Link Here
|
37 |
my $builder = t::lib::TestBuilder->new(); |
37 |
my $builder = t::lib::TestBuilder->new(); |
38 |
|
38 |
|
39 |
if ( can_load( modules => { 'Net::OAuth2::AuthorizationServer' => undef } ) ) { |
39 |
if ( can_load( modules => { 'Net::OAuth2::AuthorizationServer' => undef } ) ) { |
40 |
plan tests => 3; |
40 |
plan tests => 4; |
41 |
} else { |
41 |
} else { |
42 |
plan skip_all => 'Net::OAuth2::AuthorizationServer not available'; |
42 |
plan skip_all => 'Net::OAuth2::AuthorizationServer not available'; |
43 |
} |
43 |
} |
Lines 113-118
subtest 'Net::OAuth2::AuthorizationServer missing tests' => sub {
Link Here
|
113 |
$schema->storage->txn_rollback; |
113 |
$schema->storage->txn_rollback; |
114 |
}; |
114 |
}; |
115 |
|
115 |
|
|
|
116 |
subtest 'OAuth login input validation tests' => sub { |
117 |
plan tests => 6; |
118 |
|
119 |
$schema->storage->txn_begin; |
120 |
|
121 |
# Mock system preferences |
122 |
t::lib::Mocks::mock_preference( 'OPACBaseURL', 'http://opac.example.com' ); |
123 |
t::lib::Mocks::mock_preference( 'staffClientBaseURL', 'http://staff.example.com' ); |
124 |
t::lib::Mocks::mock_preference( 'OpacPublic', 1 ); |
125 |
|
126 |
# Test invalid interface parameter (should be validated by OpenAPI enum) |
127 |
$t->get_ok('/api/v1/oauth/login/test_provider/invalid') |
128 |
->status_is( 400, 'Invalid interface returns 400 due to OpenAPI enum validation' ); |
129 |
|
130 |
# Test non-existent provider (should redirect with error) |
131 |
$t->get_ok('/api/v1/oauth/login/nonexistent_provider/opac') |
132 |
->status_is( 302, 'Non-existent provider redirects with error' ); |
133 |
|
134 |
# Test missing provider_code and interface are handled by OpenAPI (404) |
135 |
$t->get_ok('/api/v1/oauth/login//opac')->status_is( 404, 'Missing provider_code returns 404' ); |
136 |
|
137 |
$schema->storage->txn_rollback; |
138 |
}; |
139 |
|
116 |
sub run_oauth_tests { |
140 |
sub run_oauth_tests { |
117 |
my ($test_case) = @_; |
141 |
my ($test_case) = @_; |
118 |
|
142 |
|
119 |
- |
|
|