From f947af211a8034503b14ea33918598c440b80c02 Mon Sep 17 00:00:00 2001 From: Oliver Kurz Date: Wed, 24 Nov 2021 22:06:03 +0100 Subject: [PATCH] t: Extend 03-auth-openid.t for _create_user and call checks --- t/03-auth-openid.t | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/t/03-auth-openid.t b/t/03-auth-openid.t index 544268049338..71a3663f33e5 100644 --- a/t/03-auth-openid.t +++ b/t/03-auth-openid.t @@ -15,18 +15,22 @@ is OpenQA::WebAPI::Auth::OpenID::_first_last_name({'value.firstname' => 'Mordred '_first_last_name concats also with empty fields'; my (%openid_res, %openid_res2); my $vident = Test::MockObject->new->set_series('signed_extension_fields', \%openid_res, \%openid_res2); -$vident->{identity} = 'mordred'; +my $user = $vident->{identity} = 'mordred'; my $users = Test::MockObject->new->set_always('create_user', 1); my $schema = Test::MockObject->new->set_always(resultset => $users); my %session; -my $c - = Test::MockObject->new->set_always(schema => $schema)->set_always(session => \%session)->set_true('_create_user'); +my $c = Test::MockObject->new->set_always(schema => $schema); +ok OpenQA::WebAPI::Auth::OpenID::_create_user($c, $user, 'nobody\@example.com', $user, $user), 'can call _create_user'; +$c->set_always(session => \%session)->set_true('_create_user'); ok OpenQA::WebAPI::Auth::OpenID::_handle_verified($c, $vident), 'can call _handle_verified'; +$c->called_ok('_create_user', 'new user is created for initial login'); +is(($c->call_args(2))[1], 'mordred', 'new user created with details'); $c->set_always( req => Test::MockObject->new->set_always(params => Test::MockObject->new->set_always(pairs => [1, 2])) ->set_always(url => Test::MockObject->new->set_always(base => 'openqa'))) ->set_always(app => Test::MockObject->new->set_always(config => {}) ->set_always(log => Test::MockObject->new->set_true('error', 'debug')))->set_true('flash'); is OpenQA::WebAPI::Auth::OpenID::auth_response($c), 0, 'can call auth_response'; +$c->app->log->called_ok('error', 'an error was logged for call without proper config'); done_testing;