-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1602 Check report_xform permission on enketo URL …
…requests
- Loading branch information
Showing
5 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -751,6 +751,30 @@ def test_enketo_url(self): | |
data = {"enketo_url": url, "enketo_preview_url": preview_url} | ||
self.assertEqual(response.data, data) | ||
|
||
alice_data = {'username': 'alice', 'email': '[email protected]'} | ||
alice_profile = self._create_user_profile(alice_data) | ||
credentials = { | ||
'HTTP_AUTHORIZATION': ( | ||
'Token %s' % alice_profile.user.auth_token) | ||
} | ||
request = self.factory.get('/', **credentials) | ||
response = view(request, pk=formid) | ||
# Alice has no permissions to the form hence no access to web form | ||
self.assertEqual(response.status_code, 404) | ||
|
||
# Give Alice read-only permissions to the form | ||
ReadOnlyRole.add(alice_profile.user, self.xform) | ||
response = view(request, pk=formid) | ||
# Alice with read-only access should not have access to web form | ||
self.assertEqual(response.status_code, 404) | ||
|
||
# Give Alice data-entry permissions | ||
DataEntryRole.add(alice_profile.user, self.xform) | ||
response = view(request, pk=formid) | ||
# Alice with data-entry access should have access to web form | ||
self.assertEqual(response.status_code, 200) | ||
self.assertEqual(response.data, data) | ||
|
||
def test_get_single_submit_url(self): | ||
with HTTMock(enketo_preview_url_mock, enketo_url_mock, | ||
enketo_single_submission_mock): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
# | ||
# flake8 check | ||
exec git diff --staged --name-only | grep -E '\.py$' | xargs flake8 --exclude=migrations - |