修复全量审查问题;设置接口PATCH化;回传指纹加固
CI / test (push) Successful in 32s

This commit is contained in:
2026-07-22 16:51:23 +08:00
parent 0614ef22af
commit f51fb6c722
66 changed files with 3997 additions and 687 deletions
+47
View File
@@ -2,7 +2,10 @@ package oci
import (
"context"
"encoding/json"
"strings"
"testing"
"time"
)
// namespace 为租户常量:缓存命中时直接返回,不构造客户端、不发起远程调用
@@ -27,3 +30,47 @@ func TestGetObjectStorageNamespaceCached(t *testing.T) {
})
}
}
func TestCreatePARDetailsBucketListingAction(t *testing.T) {
cases := []struct {
accessType string
wantList bool
}{
{"AnyObjectRead", true},
{"AnyObjectReadWrite", true},
{"AnyObjectWrite", false},
{"ObjectRead", false},
}
for _, tc := range cases {
details := createPARDetails(CreatePARInput{AccessType: tc.accessType, ExpiresHours: 1}, time.Unix(100, 0))
gotList := string(details.BucketListingAction) == "ListObjects"
if gotList != tc.wantList {
t.Errorf("%s listing = %q, wantList %v", tc.accessType, details.BucketListingAction, tc.wantList)
}
wire, err := json.Marshal(details)
if err != nil {
t.Fatalf("marshal %s details: %v", tc.accessType, err)
}
gotWireList := strings.Contains(string(wire), `"bucketListingAction":"ListObjects"`)
if gotWireList != tc.wantList {
t.Errorf("%s wire = %s, wantList %v", tc.accessType, wire, tc.wantList)
}
}
}
func TestCreatePARDetailsExpirationAndObject(t *testing.T) {
now := time.Date(2026, 7, 22, 12, 0, 0, 0, time.UTC)
details := createPARDetails(CreatePARInput{
Name: "share", ObjectName: "folder/a.txt", AccessType: "ObjectRead", ExpiresHours: 48,
}, now)
if got, want := details.TimeExpires.Time, now.Add(48*time.Hour); !got.Equal(want) {
t.Errorf("TimeExpires = %v, want %v", got, want)
}
if details.ObjectName == nil || *details.ObjectName != "folder/a.txt" {
t.Errorf("ObjectName = %v, want folder/a.txt", details.ObjectName)
}
defaults := createPARDetails(CreatePARInput{AccessType: "ObjectRead"}, now)
if got, want := defaults.TimeExpires.Time, now.Add(24*time.Hour); !got.Equal(want) {
t.Errorf("default TimeExpires = %v, want %v", got, want)
}
}