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

Prevent file extension and content type mismatch #82

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

asuresh-code
Copy link
Contributor

@asuresh-code asuresh-code commented Dec 19, 2024

Description

See #81 Implements Option 3 (Store File Extension w/ Filename) Makes Changes to the edit service layer, to ensure that file extension is preserved.

Testing instructions

Add a set up instructions describing how the reviewer should test the code

  • Review code
  • Check Actions build
  • Review changes to test coverage
  • {more steps here}

Agile board tracking

closes #81

@asuresh-code asuresh-code marked this pull request as draft December 19, 2024 11:38
@asuresh-code asuresh-code self-assigned this Dec 24, 2024
@codecov-commenter
Copy link

codecov-commenter commented Jan 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.30%. Comparing base (225598b) to head (e433f11).
Report is 4 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop      #82      +/-   ##
===========================================
+ Coverage    98.89%   99.30%   +0.41%     
===========================================
  Files           21       19       -2     
  Lines          453      434      -19     
===========================================
- Hits           448      431      -17     
+ Misses           5        3       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@asuresh-code asuresh-code marked this pull request as ready for review January 2, 2025 10:56
object_storage_api/stores/image.py Outdated Show resolved Hide resolved
object_storage_api/stores/image.py Outdated Show resolved Hide resolved
object_storage_api/services/image.py Outdated Show resolved Hide resolved
test/unit/services/test_image.py Outdated Show resolved Hide resolved
@joelvdavies
Copy link
Collaborator

One other thing could you perhaps update the names of this PR and the issue to reflect its new purpose of preventing invalid files/add the issue to the IMS project board please, just helps us find things again.

@asuresh-code asuresh-code changed the title Single/Multiple Image Download Prevent file extension and content type mismatch Jan 14, 2025
@joelvdavies joelvdavies requested a review from VKTB January 15, 2025 09:50
Copy link
Member

@rowan04 rowan04 left a comment

Choose a reason for hiding this comment

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

looks good, some very minor changes!

"""
Mocks repo & store methods appropriately to test the `create` service method.

:param image_post_metadata_data: Dictionary containing the image metadata data as would be required for an
`ImagePostMetadataSchema`.
:filename: Filename of the image.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
:filename: Filename of the image.
:param filename: Filename of the image.

Comment on lines +334 to +337
Class the `ImageService` `update` method with the appropriate data from a prior call to `mock_update`.
while expecting an error to be raised.

:param error_type: Expected exception to be raised.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Class the `ImageService` `update` method with the appropriate data from a prior call to `mock_update`.
while expecting an error to be raised.
:param error_type: Expected exception to be raised.
Class the `ImageService` `update` method with the appropriate data from a prior call to `mock_update`,
while expecting an error to be raised.
:param image_id: ID of the image to be updated.
:param error_type: Expected exception to be raised.

@@ -356,6 +394,20 @@ def test_update_primary(self):
self.call_update(image_id)
self.check_update_success()

def test_update_with_file_extension_content_type_mismatch(self):
"""Test updating filename to a mismatched file extension."""
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"""Test updating filename to a mismatched file extension."""
"""Test updating filename to one with a mismatched file extension."""

@rowan04
Copy link
Member

rowan04 commented Jan 16, 2025

This is also an issue on the attachments side - I have created an issue for it #96

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

Successfully merging this pull request may close these issues.

Prevent File extension and content type mismatch
4 participants