Skip to content

Commit

Permalink
Temporarily relax the Checksum URI check (#96)
Browse files Browse the repository at this point in the history
* Temporarily relax the Checksum URI check
  • Loading branch information
andamian authored Sep 12, 2018
1 parent 3e0f9c5 commit b9e6bb5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
18 changes: 11 additions & 7 deletions caom2/caom2/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,14 @@

from builtins import int, str
from six.moves.urllib.parse import SplitResult, urlparse
import logging

from . import caom_util

__all__ = ['CaomObject', 'AbstractCaomEntity', 'ObservationURI', 'ChecksumURI']

logger = logging.getLogger('caom2')


def get_current_ivoa_time():
"""Generate a datetime with 3 digit microsecond precision.
Expand Down Expand Up @@ -341,14 +344,15 @@ def __init__(self, uri):
# note: urlparse does not recognize scheme in uri of form scheme:val
tmp = uri.split(':', 1)

# TODO change this raise a ValueError when the rule is being enforced
if len(tmp) < 2:
raise ValueError(
("A checksum scheme noting the algorithm is "
"required.. received: {}")
.format(uri))

algorithm = tmp[0]
checksum = tmp[1]
logger.warn(("A checksum scheme noting the algorithm is "
"required.. received: {}").format(uri))
algorithm = None
checksum = tmp[0]
else:
algorithm = tmp[0]
checksum = tmp[1]

if checksum is None:
raise ValueError(
Expand Down
6 changes: 4 additions & 2 deletions caom2/caom2/tests/test_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,5 +181,7 @@ def test_all(self):
artifact.ReleaseType('META'),
artifact.ProductType('THUMBNAIL'))

with self.assertRaises(ValueError):
test_artifact.content_checksum = common.ChecksumURI('0x1234')
# TODO re-enable when check enforced
# with self.assertRaises(ValueError):
test_artifact.content_checksum = common.ChecksumURI('0x1234')
assert test_artifact.content_checksum.uri == '0x1234'

0 comments on commit b9e6bb5

Please sign in to comment.