mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-03 07:55:36 +00:00
Illegal report by react (#3415)
* illegal report 1, add illegal report at shared file page 2, list all illegal reports at admin page * add ENABLE_SHARE_LINK_REPORT_ILLEGAL setting * UserRateThrottle -> AnonRateThrottle * use to_python_boolean * frontend by React * remove illegal report dialog in shared dir view * add migrations dir * add illegal_reports migrations * rename illegal to abuse in api * rename illegal to abuse in test * rename illegal to abuse in share file view * rename illegal to abuse in react * rename illegal to abuse in Backbone * add enableShareLinkReportAbuse in templates * add ReportAbuse * update ReportAbuse * update ReportAbuse urls * update ReportAbuse api-js * sysadmin_react_app.html * sysadmin.py * fix * fix * fix * can not abuse own file * Contact Information is required. * fix review * remove repo icon
This commit is contained in:
65
tests/api/endpoints/admin/test_abuse_reports.py
Normal file
65
tests/api/endpoints/admin/test_abuse_reports.py
Normal file
@@ -0,0 +1,65 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import json
|
||||
|
||||
from mock import patch, MagicMock
|
||||
from django.core.urlresolvers import reverse
|
||||
from seahub.test_utils import BaseTestCase
|
||||
from seahub.abuse_reports.models import AbuseReport
|
||||
|
||||
|
||||
class AdminAbuseReportsTest(BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.login_as(self.admin)
|
||||
self.url = reverse('api-v2.1-admin-abuse-reports')
|
||||
|
||||
@patch('seahub.api2.endpoints.admin.abuse_reports.ENABLE_SHARE_LINK_REPORT_ABUSE', MagicMock(return_value=True))
|
||||
def test_can_get(self):
|
||||
resp = self.client.get(self.url)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
|
||||
|
||||
class AdminAbuseReportTest(BaseTestCase):
|
||||
def setUp(self):
|
||||
self.login_as(self.admin)
|
||||
self.repo = self.repo
|
||||
self.file_path = self.file
|
||||
self.url = reverse('api-v2.1-admin-abuse-reports')
|
||||
|
||||
def _add_abuse_report(self):
|
||||
reporter = ''
|
||||
repo_id = self.repo.id
|
||||
repo_name = self.repo.name
|
||||
file_path = self.file_path
|
||||
abuse_type = 'copyright'
|
||||
description = ''
|
||||
|
||||
report = AbuseReport.objects.add_abuse_report(
|
||||
reporter, repo_id, repo_name, file_path, abuse_type, description)
|
||||
return report
|
||||
|
||||
def _remove_abuse_report(self, report_id):
|
||||
report = AbuseReport.objects.get(id=report_id)
|
||||
report.delete()
|
||||
|
||||
@patch('seahub.api2.endpoints.admin.abuse_reports.ENABLE_SHARE_LINK_REPORT_ABUSE', MagicMock(return_value=True))
|
||||
def test_can_put(self):
|
||||
report = self._add_abuse_report()
|
||||
data = 'handled=' + str(not report.handled).lower()
|
||||
resp = self.client.put(self.url + str(report.id) + '/', data, 'application/x-www-form-urlencoded')
|
||||
self.assertEqual(200, resp.status_code)
|
||||
|
||||
json_resp = json.loads(resp.content)
|
||||
assert json_resp['file_name'] is not None
|
||||
assert json_resp['time'] is not None
|
||||
|
||||
assert json_resp['handled'] == (not report.handled)
|
||||
assert json_resp['abuse_type'] == report.abuse_type
|
||||
assert json_resp['description'] == report.description
|
||||
assert json_resp['id'] == report.id
|
||||
assert json_resp['reporter'] == report.reporter
|
||||
assert json_resp['repo_id'] == report.repo_id
|
||||
assert json_resp['repo_name'] == report.repo_name
|
||||
assert json_resp['file_path'] == report.file_path
|
||||
|
||||
self._remove_abuse_report(report.id)
|
Reference in New Issue
Block a user