Update webapi test suite to test invalid PUT/POST operations.

Review Request #13285 — Created Sept. 22, 2023 and submitted — Latest diff uploaded

Information

Review Board
release-6.x

Reviewers

The API resource implementation previously prevented POST requests to
item resources, and with a new change to Djblets, will also prevent PUT
requests to list resources. However, neither of these was properly
tested in the test suite.

This change updates our API test mixins to test these scenarios where
appropriate. Most of the individual test suites needed to add some setup
methods to handle this appropriately.

Unfortunately, the naming of the setup methods isn't ideal.
setup_http_not_allowed_item_test should really be
setup_http_not_allowed_put_test, and
setup_http_not_allowed_list_test should be
setup_http_not_allowed_post_test. These also do not currently support
similar test cases for when there is a local site (though that shouldn't
be a problem). Rather than trying to rename these methods now, I've just
gone with the old ones, and we can address the naming later. For this
reason I'm also holding off on adding missing docstrings or typing,
merely trying to match it to the individual style of each existing test
case.

Ran unit tests.

Diff Revision 1

This is not the most recent revision of the diff. The latest diff is revision 4. See what's changed.

orig
1
2
3
4

Commits

First Last Summary ID Author
Update webapi test suite to test invalid PUT/POST operations.
The API resource implementation previously prevented POST requests to item resources, and with a new change to Djblets, will also prevent PUT requests to list resources. However, neither of these was properly tested in the test suite. This change updates our API test mixins to test these scenarios where appropriate. Most of the individual test suites needed to add some setup methods to handle this appropriately. Unfortunately, the naming of the setup methods isn't ideal. `setup_http_not_allowed_item_test` should really be `setup_http_not_allowed_put_test`, and `setup_http_not_allowed_list_test` should be `setup_http_not_allowed_post_test`. These also do not currently support similar test cases for when there is a local site (though that shouldn't be a problem). Rather than trying to rename these methods now, I've just gone with the old ones, and we can address the naming later. For this reason I'm also holding off on adding missing docstrings or typing, merely trying to match it to the individual style of each existing test case. Testing Done: Ran unit tests.
9f83d024a8a515c134d343119f7546798d2b0d93 David Trowbridge
This diff has been split across 2 pages: 1 2 >
reviewboard/webapi/tests/mixins.py
reviewboard/webapi/tests/test_api_token.py
reviewboard/webapi/tests/test_default_reviewer.py
reviewboard/webapi/tests/test_diff.py
reviewboard/webapi/tests/test_diff_file_attachment.py
reviewboard/webapi/tests/test_diffcommit.py
reviewboard/webapi/tests/test_draft_diff.py
reviewboard/webapi/tests/test_draft_diffcommit.py
reviewboard/webapi/tests/test_draft_filediff.py
reviewboard/webapi/tests/test_file_attachment.py
reviewboard/webapi/tests/test_file_attachment_comment.py
reviewboard/webapi/tests/test_file_attachment_draft.py
reviewboard/webapi/tests/test_file_diff_comment.py
reviewboard/webapi/tests/test_hosting_service.py
reviewboard/webapi/tests/test_hosting_service_account.py
reviewboard/webapi/tests/test_oauth_app.py
reviewboard/webapi/tests/test_oauth_token.py
reviewboard/webapi/tests/test_remote_repository.py
reviewboard/webapi/tests/test_repository.py
reviewboard/webapi/tests/test_repository_group.py
This diff has been split across 2 pages: 1 2 >
Loading...