-
Notifications
You must be signed in to change notification settings - Fork 786
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
Fix error when removing uploaded post breach file on config reset #1054
Fix error when removing uploaded post breach file on config reset #1054
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #1054 +/- ##
===========================================
- Coverage 29.13% 29.01% -0.13%
===========================================
Files 410 409 -1
Lines 12934 12912 -22
===========================================
- Hits 3768 3746 -22
Misses 9166 9166
Continue to review full report at Codecov.
|
8ef0986
to
f61f9ed
Compare
f61f9ed
to
1ad8249
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice, but not mandatory, to add some tests for this function. I'm not sure if pytest plays nicely with the @jwt_required
decorator.
… another function
f84cdac
to
4f94e9d
Compare
@mssalvatore I'm not sure how much value we'll get out of adding tests for this. |
Had we had the tests in the first place, this bug might have been prevented. Where possible, we should try to first write a test that reproduces the issue, then fix it and see that the test passes. A set of tests for this function seems feasible. It's also a good opportunity to investigate the best way to test our API endpoints. |
@@ -96,3 +93,11 @@ def upload_pba_file(request_, is_linux=True): | |||
(PBA_LINUX_FILENAME_PATH if is_linux else PBA_WINDOWS_FILENAME_PATH), filename | |||
) | |||
return filename | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend putting this method immediately after the one that calls it so as to follow the Stepdown rule
@@ -69,13 +69,10 @@ def delete(self, file_type): | |||
PBA_LINUX_FILENAME_PATH if file_type == "PBAlinux" else PBA_WINDOWS_FILENAME_PATH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the value of adding tests, does this function behave in a sane way if I pass an invalid value for file_type
?
…load.py` to follow stepdown rule
Fixes:
os.remove(file_path)
inmonkey_island/cc/resources/pba_file_upload.py
attempts to delete a directory which throws an error when the PBA_linux_filename/PBA_windows_filename field in the database is empty.To reproduce: