-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support if-none-match for upload #462
Merged
+105
−0
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
57c1492
if none match
TingDaoK 9dc17d0
don't include it for the list part
TingDaoK fcc2617
share the code
TingDaoK 62a13ae
tirivial
TingDaoK 065662c
add the cancel older runs when change pushed
TingDaoK 3eb9d23
test-cancel
TingDaoK cf1d945
address comments
TingDaoK fe4eab9
tolerate 200 error
TingDaoK File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -3010,6 +3010,88 @@ static int s_test_s3_put_object_async_fail_reading(struct aws_allocator *allocat | |||||||||
return 0; | ||||||||||
} | ||||||||||
|
||||||||||
static int s_test_validate_if_none_match_failure_response(struct aws_s3_meta_request_test_results *test_results) { | ||||||||||
|
||||||||||
ASSERT_UINT_EQUALS(AWS_HTTP_STATUS_CODE_412_PRECONDITION_FAILED, test_results->finished_response_status); | ||||||||||
|
||||||||||
/** | ||||||||||
* response body should be like: | ||||||||||
* <Error> | ||||||||||
* <Code>PreconditionFailed</Code> | ||||||||||
* <Message>At least one of the pre-conditions you specified did not hold</Message> | ||||||||||
* <Condition>If-None-Match</Condition> | ||||||||||
* <RequestId></RequestId> | ||||||||||
* <HostId></HostId> | ||||||||||
* </Error> | ||||||||||
*/ | ||||||||||
|
||||||||||
struct aws_byte_cursor xml_doc = aws_byte_cursor_from_buf(&test_results->error_response_body); | ||||||||||
struct aws_byte_cursor error_code_string = {0}; | ||||||||||
struct aws_byte_cursor condition_string = {0}; | ||||||||||
|
||||||||||
const char *error_code_path[] = {"Error", "Code", NULL}; | ||||||||||
ASSERT_SUCCESS(aws_xml_get_body_at_path(test_results->allocator, xml_doc, error_code_path, &error_code_string)); | ||||||||||
ASSERT_TRUE(aws_byte_cursor_eq_c_str(&error_code_string, "PreconditionFailed")); | ||||||||||
|
||||||||||
const char *condition_path[] = {"Error", "Condition", NULL}; | ||||||||||
ASSERT_SUCCESS(aws_xml_get_body_at_path(test_results->allocator, xml_doc, condition_path, &condition_string)); | ||||||||||
ASSERT_TRUE(aws_byte_cursor_eq_c_str(&condition_string, "If-None-Match")); | ||||||||||
|
||||||||||
return AWS_OP_SUCCESS; | ||||||||||
} | ||||||||||
|
||||||||||
AWS_TEST_CASE(test_s3_put_object_if_none_match, s_test_s3_put_object_if_none_match) | ||||||||||
static int s_test_s3_put_object_if_none_match(struct aws_allocator *allocator, void *ctx) { | ||||||||||
(void)ctx; | ||||||||||
|
||||||||||
struct aws_s3_meta_request_test_results test_results; | ||||||||||
aws_s3_meta_request_test_results_init(&test_results, allocator); | ||||||||||
struct aws_byte_cursor if_none_match_all = aws_byte_cursor_from_c_str("*"); | ||||||||||
struct aws_s3_tester_meta_request_options put_options = { | ||||||||||
.allocator = allocator, | ||||||||||
.meta_request_type = AWS_S3_META_REQUEST_TYPE_PUT_OBJECT, | ||||||||||
.validate_type = AWS_S3_TESTER_VALIDATE_TYPE_EXPECT_FAILURE, | ||||||||||
.put_options = | ||||||||||
{ | ||||||||||
/* Use pre_exist object so that the request should fail with the expected failure message. */ | ||||||||||
.object_path_override = g_pre_existing_object_10MB, | ||||||||||
.object_size_mb = 5, | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. trivial: it's weird to use the
Suggested change
|
||||||||||
.if_none_match_header = if_none_match_all, | ||||||||||
}, | ||||||||||
}; | ||||||||||
ASSERT_SUCCESS(aws_s3_tester_send_meta_request_with_options(NULL, &put_options, &test_results)); | ||||||||||
ASSERT_SUCCESS(s_test_validate_if_none_match_failure_response(&test_results)); | ||||||||||
|
||||||||||
aws_s3_meta_request_test_results_clean_up(&test_results); | ||||||||||
return 0; | ||||||||||
} | ||||||||||
|
||||||||||
AWS_TEST_CASE(test_s3_put_object_mpu_if_none_match, s_test_s3_put_object_mpu_if_none_match) | ||||||||||
static int s_test_s3_put_object_mpu_if_none_match(struct aws_allocator *allocator, void *ctx) { | ||||||||||
(void)ctx; | ||||||||||
|
||||||||||
struct aws_s3_meta_request_test_results test_results; | ||||||||||
aws_s3_meta_request_test_results_init(&test_results, allocator); | ||||||||||
struct aws_byte_cursor if_none_match_all = aws_byte_cursor_from_c_str("*"); | ||||||||||
struct aws_s3_tester_meta_request_options put_options = { | ||||||||||
.allocator = allocator, | ||||||||||
.meta_request_type = AWS_S3_META_REQUEST_TYPE_PUT_OBJECT, | ||||||||||
.validate_type = AWS_S3_TESTER_VALIDATE_TYPE_EXPECT_FAILURE, | ||||||||||
.put_options = | ||||||||||
{ | ||||||||||
/* Use pre_exist object so that the request should fail with the expected failure message. */ | ||||||||||
.object_path_override = g_pre_existing_object_10MB, | ||||||||||
.object_size_mb = 20, | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. trivial: same
Suggested change
|
||||||||||
.if_none_match_header = if_none_match_all, | ||||||||||
}, | ||||||||||
}; | ||||||||||
ASSERT_SUCCESS(aws_s3_tester_send_meta_request_with_options(NULL, &put_options, &test_results)); | ||||||||||
ASSERT_SUCCESS(s_test_validate_if_none_match_failure_response(&test_results)); | ||||||||||
|
||||||||||
aws_s3_meta_request_test_results_clean_up(&test_results); | ||||||||||
return 0; | ||||||||||
} | ||||||||||
|
||||||||||
AWS_TEST_CASE(test_s3_put_object_sse_kms, s_test_s3_put_object_sse_kms) | ||||||||||
static int s_test_s3_put_object_sse_kms(struct aws_allocator *allocator, void *ctx) { | ||||||||||
(void)ctx; | ||||||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trivial: this is slightly different than what we have in aws-crt-java and aws-crt-cpp, which do this:
which I got from these docs:
https://docs.github.com/en/enterprise-cloud@latest/actions/writing-workflows/choosing-what-your-workflow-does/control-the-concurrency-of-workflows-and-jobs