def test_post_invalid_model(self, test_client): response = test_client.post( '/executions', headers={"apiKey": standard_user().api_key}, data=POST_INVALID_MODEL) error = error_from_response(response) assert error == INVALID_MODEL_PROVIDED
def test_get_pipeline_boutiques_descriptor_by_identifier_invalid_id( self, test_client): response = test_client.get('/pipelines/{}/boutiquesdescriptor'.format( "INVALID_{}".format(PipelineOne.identifier)), headers={"apiKey": standard_user().api_key}) error = error_from_response(response) assert error == INVALID_PIPELINE_IDENTIFIER
def test_get_content_action_with_invalid_dir(self, test_client): response = test_client.get( '/path/{}/dir_that_does_not_exist?action=content'.format( standard_user().username), headers={"apiKey": standard_user().api_key}) error = error_from_response(response) assert error == PATH_DOES_NOT_EXIST
def test_post_identifier_set(self, test_client, pipeline): response = test_client.post( '/executions', headers={"apiKey": standard_user().api_key}, data=json.dumps(ExecutionSchema().dump( post_invalid_identifier_set(pipeline.identifier)).data)) error = error_from_response(response) assert error == EXECUTION_IDENTIFIER_MUST_NOT_BE_SET
def test_post_pipeline_identifier_doesnt_exist(self, test_client): response = test_client.post( '/executions', headers={"apiKey": standard_user().api_key}, data=json.dumps(ExecutionSchema().dump( POST_INVALID_EXECUTION_IDENTIFIER_NOT_EXIST).data)) error = error_from_response(response) assert error == INVALID_PIPELINE_IDENTIFIER
def test_edit_password_no_password(self, test_client): response = test_client.post( "/users/edit", headers={"apiKey": standard_user().api_key}, data=json.dumps({"password": ""})) error = error_from_response(response) INVALID_MODEL_PROVIDED.error_detail = "'password' is required" assert error == INVALID_MODEL_PROVIDED
def test_get_invalid_execution(self, test_client): execution_id = "invalid" response = test_client.get('/executions/{}'.format(execution_id), headers={"apiKey": standard_user().api_key}) error = error_from_response(response) expected_error_code_and_message = ErrorCodeAndMessageFormatter( EXECUTION_NOT_FOUND, execution_id) assert error == expected_error_code_and_message
def test_put_illegal_parameter_identifier(self, test_client, execution_id): response = test_client.put('/executions/{}'.format(execution_id), headers={"apiKey": standard_user().api_key}, data=json.dumps(PATCH_ILLEGAL_PARAMETER2)) error = error_from_response(response) expected_error_code_and_message = copy.deepcopy(error) expected_error_code_and_message.error_message = error.error_message.format( "identifier") assert error == expected_error_code_and_message
def test_edit_password_user_other_user(self, test_client): response = test_client.post( "/users/edit", headers={"apiKey": standard_user().api_key}, data=json.dumps({ "username": standard_user_2().username, "password": standard_user().password + "2" })) error = error_from_response(response) assert error == UNAUTHORIZED
def test_get_execution_std_err_invalid_execution_id( self, test_client, execution_id, write_std_err): invalid_execution_id = "NOT_{}".format(execution_id) response = test_client.get( '/executions/{}/stderr'.format(invalid_execution_id), headers={"apiKey": standard_user().api_key}) error = error_from_response(response) expected_error_code_and_message = ErrorCodeAndMessageFormatter( EXECUTION_NOT_FOUND, invalid_execution_id) assert error == expected_error_code_and_message
def test_put_with_invalid_upload_type(self, test_client): response = test_client.put( '/path/{}/new_file.txt'.format(standard_user().username), headers={ "apiKey": standard_user().api_key, "Content-Type": "application/carmin+json" }, data='{"type": "Invented", "base64Content": "ewlfkjweflk=="}') error = error_from_response(response) assert error.error_code == INVALID_MODEL_PROVIDED.error_code assert error.error_message == INVALID_MODEL_PROVIDED.error_message assert len(error.error_detail) == 1 assert "type" in error.error_detail
def test_edit_password_user_not_exist(self, test_client): response = test_client.post("/users/edit", headers={"apiKey": admin().api_key}, data=json.dumps({ "username": "******", "password": standard_user().password + "2" })) error = error_from_response(response) expected_error_code_and_message = copy.deepcopy(USER_DOES_NOT_EXIST) expected_error_code_and_message.error_message = expected_error_code_and_message.error_message.format( "does_not_exist") assert error == expected_error_code_and_message
def test_put_file_on_dir(self, test_client): path = '{}/empty_dir'.format(standard_user().username) put_dir = UploadData(base64_content='bad_content', upload_type='File', md5='') response = test_client.put( '/path/{}'.format(path), headers={ "apiKey": standard_user().api_key, "Content-Type": "application/carmin+json" }, data=json.dumps(UploadDataSchema().dump(put_dir).data)) error = error_from_response(response) assert error.error_message == "Invalid path: '{}' is a directory.".format( path)
def test_post_array_file_doesnt_exist(self, test_client, pipeline): user_execution_dir = os.path.join(app.config['DATA_DIRECTORY'], standard_user().username, 'executions') execution = post_invalid_execution_array_file_not_exist( pipeline.identifier) response = test_client.post( '/executions', headers={"apiKey": standard_user().api_key}, data=json.dumps(ExecutionSchema().dump(execution).data)) error_code_and_message = error_from_response(response) expected_error_code_and_message = copy.deepcopy(INVALID_INPUT_FILE) expected_error_code_and_message.error_message = expected_error_code_and_message.error_message.format( *execution.input_values["input_file"]) assert not os.listdir(user_execution_dir) assert error_code_and_message == expected_error_code_and_message
def test_get_execution_std_err_not_found(self, test_client, execution_id): response = test_client.get( '/executions/{}/stderr'.format(execution_id), headers={"apiKey": standard_user().api_key}) error = error_from_response(response) assert error == PATH_DOES_NOT_EXIST
def test_get_md5_action_with_dir(self, test_client): response = test_client.get('/path/{}/subdirectory?action=md5'.format( standard_user().username), headers={"apiKey": standard_user().api_key}) error = error_from_response(response) assert error == MD5_ON_DIR
def test_put_outside_authorized_directory(self, test_client): response = test_client.put('/path/../../test_file', headers={"apiKey": standard_user().api_key}) error = error_from_response(response) assert error == INVALID_PATH
def test_put_where_parent_dir_not_exist(self, test_client): response = test_client.put('/path/{}/made_up_dir/file.txt'.format( standard_user().username), headers={"apiKey": standard_user().api_key}) error = error_from_response(response) assert error == INVALID_PATH
def test_put_dir_already_exists(self, test_client): dir_to_create = "{}/subdirectory".format(standard_user().username) response = test_client.put('/path/{}'.format(dir_to_create), headers={"apiKey": standard_user().api_key}) error = error_from_response(response) assert error == PATH_EXISTS
def test_get_list_action_with_file(self, test_client): response = test_client.get('/path/{}/file.json?action=list'.format( standard_user().username), headers={"apiKey": standard_user().api_key}) error = error_from_response(response) assert error == LIST_ACTION_ON_FILE
def test_get_invalid_action(self, test_client): response = test_client.get('/path/{}/file.json?action=invalid'.format( standard_user().username), headers={"apiKey": standard_user().api_key}) error = error_from_response(response) assert error == INVALID_ACTION
def test_get_no_action(self, test_client): response = test_client.get('/path/{}/file.json'.format( standard_user().username), headers={"apiKey": standard_user().api_key}) error = error_from_response(response) assert error == ACTION_REQUIRED
def test_query_outside_authorized_directory(self, test_client): response = test_client.get('/path/../../test?action=properties', headers={"apiKey": standard_user().api_key}) error = error_from_response(response) assert error == INVALID_PATH