示例#1
0
 def test_entity_read__readable(self):
     project, permission = _project_and_permission()
     entity_source = \
         Entity(project=project, status=authz.PUBLISHED_THRESHOLD)
     entity_target = \
         Entity(project=project, status=authz.PUBLISHED_THRESHOLD)
     db.session.add(entity_source)
     db.session.add(entity_target)
     rel = Relation(source=entity_source, target=entity_target)
     db.session.add(rel)
     db.session.commit()
     with self.app.test_request_context():
         flask.session['id'] = 1
         self.app.preprocess_request()
         self.assertTrue(authz.relation_read(rel))
示例#2
0
文件: test_authz.py 项目: 01-/grano
 def test_entity_read__readable(self):
     project, permission = _project_and_permission()
     entity_source = \
         Entity(project=project, status=authz.PUBLISHED_THRESHOLD)
     entity_target = \
         Entity(project=project, status=authz.PUBLISHED_THRESHOLD)
     db.session.add(entity_source)
     db.session.add(entity_target)
     rel = Relation(source=entity_source, target=entity_target)
     db.session.add(rel)
     db.session.commit()
     with self.app.test_request_context():
         flask.session['id'] = 1
         self.app.preprocess_request()
         self.assertTrue(authz.relation_read(rel))
示例#3
0
def view(id):
    relation = object_or_404(Relation.by_id(id))
    authz.require(authz.relation_read(relation))
    return jsonify(relation)
示例#4
0
def view(id):
    relation = object_or_404(Relation.by_id(id))
    authz.require(authz.relation_read(relation))
    return jsonify(relation)