-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sanitize content hashes in archive methods
Our content hashes are always hex digests and we should reject anything that contains non-hex characters.
- Loading branch information
1 parent
fc56a38
commit 07bea7b
Showing
8 changed files
with
107 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import pytest | ||
from unittest import TestCase | ||
|
||
from servicelayer.archive.util import sanitize_checksum | ||
|
||
|
||
class UtilTest(TestCase): | ||
def test_sanitize_checksum(self): | ||
assert sanitize_checksum("0123456789abcdef") == "0123456789abcdef" | ||
|
||
with pytest.raises(ValueError, match="Checksum is empty"): | ||
sanitize_checksum(None) | ||
|
||
with pytest.raises(ValueError, match="Checksum is empty"): | ||
sanitize_checksum("") | ||
|
||
with pytest.raises(ValueError, match='Checksum contains invalid character "n"'): | ||
sanitize_checksum("banana") | ||
|
||
with pytest.raises(ValueError, match='Checksum contains invalid character "/"'): | ||
sanitize_checksum("/") |