package objectstorage import ( "testing" "github.com/geo-platform/tenant-api/internal/shared/config" ) func TestAliyunPutObjectOptionsAcceptsSupportedObjectACL(t *testing.T) { t.Parallel() for _, acl := range []string{"", "default", "private", "public-read", "public-read-write"} { acl := acl t.Run(acl, func(t *testing.T) { t.Parallel() options, err := aliyunPutObjectOptions(config.ObjectStorageConfig{ObjectACL: acl}, "application/zip") if err != nil { t.Fatalf("aliyunPutObjectOptions(%q) error = %v", acl, err) } if len(options) == 0 { t.Fatalf("expected at least content type option") } }) } } func TestAliyunPutObjectOptionsRejectsUnsupportedObjectACL(t *testing.T) { t.Parallel() _, err := aliyunPutObjectOptions(config.ObjectStorageConfig{ObjectACL: "authenticated-read"}, "application/zip") if err == nil { t.Fatal("expected unsupported object acl error") } } func TestIsPublicReadACL(t *testing.T) { t.Parallel() for _, tc := range []struct { acl string want bool }{ {acl: "", want: false}, {acl: "default", want: false}, {acl: "private", want: false}, {acl: "public-read", want: true}, {acl: "public-read-write", want: true}, {acl: " PUBLIC-READ ", want: true}, } { got := isPublicReadACL(tc.acl) if got != tc.want { t.Fatalf("isPublicReadACL(%q) = %v, want %v", tc.acl, got, tc.want) } } }