Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return consistent status codes from REST API delete operations #1907

Merged
merged 13 commits into from Aug 27, 2023

Conversation

dregad
Copy link
Member

@dregad dregad commented Aug 26, 2023

Fixes #32858 + code cleanup

Follows up on discussion in #1905

Update PHPDoc and @noinspection tags accordingly.
The test case was defined with a data provider, but did not actually
use it...
Based on the default value for $g_user_login_valid_regex

- `vboctor@localhost` -> a TLD is required
- `user!` -> only letters, numbers, `-.+_` and space are allowed
Update the test case to prepare for change of returned status code to
404 when trying to delete a non-existing user.

Remove the assertion from RestBase::tearDown(), the check for a
successful deletion should be done in the actual test cases.

Issue #32858
Covering
- attach a new tag
- attach existing tag
- detach tag
- detach unattached tag
- detach non-existing tag
- attach/detach on non-existing issue

Issue #32858
@dregad dregad requested a review from vboctor August 26, 2023 17:46
@dregad
Copy link
Member Author

dregad commented Aug 26, 2023

Note: there are currently no test cases for REST API /projects endpoint

Copy link
Member

@vboctor vboctor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dregad

The API tests shouldn't call internal APIs like tag_exists(). The need to do so is a symptom of missing APIs and couples the API tests with the codebase. Please remove such calls and identify gaps that we need with todos or issues in bug tracker - e.g. if we are missing a Get Tags API or equivalent.

@dregad
Copy link
Member Author

dregad commented Aug 27, 2023

The API tests shouldn't call internal APIs like tag_exists(). The need to do so is a symptom of missing APIs and couples the API tests with the codebase.

I can hear the argument about such usage being an indicator that the API has missing endpoints and needs improvement. On the other hand, I strongly disagree that the internal calls should be removed before the new endpoints are available.

Doing so means reducing the tests's coverage and quality, which does not make sense. I'm OK to flag them with a TODO, but getting rid of them is not a good idea.

Some of these usages, e.g. the loop to find a non-existing Id or ensuring a tag name's uniqueness, make absolutely no sense to implement with repeated REST calls; it adds no value, and is less efficient.

@dregad
Copy link
Member Author

dregad commented Aug 27, 2023

Opened #32863 to track adding CRUD endpoints for Tags management.

@dregad dregad merged commit 02601fe into mantisbt:master Aug 27, 2023
1 check passed
@dregad dregad deleted the i32858-api-delete-404 branch August 27, 2023 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants