Skip to content
This repository has been archived by the owner on Mar 31, 2021. It is now read-only.

Commit

Permalink
Merge pull request #55 from diox/fix-permissions-checking
Browse files Browse the repository at this point in the history
Fix permission checking (bug 1178810)
  • Loading branch information
diox committed Aug 5, 2015
2 parents 7762a03 + 063e35e commit 4678dce
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 1 addition & 3 deletions appvalidator/specs/webapps.py
Expand Up @@ -730,7 +730,7 @@ def process_permissions(self, node):
requested_permissions = set()

for permission, per_node in node.items():
if permission in PRERELEASE_PERMISSIONS:
if permission in ALL_PERMISSIONS:
requested_permissions.add(permission)

if permission not in self.PERMISSIONS_ACCESS:
Expand Down Expand Up @@ -762,8 +762,6 @@ def process_permissions(self, node):
"Found value: %s" % access_value,
self.MORE_INFO])

requested_permissions.add(permission)

self.err.save_resource("permissions", list(requested_permissions))

def process_origin(self, node):
Expand Down
6 changes: 6 additions & 0 deletions tests/helper.py
Expand Up @@ -155,6 +155,12 @@ def assert_has_feature(self, name):
'"%s" not found in feature profile (%s)' % (
name, ', '.join(self.err.feature_profile)))

def assert_has_permission(self, name):
permissions = self.err.get_resource("permissions")
assert name in permissions, (
'"%s" not found in permissions (%s)' % (
name, ', '.join(permissions)))


class MockZipFile:

Expand Down
6 changes: 5 additions & 1 deletion tests/test_webapp.py
Expand Up @@ -1134,12 +1134,17 @@ def test_permissions_full(self):
self.set_permissions()
self.analyze()
self.assert_silent()
for perm in appvalidator.constants.ALL_PERMISSIONS:
self.assert_has_permission(perm)

def test_permissions_extra_invalid(self):
self.set_permissions()
self.data["permissions"]["foo"] = {"description": "lol"}
self.analyze()
self.assert_failed(with_errors=True)
assert 'foo' not in self.err.get_resource("permissions")
for perm in appvalidator.constants.ALL_PERMISSIONS:
self.assert_has_permission(perm)

def test_permissions_missing_desc(self):
self.set_permissions()
Expand Down Expand Up @@ -1247,7 +1252,6 @@ def test_redirects_required_nodes(self):
self.analyze()
self.assert_failed(with_errors=True)


def test_redirects_missing_nodes(self):
self.data['redirects'] = [
{"to": "asdf"},
Expand Down

0 comments on commit 4678dce

Please sign in to comment.