diff options
author | Dylan William Hardison <dylan@hardison.net> | 2018-09-25 23:30:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-25 23:30:28 +0200 |
commit | deec4ab75d6478f51d6c72a230343ab955116a6b (patch) | |
tree | 168e7380ded24cedac218abbc0212567ce41b67c /Bugzilla/Test | |
parent | 137a983d511bfed23a914946dde4b7cf1108a726 (diff) | |
download | bugzilla-deec4ab75d6478f51d6c72a230343ab955116a6b.tar.gz bugzilla-deec4ab75d6478f51d6c72a230343ab955116a6b.tar.xz |
Bug 1494065 - Add a basic test using Test::Mojo
Diffstat (limited to 'Bugzilla/Test')
-rw-r--r-- | Bugzilla/Test/Util.pm | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/Bugzilla/Test/Util.pm b/Bugzilla/Test/Util.pm index 02c842658..8124c25ee 100644 --- a/Bugzilla/Test/Util.pm +++ b/Bugzilla/Test/Util.pm @@ -12,9 +12,10 @@ use strict; use warnings; use base qw(Exporter); -our @EXPORT = qw(create_user); +our @EXPORT = qw(create_user issue_api_key); use Bugzilla::User; +use Bugzilla::User::APIKey; sub create_user { my ($login, $password, %extra) = @_; @@ -29,4 +30,21 @@ sub create_user { }); } +sub issue_api_key { + my ($login, $given_api_key) = @_; + my $user = Bugzilla::User->check({ name => $login }); + + my $params = { + user_id => $user->id, + description => 'Bugzilla::Test::Util::issue_api_key', + api_key => $given_api_key, + }; + + if ($given_api_key) { + return Bugzilla::User::APIKey->create_special($params); + } else { + return Bugzilla::User::APIKey->create($params); + } +} + 1; |