Commit 394f972d authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Merge branch 'fastapi' into 'v0.10.0'

Fixed foreign dataset for non owners.

See merge request !269
parents 6cd2d4f7 859715d0
Pipeline #94735 passed with stages
in 26 minutes and 34 seconds
......@@ -227,7 +227,7 @@ async def post_datasets(
ctx._source.datasets.add(params.dataset);
''',
params=dict(dataset=ElasticDocument.create_index_entry(dataset)),
owner='user', query=es_query, user_id=user.user_id)
query=es_query, user_id=user.user_id)
search.refresh()
return {
......@@ -292,7 +292,7 @@ async def delete_dataset(
}
''',
params=dict(dataset_id=dataset_id),
owner='user', query=es_query, user_id=user.user_id)
query=es_query, user_id=user.user_id)
search.refresh()
return {
......
......@@ -179,10 +179,13 @@ def test_dataset(client, data, dataset_id, result, status_code):
pytest.param('another test dataset', 'foreign', None, None, None, 401, id='no-user'),
pytest.param('test dataset 1', 'foreign', None, None, 'test_user', 400, id='exists'),
pytest.param('another test dataset', 'owned', None, None, 'test_user', 200, id='owned'),
pytest.param('another test dataset', 'foreign', {}, None, 'test_user', 200, id='query'),
pytest.param('another test dataset', 'foreign', None, ['id_01', 'id_02'], 'test_user', 200, id='entries')
pytest.param('another test dataset', 'foreign', {}, None, 'test_user', 200, id='foreign-query-owner'),
pytest.param('another test dataset', 'foreign', {}, None, 'other_test_user', 200, id='foreign-query'),
pytest.param('another test dataset', 'foreign', None, ['id_01', 'id_02'], 'test_user', 200, id='foreign-entries')
])
def test_post_datasets(client, data, example_entries, test_user, test_user_auth, name, dataset_type, query, entries, user, status_code):
def test_post_datasets(
client, data, example_entries, test_user, test_user_auth, other_test_user,
other_test_user_auth, name, dataset_type, query, entries, user, status_code):
dataset = {'name': name, 'dataset_type': dataset_type}
if query is not None:
dataset['query'] = query
......@@ -191,6 +194,10 @@ def test_post_datasets(client, data, example_entries, test_user, test_user_auth,
auth = None
if user == 'test_user':
auth = test_user_auth
user = test_user
elif user == 'other_test_user':
auth = other_test_user_auth
user = other_test_user
response = client.post(
'datasets/', headers=auth, json=dataset)
......@@ -202,7 +209,7 @@ def test_post_datasets(client, data, example_entries, test_user, test_user_auth,
dataset = json_response['data']
assert_dataset(
dataset, query=query, entries=entries,
user_id=test_user.user_id, name=name, dataset_type=dataset_type)
user_id=user.user_id, name=name, dataset_type=dataset_type)
assert Dataset.m_def.a_mongo.objects().count() == 5
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment