Skip to content

Commit

Permalink
t: Extend 03-auth-openid.t for _create_user and call checks
Browse files Browse the repository at this point in the history
  • Loading branch information
okurz committed Aug 16, 2022
1 parent 02c86c3 commit 9ab8eee
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions t/03-auth-openid.t
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 9ab8eee

Please sign in to comment.