Skip to content

Conversation

@0lai0
Copy link
Contributor

@0lai0 0lai0 commented Dec 7, 2025

What changes were proposed in this pull request?

Adding PutObjectTagging, GetObjectTagging, DeleteObjectTagging SDK integration tests to validate.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-13081

Copy link
Contributor

@Gargi-jais11 Gargi-jais11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @0lai0 for the patch.
I have few more test case suggestions which could be added.

}

@Test
public void testGetObjectTagging() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testPutObjectTagging()and testGetObjectTagging(), are functionally very similar and could be merged into a single test named as testPutAndGetObjectTagging().

@Gargi-jais11
Copy link
Contributor

More Edge Cases which can be tested:

  1. testPutObjectTaggingExceedsLimit() — Test 11 tags and validate it throws error there is 10-tag limit.
  2. testPutObjectTaggingReplacesExistingTags() — verifies replacement behavior (Initially put 2 tags then replace it with 1 tag and check the last replcaed tag is only applied)
  3. testPutObjectTaggingInvalidConstraints - This can be a parameterised test like below:
private static Stream<Arguments> invalidTagConstraintsProvider() {
    return Stream.of(
        // Test 1: Tag key exceeds maximum length (128 bytes)
        Arguments.of(
            "Tag key exceeding 128 bytes should be rejected",
            Arrays.asList(Tag.builder().key("a".repeat(129)).value("value").build()),
            400,
            "exceeds the maximum length"
        ),
        
        // Test 2: Tag value exceeds maximum length (256 bytes)
        Arguments.of(
            "Tag value exceeding 256 bytes should be rejected",
            Arrays.asList(Tag.builder().key("valid-key").value("b".repeat(257)).build()),
            400,
            "exceeds the maximum length"
        ),
        // Test 3: Tag key with invalid characters (@, #, $, (, {, ....)
        Arguments.of(
            "Tag key with invalid characters should be rejected",
            Arrays.asList(Tag.builder().key("t$ag@#invalid").value("value").build()),
            400,
            "does not have a valid pattern"
        ), 
        // Test 4: Tag key starting with "aws:" prefix
        Arguments.of(
            "Tag key starting with 'aws:' prefix should be rejected",
            Arrays.asList(Tag.builder().key("aws:test").value("value").build()),
            400,
            "cannot start with \"aws:\"" 
        )
    );
    }
@ParameterizedTest
@MethodSource("invalidTagConstraintsProvider")
public void testPutObjectTaggingInvalidConstraints(
    String testCaseName,
    List<Tag> invalidTags,
    int expectedStatusCode,
    String expectedErrorMessage) {
    // your code
}
  1. testPutAndGetObjectTaggingOnNonExistentObject() - Verify NoSuchKeyException occurs and 404 status code.
  2. testDeleteObjectTaggingOnNonExistentObject() - Verify NoSuchKeyException occurs and 404 status code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants