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))
def view(id): relation = object_or_404(Relation.by_id(id)) authz.require(authz.relation_read(relation)) return jsonify(relation)