Merge pull request #131 from fkautz/pr_out_removing_xmlname_from_json_request

This commit is contained in:
Frederick F. Kautz IV 2015-02-04 14:22:05 -08:00
commit e5cd3dcb7c
2 changed files with 53 additions and 2 deletions

View File

@ -25,7 +25,7 @@ const (
) )
type ObjectListResponse struct { type ObjectListResponse struct {
XMLName xml.Name `xml:"ListBucketResult"` XMLName xml.Name `xml:"ListBucketResult" json:"-"`
Name string Name string
Marker string Marker string
MaxKeys int MaxKeys int
@ -34,7 +34,7 @@ type ObjectListResponse struct {
} }
type BucketListResponse struct { type BucketListResponse struct {
XMLName xml.Name `xml:"ListAllMyBucketsResult"` XMLName xml.Name `xml:"ListAllMyBucketsResult" json:"-"`
Owner Owner Owner Owner
Buckets struct { Buckets struct {
Bucket []*Bucket Bucket []*Bucket

View File

@ -24,6 +24,7 @@ import (
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"strconv" "strconv"
"strings"
"testing" "testing"
"time" "time"
@ -363,3 +364,53 @@ func verifyHeaders(c *C, header http.Header, date time.Time, size int, contentTy
// verify etag // verify etag
c.Assert(header["Etag"][0], Equals, etag) c.Assert(header["Etag"][0], Equals, etag)
} }
func (s *MySuite) TestXMLNameNotInBucketListJson(c *C) {
_, _, storage := inmemory.Start()
httpHandler := HttpHandler(storage)
testServer := httptest.NewServer(httpHandler)
defer testServer.Close()
err := storage.StoreBucket("foo")
c.Assert(err, IsNil)
request, err := http.NewRequest("GET", testServer.URL+"/", bytes.NewBufferString(""))
c.Assert(err, IsNil)
request.Header.Add("Accept", "application/json")
client := http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
byteResults, err := ioutil.ReadAll(response.Body)
c.Assert(err, IsNil)
c.Assert(strings.Contains(string(byteResults), "XML"), Equals, false)
}
func (s *MySuite) TestXMLNameNotInObjectListJson(c *C) {
_, _, storage := inmemory.Start()
httpHandler := HttpHandler(storage)
testServer := httptest.NewServer(httpHandler)
defer testServer.Close()
err := storage.StoreBucket("foo")
c.Assert(err, IsNil)
request, err := http.NewRequest("GET", testServer.URL+"/foo/", bytes.NewBufferString(""))
c.Assert(err, IsNil)
request.Header.Add("Accept", "application/json")
client := http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
byteResults, err := ioutil.ReadAll(response.Body)
c.Assert(err, IsNil)
c.Assert(strings.Contains(string(byteResults), "XML"), Equals, false)
}