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

@@ -73,6 +73,26 @@ func TestS3Integration(t *testing.T) {
t.Fatal(err)
}
defer client.RemoveBucket(context.Background(), bucket)
uploads, _ := New(client, bucket, 6<<20)
httpClient := &http.Client{Timeout: 10 * time.Second}
storagetest.RunUploads(t, uploads, httpClient)
link, err := uploads.PresignPut(ctx, "constrained", 5, "text/plain", time.Minute)
if err != nil {
t.Fatal(err)
}
for _, tc := range []struct{ body, contentType string }{{"longer", "text/plain"}, {"hello", "image/png"}} {
req, _ := http.NewRequestWithContext(ctx, link.Method, link.URL, strings.NewReader(tc.body))
req.Header = link.Headers.Clone()
req.Header.Set("Content-Type", tc.contentType)
response, requestErr := httpClient.Do(req)
if requestErr != nil {
t.Fatal(requestErr)
}
response.Body.Close()
if response.StatusCode != 403 {
t.Fatalf("tampered upload constraints accepted: %d", response.StatusCode)
}
}
s, _ := New(client, bucket, 64)
storagetest.Run(t, s)
s.Put(ctx, "signed", strings.NewReader("hello"), 5, "text/plain")