def test_set_acl_remove(self): activity = self.activity_for_set_acl([{ 'objectType': 'gender', 'content': '', 'summary': ApiActions.JOIN }]) is_valid, code, msg = request.on_set_acl(as_parser(activity)) self.assertTrue(is_valid)
def test_set_room_acls_super_user(self): self.set_super_user() acl_type = 'gender' acl_value = 'm,f' activity = self.activity_for_set_acl([{ 'objectType': acl_type, 'content': acl_value, 'summary': ApiActions.JOIN }]) is_valid, code, msg = request.on_set_acl(as_parser(activity)) self.assertTrue(is_valid)
def test_set_acl_unknown_type(self): acl_type = 'unknown' acl_value = 'm,f' activity = self.activity_for_set_acl([{ 'objectType': acl_type, 'content': acl_value }]) is_valid, code, msg = request.on_set_acl(as_parser(activity)) self.assertFalse(is_valid) self.assertEqual(code, ErrorCodes.INVALID_ACL_TYPE)
def test_set_acl_two_acl(self): acl_tuples = [('gender', 'm,f'), ('age', '23:25')] attachments = list() for acl_type, acl_value in acl_tuples: attachments.append({ 'objectType': acl_type, 'content': acl_value, 'summary': ApiActions.JOIN }) is_valid, code, msg = request.on_set_acl( as_parser(self.activity_for_set_acl(attachments))) self.assertTrue(is_valid)
def test_set_acl_invalid_value(self): acl_type = 'gender' acl_value = 'm,999' activity = self.activity_for_set_acl([{ 'objectType': acl_type, 'content': acl_value, 'summary': ApiActions.JOIN }]) is_valid, code, msg = request.on_set_acl(as_parser(activity)) self.assertFalse(is_valid) self.assertEqual(code, ErrorCodes.INVALID_ACL_VALUE)
def test_set_room_acls_channel_owner_empty_summary(self): self.set_channel_owner() acl_type = 'gender' acl_value = 'm,f' activity = self.activity_for_set_acl([{ 'objectType': acl_type, 'content': acl_value, 'summary': '' }]) is_valid, code, msg = request.on_set_acl(as_parser(activity)) self.assertFalse(is_valid) self.assertEqual(code, ErrorCodes.INVALID_ACL_ACTION)
def test_set_acl_not_owner_returns_code_400(self): acl_type = 'gender' acl_value = 'm,f' activity = self.activity_for_set_acl([{ 'objectType': acl_type, 'content': acl_value, 'summary': ApiActions.JOIN }]) self.remove_owner() is_valid, code, msg = request.on_set_acl(as_parser(activity)) self.assertFalse(is_valid) self.assertEqual(code, ErrorCodes.NOT_ALLOWED)
def test_set_channel_acls_not_allowed(self): acl_type = 'gender' acl_value = 'm,f' activity = self.activity_for_set_acl([{ 'objectType': acl_type, 'content': acl_value, 'summary': ApiActions.JOIN }]) activity['target']['id'] = RequestSetAclTest.CHANNEL_ID activity['target']['objectType'] = 'channel' is_valid, code, msg = request.on_set_acl(as_parser(activity)) self.assertFalse(is_valid) self.assertEqual(code, ErrorCodes.NOT_ALLOWED)
def test_set_channel_acls_admin(self): self.set_channel_admin() acl_type = 'gender' acl_value = 'm,f' activity = self.activity_for_set_acl([{ 'objectType': acl_type, 'content': acl_value, 'summary': ApiActions.JOIN }]) activity['target']['id'] = RequestSetAclTest.CHANNEL_ID activity['target']['objectType'] = 'channel' is_valid, code, msg = request.on_set_acl(as_parser(activity)) self.assertTrue(is_valid)
def test_set_room_acls_channel_owner_wrong_object_type(self): self.set_channel_owner() acl_type = 'gender' acl_value = 'm,f' activity = self.activity_for_set_acl([{ 'objectType': acl_type, 'content': acl_value, 'summary': ApiActions.JOIN }]) activity['target']['objectType'] = 'something-invalid' is_valid, code, msg = request.on_set_acl(as_parser(activity)) self.assertFalse(is_valid) self.assertEqual(code, ErrorCodes.INVALID_TARGET_TYPE)