From deec4ab75d6478f51d6c72a230343ab955116a6b Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Tue, 25 Sep 2018 17:30:28 -0400 Subject: Bug 1494065 - Add a basic test using Test::Mojo --- Bugzilla/Quantum.pm | 2 +- Bugzilla/Test/Util.pm | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'Bugzilla') diff --git a/Bugzilla/Quantum.pm b/Bugzilla/Quantum.pm index 8af06c477..c64e57e13 100644 --- a/Bugzilla/Quantum.pm +++ b/Bugzilla/Quantum.pm @@ -34,7 +34,7 @@ sub startup { DEBUG('Starting up'); $self->plugin('Bugzilla::Quantum::Plugin::Glue'); - $self->plugin('Bugzilla::Quantum::Plugin::Hostage'); + $self->plugin('Bugzilla::Quantum::Plugin::Hostage') unless $ENV{BUGZILLA_DISABLE_HOSTAGE}; $self->plugin('Bugzilla::Quantum::Plugin::BlockIP'); $self->plugin('Bugzilla::Quantum::Plugin::BasicAuth'); 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; -- cgit v1.2.3-24-g4f1b