Repository navigation
Conversation
…jo API POST /rest/invalid_bug_helper/close/<id> is now served by the native controller Bugzilla::Extension::InvalidBugHelper::API::V1::InvalidBugHelper instead of the legacy REST server. Same path, parameters, checks and response, mark_as_spam must now be a boolean. The legacy WebService module and its webservice hook are removed, and the extension test now goes through the real route.
GET /rest/bitly/shorten and GET /rest/bitly/list are now served by the native controller
Bugzilla::Extension::Bitly::API::V1::Bitly instead of the legacy REST server.
Same paths, url parameter, checks and {url} response.
The legacy WebService module and its webservice hook are removed, and a test covers
both routes.
… API GET /rest/prod_comp_search/find/<search> and GET /rest/prod_comp_search/frequent are now served by the native controller Bugzilla::Extension::ProdCompSearch::API::V1::ProdCompSearch instead of the legacy REST server. Same paths, limit parameter, queries and responses. The legacy WebService module and its webservice hook are removed, and a test covers both routes.
GET /rest/editcomments/comment[/<id>], PUT /rest/editcomments/comment/<id> and PUT /rest/editcomments/revision are now served by the native controller Bugzilla::Extension::EditComments::API::V1::EditComments instead of the legacy REST server. Same paths, parameters, checks and responses and is_hidden must now be a boolean (true/false/1/0). The legacy WebService module and its webservice hook are removed, and a test covers the four routes.
…ojo API GET and POST /rest/component-watching, GET and DELETE /rest/component-watching/<id> are now served by the native controller Bugzilla::Extension::ComponentWatching::API::V1::ComponentWatching instead of the legacy REST server. Same paths, parameters, checks and responses, except that product_access_denied now names the product (it was passed as product instead of name, so the message showed ''). The Preferences page gets the same fix. The legacy WebService module and its webservice hook are removed, and a test covers the four routes. rest_legacy_credentials.t moves to GET /rest/bug_modal/initial_field_values, still on the legacy server.
GET /rest/mydashboard/run_bug_query, run_flag_query and run_last_changes, and PUT /rest/mydashboard/bug_interest_unmark (also still served without the prefix) are now served by the native controller Bugzilla::Extension::MyDashboard::API::V1::MyDashboard instead of the legacy REST server. Same paths, parameters, checks and responses. The two query methods still read from the shadow database. The legacy WebService module and its webservice hook are removed, and a test covers the five routes.
query_flags meant to accept only requestee and requester, but its check (ne || ne) was always true, so any other type was treated as requester and returned under that key. It now throws param_invalid, and Queries.pm imports Bugzilla::Error, which that error path never needed before.
GET /rest/phabbugz/check_bug/<bug_id>/<user_id>, GET /rest/phabbugz/check_enter_bug/<product>/<user_id>, GET /rest/phabbugz/bug_revisions/<bug_id> and GET /rest/phabbugz/user/<user_id> are now served by the existing native controller Bugzilla::Extension::PhabBugz::API::V1::PhabBugz instead of the legacy REST server. Same paths, checks and responses. The three read-only ones still use the shadow database. The legacy WebService module and its webservice hook are removed, and webservice.t now calls the routes.
GET /rest/review/suggestions (by bug ID, product, product/component or query params) and GET /rest/review/flag_activity (by flag ID, type name, requestee, setter, type ID or query params) are now served by the native controller Bugzilla::Extension::Review::API::V1::Review instead of the legacy REST server. Same paths, parameters, checks and responses, include_fields and exclude_fields included. The legacy WebService module and its webservice hook are removed, and a test covers both methods.
GET /rest/bug_modal/initial_field_values, product_info, edit/<id>, cc/<id>, comment_tags/<id> and new_product/<id>, and PUT /rest/bug_modal/update_comment_tags/<id> are now served by the native controller Bugzilla::Extension::BugModal::API::V1::BugModal instead of the legacy REST server. Same paths, parameters, checks and responses. A bug id sent as a hash is now refused, as on the core bug routes. The legacy WebService module and its webservice hook are removed, and a test covers the seven routes. rest_legacy_credentials.t is deleted: no resource is left on the legacy REST server.
On a GET, the legacy REST server kept the id from the path even when the query string had one, and only a PUT body or query string replaced it. The controller let a query-string id win on GET too, so GET /rest/bug_modal/edit/5?id=6 answered for bug 6. The path id wins again on GET, which also makes the hash id check unneeded, so it is removed.
…required The legacy route matched /prod_comp_search/find/ with an empty search and returned the param_required error. The *search placeholder needed at least one character, so it was a 404. The placeholder now defaults to ''.
The legacy route matched /review/flag_activity/requestee/ (and setter/, type_id/) with an empty value, which was then ignored. The *value placeholder made it a 404. The placeholder now defaults to ''.
| my ($self, $lists) = @_; | ||
| my ($params, $error) = merge_request_params($self, $lists); | ||
| return (undef, $error) if $error; | ||
| if (defined(my $id = $self->param('comment_id'))) { |
There was a problem hiding this comment.
$self->param('comment_id') falls back to the query string, so GET /editcomments/comment?comment_ids=1&comment_ids=2&comment_id=3 only returns comment 3, $self->stash('comment_id') would only read the path
There was a problem hiding this comment.
Thanks! Followed your suggestion: _params now reads stash('comment_id'), so only the path ID is used, and the test checks that a comment_id in the query string is ignored.
Fixed in 904f10ff2
| ); | ||
|
|
||
| $t->get_ok('/rest/phabbugz/bug_revisions/' . $bug->id) | ||
| ->status_is(401, 'bug_revisions needs a login'); |
There was a problem hiding this comment.
no test that bug_revisions refuses a bug the caller can't see, worth adding one with the $private bug since that check is what keeps revision titles and reviewers hidden
There was a problem hiding this comment.
Test added: bug_revisions on the $private bug is refused for the author, and the test checks that no Conduit call is made for it.
Fixed in c2fc05082
| ); | ||
| $t->get_ok('/rest/editcomments/comment') | ||
| ->status_is(400) | ||
| ->json_like('/message' => qr/comment_ids/, 'comment_ids is required'); |
There was a problem hiding this comment.
no private comment or secure bug cases here, can we add a non-insider and a signed-out GET plus a PUT on a private comment so the comment_is_private and check_is_visible checks stay covered
There was a problem hiding this comment.
Yes sure, you right, I should have added these tests...:/
Added in 8793ee385:
- GET of a private comment as a non-insider and signed out
- GET of a comment on a bug in a group the caller isn't in (also signed out)
- a PUT on a private comment by the admin (not an insider)
- and a PUT on a comment on the hidden bug
Thanks! :)
| ->status_is(200) | ||
| ->json_like('/html' => qr/data-user-id="${\ $admin->id }"/, 'cc list html'); | ||
| $t->get_ok('/rest/bug_modal/cc/999999999') | ||
| ->json_is('/error' => 1, 'unknown bug'); |
There was a problem hiding this comment.
edit, cc and new_product are only tried on a public bug, could we add a secure bug the caller can't see, plus update_comment_tags by a user who isn't in the taggers group
There was a problem hiding this comment.
Good suggestion, thanks! :)
Added in 4a3b24a74: edit, cc and new_product on a bug in a group the caller isn't in are refused, and update_comment_tags by a user outside the comment taggers group is refused.
| ->json_is('/results/0/last_changes/email' => $admin->login) | ||
| ->json_has('/results/0/last_changes/when'); | ||
| $t->get_ok('/rest/mydashboard/run_last_changes?bug_id=999999999' => \%auth) | ||
| ->json_is('/error' => 1, 'unknown bug'); |
There was a problem hiding this comment.
run_last_changes isn't tested on a bug the user can't see, or with a private comment for a non-insider, and both checks guard data here
|
|
||
| $t->post_ok($close_url . $bug_from_plain_reporter->id) | ||
| ->status_is(401) | ||
| ->json_is('/code' => 410, 'anonymous request needs a login'); |
There was a problem hiding this comment.
this endpoint closes and moves bugs but there's no test that a non-editbugs caller gets refused, or that a bug in a mandatory group the caller isn't in gets refused
Summary
Moves the REST endpoints that extensions still registered through the
webservicehook from the legacy REST server to native Mojo controllers (extensions/<Name>/lib/API/V1/<Name>.pm), one commit per extension. Paths, parameters and responses stay the same, except for the changes listed below.Last step of 2057358 before the legacy REST server can be removed in 2081819: no resource is left on it after this PR.
Changes
lib/WebService.pmandwebservicehook: InvalidBugHelper, Bitly, ProdCompSearch, EditComments, ComponentWatching, MyDashboard, PhabBugz (added to its existing controller), Review, BugModal.mark_as_spam(InvalidBugHelper) andis_hidden(EditComments) must now be booleans (true/false/1/0).comment_idsent with aPUTno longer replaces the one in the path.run_flag_queryrefuses atypeother thanrequesteeorrequester, which it used to treat asrequester.qa/t/rest_legacy_credentials.tis removed, as no endpoint is left on the legacy server.t/bmotests in each extension call the routes.Test plan
enter_bug.cgiReferences