Skip to content

Commit

Permalink
test that operation_name from DEFAULT meta-request carries through.
Browse files Browse the repository at this point in the history
also, whoopsie fix memory leak
  • Loading branch information
graebm committed Nov 22, 2023
1 parent aab5101 commit c44f70e
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions source/s3_default_meta_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ static void s_s3_meta_request_default_destroy(struct aws_s3_meta_request *meta_r
AWS_PRECONDITION(meta_request->impl);

struct aws_s3_meta_request_default *meta_request_default = meta_request->impl;
aws_string_destroy(meta_request_default->operation_name);
aws_mem_release(meta_request->allocator, meta_request_default);
}

Expand Down
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ add_net_test_case(test_s3_get_object_invoke_headers_callback_on_error)
add_net_test_case(test_s3_put_object_invoke_headers_callback_on_error)
add_net_test_case(test_s3_put_object_invoke_headers_callback_on_error_with_user_cancellation)
add_net_test_case(test_s3_default_fail_body_callback)
add_net_test_case(test_s3_default_fail_operation_name)
add_net_test_case(test_s3_error_missing_file)
add_net_test_case(test_s3_existing_host_entry)
add_net_test_case(test_s3_put_fail_object_invalid_request)
Expand Down
36 changes: 36 additions & 0 deletions tests/s3_data_plane_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -4582,6 +4582,42 @@ static int s_test_s3_default_fail_body_callback(struct aws_allocator *allocator,
return 0;
}

/* Test that if a DEFAULt meta-request sets the operation_name, and gets an error response,
* then aws_s3_meta_request_result.error_response_operation_name is set. */
AWS_TEST_CASE(test_s3_default_fail_operation_name, s_test_s3_default_fail_operation_name)
static int s_test_s3_default_fail_operation_name(struct aws_allocator *allocator, void *ctx) {
(void)ctx;

struct aws_s3_meta_request_test_results meta_request_test_results;
aws_s3_meta_request_test_results_init(&meta_request_test_results, allocator);

struct aws_byte_cursor invalid_path = AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("___INVALID_PATH___");

struct aws_s3_tester_meta_request_options options = {
.allocator = allocator,
.meta_request_type = AWS_S3_META_REQUEST_TYPE_DEFAULT,

.validate_type = AWS_S3_TESTER_VALIDATE_TYPE_EXPECT_FAILURE,
.default_type_options =
{
.mode = AWS_S3_TESTER_DEFAULT_TYPE_MODE_GET,
.operation_name = aws_byte_cursor_from_c_str("GetObject"),
},
.get_options =
{
.object_path = invalid_path,
},
};

ASSERT_SUCCESS(aws_s3_tester_send_meta_request_with_options(NULL, &options, &meta_request_test_results));
ASSERT_TRUE(meta_request_test_results.finished_error_code == AWS_ERROR_S3_INVALID_RESPONSE_STATUS);
ASSERT_STR_EQUALS("GetObject", aws_string_c_str(meta_request_test_results.error_response_operation_name));

aws_s3_meta_request_test_results_clean_up(&meta_request_test_results);

return 0;
}

AWS_TEST_CASE(test_s3_put_fail_object_invalid_request, s_test_s3_put_fail_object_invalid_request)
static int s_test_s3_put_fail_object_invalid_request(struct aws_allocator *allocator, void *ctx) {
(void)ctx;
Expand Down
1 change: 1 addition & 0 deletions tests/s3_tester.c
Original file line number Diff line number Diff line change
Expand Up @@ -1402,6 +1402,7 @@ int aws_s3_tester_send_meta_request_with_options(

struct aws_s3_meta_request_options meta_request_options = {
.type = options->meta_request_type,
.operation_name = options->default_type_options.operation_name,
.message = options->message,
.checksum_config = &checksum_config,
.resume_token = options->put_options.resume_token,
Expand Down
1 change: 1 addition & 0 deletions tests/s3_tester.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ struct aws_s3_tester_meta_request_options {
/* Default Meta Request specific options. */
struct {
enum aws_s3_tester_default_type_mode mode;
struct aws_byte_cursor operation_name;
} default_type_options;

/* Get Object Meta Request specific options.*/
Expand Down

0 comments on commit c44f70e

Please sign in to comment.