diff --git a/.travis.yml b/.travis.yml index c47fb43..0503b58 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,10 @@ os: linux language: python python: - "2.7" - - "3.5" - "3.6" - "3.7" + - "3.8" + - "3.9" install: - python setup.py install - pip install coveralls diff --git a/iiif-presentation-validator.py b/iiif-presentation-validator.py index 79ee83c..3da51a5 100755 --- a/iiif-presentation-validator.py +++ b/iiif-presentation-validator.py @@ -69,6 +69,10 @@ def check_manifest(self, data, version, url=None, warnings=[]): infojson = schemavalidator.validate(data, version, url) for error in infojson['errorList']: error.pop('error', None) + + mf = json.loads(data) + if url and 'id' in mf and mf['id'] != url: + raise ValidationError("The manifest id ({}) should be the same as the URL it is published at ({}).".format(mf["id"], url)) except ValidationError as e: infojson = { 'received': data, @@ -93,6 +97,8 @@ def check_manifest(self, data, version, url=None, warnings=[]): try: mf = reader.read() mf.toJSON() + if url and mf.id != url: + raise ValidationError("Manifest @id ({}) is different to the location where it was retrieved ({})".format(mf.id, url)) # Passed! okay = 1 except Exception as e: diff --git a/tests/test_validator.py b/tests/test_validator.py index b9ba60c..5da9e0e 100644 --- a/tests/test_validator.py +++ b/tests/test_validator.py @@ -95,11 +95,11 @@ def test05_do_GET_test(self): # input data works only the first time. Instead create a new request # object to similate each web request, with data that sets request.environ v = val_mod.Validator() - request = LocalRequest({'QUERY_STRING': 'url=https://example.org/a'}) + request = LocalRequest({'QUERY_STRING': 'url=http://iiif.io/api/presentation/2.0/example/fixtures/1/manifest.json'}) v.fetch = Mock(return_value=(read_fixture('fixtures/1/manifest.json'), MockWebHandle())) j = json.loads(v.do_GET_test()) self.assertEqual(j['okay'], 1) - self.assertEqual(j['url'], 'https://example.org/a') + self.assertEqual(j['url'], 'http://iiif.io/api/presentation/2.0/example/fixtures/1/manifest.json') # fetch failure v = val_mod.Validator() request = LocalRequest({'QUERY_STRING': 'url=http://example.org/a'})