feat: complete API-driven projects with infrastructure and business acceptance

This commit is contained in:
2026-09-23 17:33:50 +08:00
parent 04a1f7999d
commit 2c74dc0859
137 changed files with 11926 additions and 105 deletions

View File

@@ -0,0 +1,29 @@
package oss
import (
"context"
"net/http/httptest"
"testing"
"time"
"git.yuntuo.hk/k2safe/go-omni/internal/storagefixture"
"git.yuntuo.hk/k2safe/go-omni/storage/storagetest"
sdk "github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
)
func TestUploadProtocol(t *testing.T) {
server := httptest.NewTLSServer(storagefixture.MultipartHandler())
defer server.Close()
cfg := sdk.LoadDefaultConfig().WithRegion("cn-hangzhou").WithEndpoint(server.URL).WithUsePathStyle(true).WithCredentialsProvider(credentials.NewStaticCredentialsProvider("fixtureAccess", "fixtureSecret")).WithHttpClient(server.Client()).WithSignatureVersion(sdk.SignatureVersionV4)
missing, _ := New(sdk.NewClient(cfg), "testbucket", 6<<20)
if _, err := missing.PresignPut(context.Background(), "file", 5, "text/plain", time.Minute); err == nil {
t.Fatal("unsigned length accepted")
}
cfg.WithAdditionalHeaders([]string{"content-length"})
s, err := New(sdk.NewClient(cfg), "testbucket", 6<<20)
if err != nil {
t.Fatal(err)
}
storagetest.RunUploads(t, s, server.Client())
}