mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-11-18 17:55:26 +01:00
s3api: answer NoSuchBucket from GetBucketRequestPayment for a missing bucket (#12716)
* s3api: answer NoSuchBucket from GetBucketRequestPayment for a missing bucket The handler wrote the static BucketOwner answer without resolving the bucket, so a bucket that does not exist looked like one that does. Check the bucket first, as PutBucketRequestPayment and the other static configuration getters already do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: test GetBucketRequestPayment on existing and missing buckets Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
eb1dca8088
commit
8c6d09f498
2 files changed
+29
-1
No files matched your search
@@ -1399,9 +1399,14 @@ func (s3a *S3ApiServer) GetBucketLocationHandler(w http.ResponseWriter, r *http.
|
||||
writeSuccessResponseXML(w, r, CreateBucketConfiguration{})
|
||||
}
|
||||
|
||||
// GetBucketRequestPaymentHandler Get bucket location
|
||||
// GetBucketRequestPaymentHandler Get bucket request payment
|
||||
// https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketRequestPayment.html
|
||||
func (s3a *S3ApiServer) GetBucketRequestPaymentHandler(w http.ResponseWriter, r *http.Request) {
|
||||
bucket, _ := s3_constants.GetBucketAndObject(r)
|
||||
if err := s3a.checkBucket(r, bucket); err != s3err.ErrNone {
|
||||
s3err.WriteErrorResponse(w, r, err)
|
||||
return
|
||||
}
|
||||
writeSuccessResponseXML(w, r, RequestPaymentConfiguration{Payer: "BucketOwner"})
|
||||
}
|
||||
|
||||
|
||||
@@ -115,6 +115,29 @@ func TestPutBucketRequestPaymentBucketOwner(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetBucketRequestPayment(t *testing.T) {
|
||||
s3a := newMiscTestServer(t, "b")
|
||||
s3a.bucketConfigCache.SetNegativeCache("missing")
|
||||
|
||||
rec := httptest.NewRecorder()
|
||||
s3a.GetBucketRequestPaymentHandler(rec, newBucketRequest(http.MethodGet, "b", "requestPayment=", ""))
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("status = %d, want %d", rec.Code, http.StatusOK)
|
||||
}
|
||||
if !strings.Contains(rec.Body.String(), "<Payer>BucketOwner</Payer>") {
|
||||
t.Fatalf("missing BucketOwner payer: %s", rec.Body.String())
|
||||
}
|
||||
|
||||
rec = httptest.NewRecorder()
|
||||
s3a.GetBucketRequestPaymentHandler(rec, newBucketRequest(http.MethodGet, "missing", "requestPayment=", ""))
|
||||
if rec.Code != http.StatusNotFound {
|
||||
t.Fatalf("missing bucket status = %d, want %d", rec.Code, http.StatusNotFound)
|
||||
}
|
||||
if !strings.Contains(rec.Body.String(), "NoSuchBucket") {
|
||||
t.Fatalf("body = %s, want NoSuchBucket", rec.Body.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestPutBucketRequestPaymentRequesterRejected(t *testing.T) {
|
||||
s3a := newMiscTestServer(t, "b")
|
||||
body := `<RequestPaymentConfiguration><Payer>Requester</Payer></RequestPaymentConfiguration>`
|
||||
|
||||
Reference in new issue
Block a user