mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
add namespace for ListAllMyBucketsResult
This commit is contained in:
parent
8a3e72566c
commit
70ac2f6ea8
|
@ -2,6 +2,7 @@ package s3api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/xml"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -21,8 +22,9 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
type ListAllMyBucketsResult struct {
|
type ListAllMyBucketsResult struct {
|
||||||
Buckets []*s3.Bucket `xml:"Buckets>Bucket"`
|
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListAllMyBucketsResult"`
|
||||||
Owner *s3.Owner
|
Owner *s3.Owner
|
||||||
|
Buckets []*s3.Bucket `xml:"Buckets>Bucket"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s3a *S3ApiServer) ListBucketsHandler(w http.ResponseWriter, r *http.Request) {
|
func (s3a *S3ApiServer) ListBucketsHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
40
weed/s3api/s3api_bucket_handlers_test.go
Normal file
40
weed/s3api/s3api_bucket_handlers_test.go
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
package s3api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
|
"github.com/aws/aws-sdk-go/service/s3"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestListBucketsHandler(t *testing.T) {
|
||||||
|
|
||||||
|
expected := `<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Owner><DisplayName></DisplayName><ID></ID></Owner><Buckets><Bucket><CreationDate>2011-04-09T12:34:49Z</CreationDate><Name>test1</Name></Bucket><Bucket><CreationDate>2011-02-09T12:34:49Z</CreationDate><Name>test2</Name></Bucket></Buckets></ListAllMyBucketsResult>`
|
||||||
|
var response ListAllMyBucketsResult
|
||||||
|
|
||||||
|
var buckets []*s3.Bucket
|
||||||
|
buckets = append(buckets, &s3.Bucket{
|
||||||
|
Name: aws.String("test1"),
|
||||||
|
CreationDate: aws.Time(time.Date(2011, 4, 9, 12, 34, 49, 0, time.UTC)),
|
||||||
|
})
|
||||||
|
buckets = append(buckets, &s3.Bucket{
|
||||||
|
Name: aws.String("test2"),
|
||||||
|
CreationDate: aws.Time(time.Date(2011, 2, 9, 12, 34, 49, 0, time.UTC)),
|
||||||
|
})
|
||||||
|
|
||||||
|
response = ListAllMyBucketsResult{
|
||||||
|
Owner: &s3.Owner{
|
||||||
|
ID: aws.String(""),
|
||||||
|
DisplayName: aws.String(""),
|
||||||
|
},
|
||||||
|
Buckets: buckets,
|
||||||
|
}
|
||||||
|
|
||||||
|
encoded := string(encodeResponse(response))
|
||||||
|
println(encoded)
|
||||||
|
if encoded != expected {
|
||||||
|
t.Errorf("unexpected output: %s\nexpecting:%s", encoded, expected)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue