aboutsummaryrefslogtreecommitdiff
path: root/test/s3
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2025-07-28 02:49:43 -0700
committerchrislu <chris.lu@gmail.com>2025-07-28 02:49:43 -0700
commit124c4281a8695c4c4d163923028838195eea4e45 (patch)
tree5693dcd053e64190e7ed3517da35c58160c567a0 /test/s3
parenta4df110e778dccd3b539f06e9a696ba286948654 (diff)
downloadseaweedfs-124c4281a8695c4c4d163923028838195eea4e45.tar.xz
seaweedfs-124c4281a8695c4c4d163923028838195eea4e45.zip
tag parsing decode url encoded
fix https://github.com/seaweedfs/seaweedfs/issues/7040
Diffstat (limited to 'test/s3')
-rw-r--r--test/s3/basic/object_tagging_test.go69
1 files changed, 68 insertions, 1 deletions
diff --git a/test/s3/basic/object_tagging_test.go b/test/s3/basic/object_tagging_test.go
index 2b9b7e5aa..ae7899534 100644
--- a/test/s3/basic/object_tagging_test.go
+++ b/test/s3/basic/object_tagging_test.go
@@ -2,9 +2,10 @@ package basic
import (
"fmt"
+ "testing"
+
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/s3"
- "testing"
)
func TestObjectTagging(t *testing.T) {
@@ -80,3 +81,69 @@ func clearTags() {
fmt.Println(response.String())
}
+
+func TestObjectTaggingWithEncodedValues(t *testing.T) {
+ // Test for URL encoded tag values
+ input := &s3.PutObjectInput{
+ Bucket: aws.String("theBucket"),
+ Key: aws.String("testDir/testObjectWithEncodedTags"),
+ }
+
+ svc.PutObject(input)
+
+ // Set tags with encoded values (simulating what would happen with timestamps containing spaces and colons)
+ _, err := svc.PutObjectTagging(&s3.PutObjectTaggingInput{
+ Bucket: aws.String("theBucket"),
+ Key: aws.String("testDir/testObjectWithEncodedTags"),
+ Tagging: &s3.Tagging{
+ TagSet: []*s3.Tag{
+ {
+ Key: aws.String("Timestamp"),
+ Value: aws.String("2025-07-16 14:40:39"), // This would be URL encoded as "2025-07-16%2014%3A40%3A39" in the header
+ },
+ {
+ Key: aws.String("Path"),
+ Value: aws.String("/tmp/file.txt"), // This would be URL encoded as "/tmp%2Ffile.txt" in the header
+ },
+ },
+ },
+ })
+
+ if err != nil {
+ t.Fatalf("Failed to set tags with encoded values: %v", err)
+ }
+
+ // Get tags back and verify they are properly decoded
+ response, err := svc.GetObjectTagging(&s3.GetObjectTaggingInput{
+ Bucket: aws.String("theBucket"),
+ Key: aws.String("testDir/testObjectWithEncodedTags"),
+ })
+
+ if err != nil {
+ t.Fatalf("Failed to get tags: %v", err)
+ }
+
+ // Verify that the tags are properly decoded
+ tagMap := make(map[string]string)
+ for _, tag := range response.TagSet {
+ tagMap[*tag.Key] = *tag.Value
+ }
+
+ expectedTimestamp := "2025-07-16 14:40:39"
+ if tagMap["Timestamp"] != expectedTimestamp {
+ t.Errorf("Expected Timestamp tag to be '%s', got '%s'", expectedTimestamp, tagMap["Timestamp"])
+ }
+
+ expectedPath := "/tmp/file.txt"
+ if tagMap["Path"] != expectedPath {
+ t.Errorf("Expected Path tag to be '%s', got '%s'", expectedPath, tagMap["Path"])
+ }
+
+ fmt.Printf("✓ URL encoded tags test passed - Timestamp: %s, Path: %s\n", tagMap["Timestamp"], tagMap["Path"])
+
+ // Clean up
+ svc.DeleteObjectTagging(&s3.DeleteObjectTaggingInput{
+ Bucket: aws.String("theBucket"),
+ Key: aws.String("testDir/testObjectWithEncodedTags"),
+ })
+}