def test_review_request_with_invite_only_group(self): """Testing no access to a review request with only an unjoined invite-only group """ group = Group(name='test-group', invite_only=True) group.save() review_request = self.create_review_request(publish=True) review_request.target_groups.add(group) self.assertFalse(review_request.is_accessible_by(self.user)) self.assertFalse(review_request.is_accessible_by(self.anonymous))
def test_review_request_with_invite_only_group(self): """Testing no access to a review request with only an unjoined invite-only group """ group = Group(name='test-group', invite_only=True) group.save() review_request = self.create_review_request(publish=True) review_request.target_groups.add(group) self.assertFalse(review_request.is_accessible_by(self.user)) self.assertFalse(review_request.is_accessible_by(self.anonymous))
def test_review_request_with_invite_only_group_and_target_user(self): """Testing access to a review request with specific target user and invite-only group """ group = Group(name='test-group', invite_only=True) group.save() review_request = self.create_review_request(publish=True) review_request.target_groups.add(group) review_request.target_people.add(self.user) self.assertTrue(review_request.is_accessible_by(self.user)) self.assertFalse(review_request.is_accessible_by(self.anonymous))
def test_review_request_with_invite_only_group_and_target_user(self): """Testing access to a review request with specific target user and invite-only group """ group = Group(name='test-group', invite_only=True) group.save() review_request = self.create_review_request(publish=True) review_request.target_groups.add(group) review_request.target_people.add(self.user) self.assertTrue(review_request.is_accessible_by(self.user)) self.assertFalse(review_request.is_accessible_by(self.anonymous))
def test_get_reviewrequest_with_invite_only_group_and_permission_denied_error(self): """Testing the GET review-requests/<id>/ API with invite-only group and Permission Denied error""" review_request = self.create_review_request(publish=True) self.assertNotEqual(review_request.submitter, self.user) group = Group(name='test-group', invite_only=True) group.save() review_request.target_groups.add(group) review_request.save() rsp = self.apiGet( get_review_request_item_url(review_request.display_id), expected_status=403) self.assertEqual(rsp['stat'], 'fail') self.assertEqual(rsp['err']['code'], PERMISSION_DENIED.code)
def test_get_reviewrequest_with_invite_only_group_and_target_user(self): """Testing the GET review-requests/<id>/ API with invite-only group and target user""" review_request = self.create_review_request(publish=True) self.assertNotEqual(review_request.submitter, self.user) group = Group(name='test-group', invite_only=True) group.save() review_request.target_groups.add(group) review_request.target_people.add(self.user) review_request.save() rsp = self.apiGet( get_review_request_item_url(review_request.display_id), expected_mimetype=review_request_item_mimetype) self.assertEqual(rsp['stat'], 'ok') self.assertEqual(rsp['review_request']['id'], review_request.display_id) self.assertEqual(rsp['review_request']['summary'], review_request.summary)