def test_filter_fields_for_file(module_file):
    file, *_ = module_file

    response = helper.get_resources_response(params=dict(path=file, fields='size'))

    check.response_has_status_code(response, 200)
    check.response_has_only_fields(response, 'size')
def test_filter_fields_for_folder(module_folder):
    folder, *_ = module_folder

    response = helper.get_resources_response(params=dict(path=folder, fields='_embedded'))

    check.response_has_status_code(response, 200)
    check.response_has_only_fields(response, '_embedded')
Exemplo n.º 3
0
def test_publish_and_filter_fields(module_folder):
    folder_path, folder_name, *_ = module_folder

    response = helper.put_publish_resource_response(params=dict(path=folder_path, fields='href,method'))

    check.response_has_status_code(response, 200)
    check.response_has_only_fields(response, 'href', 'method')
def test_upload_file_with_empty_params():
    response = helper.post_upload_resource_response()

    check.response_has_status_code(response, 400)
    check.response_has_only_fields(response, 'message', 'description', 'error')
    check.response_has_field_with_value(response,
                                        field='error',
                                        value='FieldValidationError')
def test_upload_file_and_get_existent_fields(base_folder, fields):
    link = config.data.TEST_DATA_URL['test_txt.txt']
    file_path = f'{base_folder}/fields_test{fields}.txt'
    response = helper.post_upload_resource_response(
        params=dict(path=file_path, url=link, fields=','.join(fields)))

    check.response_has_status_code(response, 202)
    check.response_has_only_fields(response, *fields)
def test_bad_request(module_folder, limit, offset):
    folder, *_ = module_folder

    response = helper.get_resources_response(params=dict(path=folder, limit=limit, offset=offset))

    check.response_has_status_code(response, 400)
    check.response_has_only_fields(response, 'message', 'description', 'error')
    check.response_has_field_with_value(response, field='error', value='FieldValidationError')
def test_expired_user(module_folder):
    folder, *_ = module_folder

    response = helper.get_resources_response(params=dict(path=folder), by_user='******')

    check.response_has_status_code(response, 401)
    check.response_has_only_fields(response, 'message', 'description', 'error')
    check.response_has_field_with_value(response, field='error', value='UnauthorizedError')
Exemplo n.º 8
0
def test_publish_file_by_unauthorized_user(module_file):
    file_path, file_name, *_ = module_file

    response = helper.put_publish_resource_response(params=dict(path=file_path), by_user='******')

    check.response_has_status_code(response, 401)
    check.response_has_only_fields(response, 'message', 'description', 'error')
    check.response_has_field_with_value(response, field='error', value='UnauthorizedError')
def test_delete_nonexistent_resource():
    response = helper.delete_resources_response(params=dict(
        path='nonexistent.txt'))

    check.response_has_status_code(response, 404)
    check.response_has_only_fields(response, 'message', 'description', 'error')
    check.response_has_field_with_value(response,
                                        field='error',
                                        value='DiskNotFoundError')
def test_upload_file_to_nonexistent_folder():
    link = config.data.TEST_DATA_URL['test_txt.txt']
    file_path = f'nonexistent_folder/existed_file.txt'
    response = helper.post_upload_resource_response(
        params=dict(path=file_path, url=link))

    check.response_has_status_code(response, 409)
    check.response_has_only_fields(response, 'message', 'description', 'error')
    check.response_has_field_with_value(response,
                                        field='error',
                                        value='DiskPathDoesntExistsError')
def test_upload_file_with_invalid_params(path, url, base_folder):
    link = None if url is None else config.data.TEST_DATA_URL['test_txt.txt']
    file_path = None if path is None else f'{base_folder}/{url}{path}.txt'
    response = helper.post_upload_resource_response(
        params=dict(path=file_path, url=link))

    check.response_has_status_code(response, 400)
    check.response_has_only_fields(response, 'message', 'description', 'error')
    check.response_has_field_with_value(response,
                                        field='error',
                                        value='FieldValidationError')
def test_delete_file_by_expired_user(temp_file):
    path, *_ = temp_file()

    response = helper.delete_resources_response(params=dict(path=path),
                                                by_user='******')

    check.response_has_status_code(response, 401)
    check.response_has_only_fields(response, 'message', 'description', 'error')
    check.response_has_field_with_value(response,
                                        field='error',
                                        value='UnauthorizedError')
def test_upload_file_by_unauthorized_user(base_folder):
    link = config.data.TEST_DATA_URL['test_txt.txt']
    file_path = f'{base_folder}/unauthorized.txt'
    response = helper.post_upload_resource_response(params=dict(path=file_path,
                                                                url=link),
                                                    by_user='******')

    check.response_has_status_code(response, 401)
    check.response_has_only_fields(response, 'message', 'description', 'error')
    check.response_has_field_with_value(response,
                                        field='error',
                                        value='UnauthorizedError')
def test_meta_for_folder(module_folder):
    path, folder_name = module_folder

    response = helper.get_resources_response(params=dict(path=path))

    check.response_has_status_code(response, 200)
    check.response_has_only_fields(
        response,
        '_embedded', 'name', 'exif', 'created', 'resource_id', 'modified', 'path', 'comment_ids', 'type', 'revision'
    )
    check.response_has_field_with_value(response, "type", 'dir')
    check.response_has_field_with_value(response, "name", folder_name)
Exemplo n.º 15
0
def test_publish_file(module_file):
    file_path, file_name, *_ = module_file

    response = helper.put_publish_resource_response(params=dict(path=file_path))

    check.response_has_status_code(response, 200)
    check.response_has_only_fields(response, 'href', 'method', 'templated')
    check.response_has_field_contains_value(response, 'href', file_name)

    with allure.step("There is should be only one copy of published file"):
        items = helper.get_public_resources().get('items')
        items_by_name = [item for item in items if item.get('name') == file_name]
        assert len(items_by_name) == 1, "There is should be only one copy of published file"

    with allure.step("Published file should be available even for unauthorized user"):
        response = http_session.send_custom_request(method='get', by_user='******', url=items_by_name[0]['file'])
        check.response_has_status_code(response, 200)
def test_not_found(base_folder):
    response = helper.get_resources_response(params=dict(path=f'{base_folder}/nonexistent.txt'))

    check.response_has_status_code(response, 404)
    check.response_has_only_fields(response, 'message', 'description', 'error')
    check.response_has_field_with_value(response, field='error', value='DiskNotFoundError')