def test_authorized_scopes(): permissions = Permissions() for scope in permissions.authorized_scopes: permissions.grant(scope, 'persona', 'topic') assert permissions.authorize(scope, 'persona', 'topic') is True assert permissions.authorize('*unknown*', 'persona', 'topic') is False assert permissions.authorize(scope, '*unknown*', 'topic') is False assert permissions.authorize(scope, 'persona', '*unknown*') is False
def test_grant_and_authorize(): permissions = Permissions(authorized_scopes=['scope']) assert permissions.count() == 0 assert permissions.authorize( scope='scope', persona='persona', topic='topic') is False permissions.grant(scope='scope', persona='persona', topic='topic') assert permissions.count() == 1 assert permissions.authorize( scope='scope', persona='persona', topic='topic') is True assert permissions.authorize( scope='*unknown*', persona='persona', topic='topic') is False assert permissions.authorize( scope='scope', persona='*unknown*', topic='topic') is False assert permissions.authorize( scope='scope', persona='persona', topic='*unknown*') is False