Skip to content

Commit

Permalink
Fixes edfc0de (#16)
Browse files Browse the repository at this point in the history
* update bagProfileBar.json with up-to-date spec example
* make sure to check tag_file wildcards against bag basedir rel path
  • Loading branch information
kba authored and ruebot committed Dec 7, 2018
1 parent edfc0de commit 1403fb5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions bagit_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ def validate_tag_files_allowed(self, bag):

# For each tag file in the bag base directory, ensure it is also in 'Tag-Files-Allowed'.
for tag_file in find_tag_files(bag.path):
tag_file = relpath(tag_file, bag.path)
if not fnmatch_any(tag_file, allowed):
self._fail("%s: Existing tag file '%s' is not listed in Tag-Files-Allowed." % (bag, tag_file))

Expand Down
3 changes: 3 additions & 0 deletions fixtures/bagProfileBar.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@
"Tag-Manifests-Required":[
"md5"
],
"Tag-Files-Allowed":[
"DPN/*"
],
"Tag-Files-Required":[
"DPN/dpnFirstNode.txt",
"DPN/dpnRegistry"
Expand Down
5 changes: 3 additions & 2 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ def test_profile_kwarg(self):
profile_url = Profile(PROFILE_URL)
profile_dict = Profile(PROFILE_URL, profile=self.profile_dict)
profile_str = Profile(PROFILE_URL, profile=self.profile_str)
self.assertEqual(json.dumps(profile_url.profile), json.dumps(profile_dict.profile))
self.assertEqual(json.dumps(profile_str.profile), json.dumps(profile_dict.profile))
self.maxDiff = None
self.assertEqual(json.dumps(profile_str.profile), json.dumps(profile_dict.profile), 'Loaded from string')
self.assertEqual(json.dumps(profile_url.profile), json.dumps(profile_dict.profile), 'Loaded from URL')

class Test_bag_profile(TestCase):

Expand Down

0 comments on commit 1403fb5

Please sign in to comment.