diff options
| author | chrislu <chris.lu@gmail.com> | 2025-12-09 00:24:54 -0800 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2025-12-09 00:24:54 -0800 |
| commit | d93c90fdb3d6123ad9398bb595fb4bf16d5918a7 (patch) | |
| tree | 03b9f1946a1ed9236607863bf0be6494fbf364e1 /weed/s3api/policy_engine/engine_test.go | |
| parent | b198a0e8d1b874cb5ead7a7b6ef1af3c304341b6 (diff) | |
| download | seaweedfs-d93c90fdb3d6123ad9398bb595fb4bf16d5918a7.tar.xz seaweedfs-d93c90fdb3d6123ad9398bb595fb4bf16d5918a7.zip | |
Address code review nitpicks
- Remove unused extractObjectTags placeholder function (engine.go)
- Add clarifying comment about s3:ExistingObjectTag/<key> evaluation
- Consolidate duplicate tag-based examples in README
- Factor out tagsToEntry helper to package level in tests
Diffstat (limited to 'weed/s3api/policy_engine/engine_test.go')
| -rw-r--r-- | weed/s3api/policy_engine/engine_test.go | 46 |
1 files changed, 13 insertions, 33 deletions
diff --git a/weed/s3api/policy_engine/engine_test.go b/weed/s3api/policy_engine/engine_test.go index 7ad2ca35b..4de537ac1 100644 --- a/weed/s3api/policy_engine/engine_test.go +++ b/weed/s3api/policy_engine/engine_test.go @@ -9,6 +9,19 @@ import ( "github.com/seaweedfs/seaweedfs/weed/s3api/s3err" ) +// tagsToEntry converts a map of tag key-value pairs to the entry.Extended format +// used for s3:ExistingObjectTag/<key> condition evaluation +func tagsToEntry(tags map[string]string) map[string][]byte { + if tags == nil { + return nil + } + entry := make(map[string][]byte) + for k, v := range tags { + entry[s3_constants.AmzObjectTaggingPrefix+k] = []byte(v) + } + return entry +} + func TestPolicyEngine(t *testing.T) { engine := NewPolicyEngine() @@ -743,18 +756,6 @@ func TestExistingObjectTagCondition(t *testing.T) { t.Fatalf("Failed to set bucket policy: %v", err) } - // Helper to convert tags to entry.Extended format - tagsToEntry := func(tags map[string]string) map[string][]byte { - if tags == nil { - return nil - } - entry := make(map[string][]byte) - for k, v := range tags { - entry[s3_constants.AmzObjectTaggingPrefix+k] = []byte(v) - } - return entry - } - tests := []struct { name string objectTags map[string]string @@ -837,15 +838,6 @@ func TestExistingObjectTagConditionMultipleTags(t *testing.T) { t.Fatalf("Failed to set bucket policy: %v", err) } - // Helper to convert tags to entry.Extended format - tagsToEntry := func(tags map[string]string) map[string][]byte { - entry := make(map[string][]byte) - for k, v := range tags { - entry[s3_constants.AmzObjectTaggingPrefix+k] = []byte(v) - } - return entry - } - tests := []struct { name string objectTags map[string]string @@ -928,18 +920,6 @@ func TestExistingObjectTagDenyPolicy(t *testing.T) { t.Fatalf("Failed to set bucket policy: %v", err) } - // Helper to convert tags to entry.Extended format - tagsToEntry := func(tags map[string]string) map[string][]byte { - if tags == nil { - return nil - } - entry := make(map[string][]byte) - for k, v := range tags { - entry[s3_constants.AmzObjectTaggingPrefix+k] = []byte(v) - } - return entry - } - tests := []struct { name string objectTags map[string]string |
