Skip to content

Conversation

@0xtrr
Copy link
Owner

@0xtrr 0xtrr commented Nov 28, 2024

Adds unit tests for handler methods

Adds a new test to verify that we get the expected error upon an
invalid authorization event in the get_blob handler.
Also adds a new ConfigBuilder builder to make it easy to test
different configurations while also keeping the code clean and
easy to read.
Adds tempfile as a dependency. This will be used in tests for creating temporary directories used to store the database and files in tests.
Adds two new tests for the get blob handler. One test verifies that we get a 404 whenever we request a blob with an invalid file hash in the url path. The other test verifies that we get a 404 whenever we try to get a file where we don't find a matching blob descriptor.

I've also simplified the blob descriptor query code a bit to make it more readable and less verbose.

I've also refactored the set_up_app_state function in the handler tests to use the tempfile dependency instead. I did this because tempfile will delete the temporary folder whenever the temp_dir goes out of scope, i.e. it cleans up after each test so we don't get any side effects from other tests.
This also brings a change to the function signature as we have to return the temp_dir to ensure that the variable isn't dropped and the temp folder deleted. If that were to happen, we wouldn't be able to read from it anymore.
Validates that an invalid auth event in a /list/pubkey request returns a 401 response.
Adds test to verify that an upload with a non-whitelisted mimetype is rejected with a 415 UNSUPPORTED_MEDIA_TYPE response.
Adds a test to verify that an UNAUTHORIZED response is returned when the delete blob handler is handed an invalid auth event.
Adds a test to verify that an UNAUTHORIZED response is returned when the mirror blob handler is handed an invalid auth event.
Moves the get blob handler tests up to the first get blob handler test, just to keep the code clean and tidy.
@0xtrr 0xtrr merged commit ac52cf8 into main Nov 28, 2024
1 check passed
@0xtrr 0xtrr deleted the add-more-handler-tests branch November 28, 2024 18:04
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.

2 participants