Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions relation_engine_server/test/test_api_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class TestApi(unittest.TestCase):
@classmethod
def setUpClass(cls):
wait_for_api()
cls.maxDiff = None

def test_request(self, url=None, params=None, data=None, headers=None, method='get',
status_code=200, resp_json=None, resp_test=None):
Expand Down Expand Up @@ -566,7 +567,6 @@ def test_admin_query(self):
def test_admin_query_non_admin(self):
"""Test an ad-hoc query error as a non-admin."""
query = 'for v in test_vertex sort rand() limit @count return v._id'
auth_response = '{"class":"Exception","error":"Unable to match endpoint: POST /"}\n'
self.test_request(
'/query_results',
method='post',
Expand All @@ -576,15 +576,15 @@ def test_admin_query_non_admin(self):
status_code=403,
resp_json={'error': {
'message': 'Unauthorized',
'auth_url': 'http://workspace:5000',
'auth_response': auth_response
'auth_url': 'http://auth:5000',
'auth_response': 'Missing role'
}},
)

def test_admin_query_invalid_auth(self):
"""Test the error response for an ad-hoc admin query without auth."""

# see ./mock_workspace/list_workspace_ids_invalid.json for response
# see ./mock_auth/auth_invalid.json for response
query = 'for v in test_vertex sort rand() limit @count return v._id'
self.test_request(
'/query_results',
Expand All @@ -596,14 +596,16 @@ def test_admin_query_invalid_auth(self):
resp_json={
'error': {
'message': 'Unauthorized',
'auth_url': 'http://workspace:5000',
'auth_url': 'http://auth:5000',
'auth_response': json.dumps({
"version": "1.1",
"error": {
"name": "JSONRPCError",
"code": -32400,
"message": "Token validation failed!",
"error": "..."
"httpcode": 401,
"httpstatus": "Unauthorized",
"appcode": 10020,
"apperror": "Invalid token",
"message": "10020 Invalid token",
"callid": "1757210147564211",
"time": 1542737889450
}
})
}
Expand Down