Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Bugzilla/Util.pm
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,9 @@ sub i_am_cgi {

sub i_am_webservice {
my $usage_mode = Bugzilla->usage_mode;
return $usage_mode == USAGE_MODE_JSON || $usage_mode == USAGE_MODE_REST;
return $usage_mode == USAGE_MODE_JSON
|| $usage_mode == USAGE_MODE_REST
|| $usage_mode == USAGE_MODE_MOJO_REST;
}

sub is_webserver_group {
Expand Down
9 changes: 9 additions & 0 deletions qa/t/rest_components.t
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ $t->post_ok($url . 'rest/component/Firefox' => json => $new_component)
->json_is(
'/message' => 'You must log in before using this part of Bugzilla.');

# Authenticated but unprivileged. This message is 110 characters long, so an
# exact match also pins that native REST errors are not wrapped at 72 columns.
$t->post_ok($url
. 'rest/component/Firefox' =>
{'X-Bugzilla-API-Key' => $config->{unprivileged_user_api_key}} => json =>
$new_component)->status_is(401)->json_is('/message' =>
"Sorry, you aren't a member of the 'editcomponents' group, and so you are not authorized to add new components."
);

# Now try as authenticated user using API key. But a required field is missing (default_assignee).
$t->post_ok($url
. 'rest/component/Firefox' => {'X-Bugzilla-API-Key' => $api_key} => json =>
Expand Down
54 changes: 54 additions & 0 deletions qa/t/rest_github_push_comment.t
Original file line number Diff line number Diff line change
Expand Up @@ -399,4 +399,58 @@ $t->post_ok(
} => json => $payload
)->status_is(200)->json_has("/bugs/$bug_id_3/id");

# An automation update must not clear restrict_comments on the bug it touches.

$new_bug = {
product => 'Firefox',
component => 'General',
summary => 'Test GitHub Push Commenting (restrict_comments)',
type => 'defect',
version => 'unspecified',
severity => 'blocker',
description => 'This is a new test bug',
};

$t->post_ok(
$url . 'rest/bug' => {'X-Bugzilla-API-Key' => $api_key} => json => $new_bug)
->status_is(200)->json_has('/id');

my $bug_id_4 = $t->tx->res->json->{id};

$t->put_ok($url
. "rest/bug/$bug_id_4" => {'X-Bugzilla-API-Key' => $api_key} => json =>
{restrict_comments => 1})->status_is(200);

$payload = {
ref => 'refs/heads/master',
repository => {
full_name => 'mozilla-mobile/firefox-android',
default_branch => 'master',
},
commits => [{
author => {username => 'foobar', name => 'Foo Bar'},
url => 'https://github.com/mozilla-bteam/bmo/commit/abcdefghijklmnopqrstuvwxyz',
message => "Bug $bug_id_4 - Test Github Push Comment (restrict_comments)",
}]
};

$t->post_ok(
$url
. 'rest/github/push_comment' => {
'X-Hub-Signature-256' => generate_payload_signature($secret, $payload),
'X-GitHub-Event' => 'push'
} => json => $payload
)->status_is(200)->json_has("/bugs/$bug_id_4/id");

$comment_id = $t->tx->res->json->{bugs}->{$bug_id_4}->{id};

# restrict_comments is not exposed by the REST bug API, so assert its effect:
# a user outside restrict_comments_group still cannot react to the comment.
$t->put_ok($url
. "rest/bug/comment/$comment_id/reactions" =>
{'X-Bugzilla-API-Key' => $config->{unprivileged_user_api_key}} => json =>
{add => ['-1']})->status_is(400)
->json_is('/message' =>
'You are not allowed to react to comments on this bug.');

done_testing();
Loading