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

API call /maintenance/{mw_id} on PATCH is returning misleading response status #44

Open
ArturoQuintana opened this issue May 14, 2021 · 0 comments

Comments

@ArturoQuintana
Copy link

  • The action to PATCH a payload where the items field is empty is returning 201 when it should be 400.

Example:
payload1 = {
"start": start.strftime(TIME_FMT),
"end": new_time.strftime(TIME_FMT)
}
mw_api_url = KYTOS_API + '/maintenance/' + mw_id
request = requests.patch(mw_api_url, data=json.dumps(payload1), headers={'Content-type': 'application/json'})

Reflected on end-to-end test:
tests/test_e2e_15_maintenance.py::TestE2EMaintenance::test_036_patch_mw_on_switch_should_fail_wrong_payload_items_empty

  • The action to PATCH a payload with no items field is returning 201 when it should be 400.

Example:
payload1 = {
"start": start.strftime(TIME_FMT),
"end": new_time.strftime(TIME_FMT)
}
mw_api_url = KYTOS_API + '/maintenance/' + mw_id
request = requests.patch(mw_api_url, data=json.dumps(payload1), headers={'Content-type': 'application/json'})

Reflected on end-to-end test:
tests/test_e2e_15_maintenance.py::TestE2EMaintenance::test_038_patch_mw_on_switch_should_fail_wrong_payload_no_items_field

  • A PATCH action using a not serializable JSON broke the application, and it should return a 400 error.

Example:
payload1 = {
"description"
}
mw_api_url = KYTOS_API + '/maintenance/' + mw_id
request = requests.patch(mw_api_url, data=json.dumps(payload1), headers={'Content-type': 'application/json'})

Reflected on end-to-end test: tests/test_e2e_15_maintenance.py::TestE2EMaintenance::test_039_patch_mw_on_switch_should_fail_wrong_payload

ajoaoff added a commit to ajoaoff/maintenance that referenced this issue Jun 8, 2021
Fix some return codes on update, delete and end maintenance.
Fix kytos#44
ajoaoff added a commit to ajoaoff/maintenance that referenced this issue Jun 8, 2021
Fix some return codes on update, delete and end maintenance.
Fix kytos#44
ajoaoff added a commit to ajoaoff/maintenance that referenced this issue Jun 11, 2021
Fix some return codes on update, delete and end maintenance.
Fix kytos#44
ajoaoff referenced this issue in kytos-ng/maintenance Jun 18, 2021
* Use werkzeug Exception classes

Use werkzeug exception classes to return the correct error
codes.
Also raise a ValueError if no item is provided on creation
Fixes #43

* Fix return codes

Fix some return codes on update, delete and end maintenance.
Fix #44

* Upgrade versions and fix linter issues

* Fixed test error

* Do not allow items with empty list on update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant