Skip to content

Commit

Permalink
Applied requested changes of PR kobotoolbox#2015
Browse files Browse the repository at this point in the history
  • Loading branch information
noliveleger committed Oct 3, 2018
1 parent d08d2ac commit f9ae5a9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docker/run_celery_sync_kobocat_xforms.bash
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ exec celery worker -A kobo --loglevel=info \
--pidfile=/tmp/celery_sync_kobocat_xforms.pid \
--queues=sync_kobocat_xforms_queue \
--concurrency=1 \
--max-memory-per-child=1
--max-tasks-per-child=1
6 changes: 3 additions & 3 deletions kobo/apps/hook/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ def failures_reports():
# Prepare data for templates.
# All logs will be grouped under their respective asset and user.
for record in queryset:
# if user doesn't exist in dict, add him
# if users don't exist in dict, add them
if record.hook.asset.owner.id not in records:
records[record.hook.asset.owner.id] = {
"username": record.hook.asset.owner.username,
# language is in implemented yet.
# language is not implemented yet.
# TODO add language to user table in registration process
"language": getattr(record.hook.asset.owner, "language", "en"),
"email": record.hook.asset.owner.email,
Expand All @@ -121,7 +121,7 @@ def failures_reports():
hook_name_length = len(record.hook.name)

# Max Length is used for plain text template. To display fixed size columns.
max_length = max_length if max_length > hook_name_length else hook_name_length
max_length = max(max_length, hook_name_length)
records[record.hook.asset.owner.id]["assets"][record.hook.asset.id]["max_length"] = max_length

# Get templates
Expand Down
4 changes: 2 additions & 2 deletions kobo/apps/hook/tests/hook_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ def _send_and_fail(self):
service_definition = ServiceDefinition(self.hook, instance_id)
first_mock_response = {"error": "not found"}

# Mock first requests try
# Mock first request's try
responses.add(responses.POST, self.hook.endpoint,
json=first_mock_response, status=status.HTTP_404_NOT_FOUND)

# Mock next requests tries
# Mock next requests' tries
responses.add(responses.POST, self.hook.endpoint,
status=status.HTTP_200_OK,
content_type="application/json")
Expand Down
6 changes: 3 additions & 3 deletions kobo/apps/hook/tests/test_api_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_data_submission(self):
response = self.client.post(submission_url, data)
self.assertEqual(response.status_code, status.HTTP_409_CONFLICT)

def test_not_owner_access(self):
def test_non_owner_cannot_access(self):
hook = self._create_hook()
self.client.logout()
self.client.login(username="anotheruser", password="anotheruser")
Expand Down Expand Up @@ -102,13 +102,13 @@ def test_not_owner_access(self):
response = self.client.get(log_list_url)
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)

def test_not_owner_create(self):
def test_non_owner_cannot_create(self):
self.client.logout()
self.client.login(username="anotheruser", password="anotheruser")
response = self._create_hook(return_response_only=True, name="Hook for asset I don't own")
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)

def test_not_owner_anonymous(self):
def test_anonymous_cannot_create(self):
self.client.logout()
response = self._create_hook(return_response_only=True, name="Hook for asset from anonymous")
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
Expand Down
2 changes: 1 addition & 1 deletion kpi/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class PostMappedToChangePermission(IsOwnerOrReadOnly):
class AssetOwnerNestedObjectsPermissions(permissions.BasePermission):
"""
Permissions for objects that are nested under Asset which only owner should access.
Others should receive a 404 response (instead of 403) to avoid to reveal existence
Others should receive a 404 response (instead of 403) to avoid revealing existence
of objects.
"""
def has_permission(self, request, view):
Expand Down

0 comments on commit f9ae5a9

Please sign in to comment.