mirror of https://github.com/zulip/zulip.git
api docs: Test sample fixture for user not authorized error.
This commit adds tests for the fixture for when a user is not authorized (perhaps because the query requires the use of admin privileges) for a particular query.
This commit is contained in:
parent
124c672a7c
commit
06bf47d2f5
|
@ -12,3 +12,10 @@ A typical failed JSON response for when a required request argument
|
|||
is not supplied:
|
||||
|
||||
{generate_code_example|missing-request-argument-error|fixture}
|
||||
|
||||
## User not authorized for query
|
||||
|
||||
A typical failed JSON response for when the user is not authorized
|
||||
for a query:
|
||||
|
||||
{generate_code_example|user-not-authorized-error|fixture}
|
||||
|
|
|
@ -259,5 +259,10 @@
|
|||
"code":"BAD_REQUEST",
|
||||
"msg":"You don't have permission to edit this message",
|
||||
"result":"error"
|
||||
},
|
||||
"user-not-authorized-error": {
|
||||
"code":"BAD_REQUEST",
|
||||
"msg":"User not authorized for this query",
|
||||
"result":"error"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,10 +82,4 @@ A typical successful JSON response may look like:
|
|||
An example of a JSON response for when the user is not authorized
|
||||
to use the `include_all_active` parameter:
|
||||
|
||||
```
|
||||
{
|
||||
'code':'BAD_REQUEST',
|
||||
'result':'error',
|
||||
'msg':'User not authorized for this query'
|
||||
}
|
||||
```
|
||||
{generate_code_example|user-not-authorized-error|fixture}
|
||||
|
|
|
@ -14,8 +14,9 @@ os.chdir(ZULIP_PATH)
|
|||
from zulip import Client
|
||||
|
||||
from tools.lib.test_server import test_server_running
|
||||
from zerver.lib.api_test_helpers import test_the_api, test_invalid_api_key
|
||||
from zerver.lib.api_test_helpers import test_update_message_edit_permission_error
|
||||
from zerver.lib.api_test_helpers import test_the_api, test_invalid_api_key, \
|
||||
test_update_message_edit_permission_error, \
|
||||
test_user_not_authorized_error
|
||||
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'zproject.test_settings'
|
||||
django.setup()
|
||||
|
@ -48,6 +49,7 @@ with test_server_running(external_host='zulipdev.com:9981'):
|
|||
|
||||
# Run tests that require non-admin client
|
||||
test_update_message_edit_permission_error(client, nonadmin_client)
|
||||
test_user_not_authorized_error(nonadmin_client)
|
||||
|
||||
# Test error payloads
|
||||
client = Client(
|
||||
|
|
|
@ -152,6 +152,13 @@ def get_streams(client):
|
|||
check_if_exists=['streams'])
|
||||
assert len(result['streams']) == 4
|
||||
|
||||
def test_user_not_authorized_error(nonadmin_client):
|
||||
# type: (Client) -> None
|
||||
result = nonadmin_client.get_streams(include_all_active=True)
|
||||
|
||||
fixture = FIXTURES['user-not-authorized-error']
|
||||
test_against_fixture(result, fixture)
|
||||
|
||||
def get_subscribers(client):
|
||||
# type: (Client) -> None
|
||||
|
||||
|
|
Loading…
Reference in New Issue