feat: complete API-driven projects with infrastructure and business acceptance
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user