From 1babc4e57253b50b3b7d720f9228756a99e051b2 Mon Sep 17 00:00:00 2001 From: Devin Humphreys Date: Fri, 1 Mar 2024 15:11:13 -0500 Subject: [PATCH] Return response type based on incoming header --- app/common.go | 12 ---- app/fixtures/fixtures.go | 4 ++ app/fixtures/sqs.go | 12 ++-- app/gosns/gosns.go | 6 +- app/gosqs/gosqs.go | 20 ++++-- app/gosqs/gosqs_test.go | 4 +- app/interfaces/interfaces.go | 5 ++ app/mocks/mocks.go | 27 ++++++- app/models/models_test.go | 20 +++--- app/models/responses.go | 45 ++++++++++++ app/router/router.go | 38 +++++++--- app/router/router_test.go | 104 ++++++++++++++++++++------- app/sqs_messages.go | 11 --- app/utils/tests.go | 3 + go.mod | 10 ++- go.sum | 24 ++++--- smoke_tests/sqs_create_queue_test.go | 74 ++++++++++--------- 17 files changed, 288 insertions(+), 131 deletions(-) create mode 100644 app/fixtures/fixtures.go create mode 100644 app/models/responses.go diff --git a/app/common.go b/app/common.go index 07ad516e1..147a79b5e 100644 --- a/app/common.go +++ b/app/common.go @@ -62,18 +62,6 @@ type ResponseMetadata struct { RequestId string `xml:"RequestId"` } -/*** Error Responses ***/ -type ErrorResult struct { - Type string `xml:"Type,omitempty"` - Code string `xml:"Code,omitempty"` - Message string `xml:"Message,omitempty"` -} - -type ErrorResponse struct { - Result ErrorResult `xml:"Error"` - RequestId string `xml:"RequestId"` -} - type RandomLatency struct { Min int Max int diff --git a/app/fixtures/fixtures.go b/app/fixtures/fixtures.go new file mode 100644 index 000000000..252753bbc --- /dev/null +++ b/app/fixtures/fixtures.go @@ -0,0 +1,4 @@ +package fixtures + +var XMLNS = "http://queue.amazonaws.com/doc/2012-11-05/" +var REQUEST_ID = "request-id" diff --git a/app/fixtures/sqs.go b/app/fixtures/sqs.go index 2139f4cbe..afd5c4795 100644 --- a/app/fixtures/sqs.go +++ b/app/fixtures/sqs.go @@ -31,11 +31,13 @@ var CreateQueueAttributes = models.Attributes{ RedriveAllowPolicy: map[string]interface{}{"this-is": "the-redrive-allow-policy"}, } -var CreateQueueResponse = app.CreateQueueResponse{ - Xmlns: "http://queue.amazonaws.com/doc/2012-11-05/", - Result: app.CreateQueueResult{ - QueueUrl: fmt.Sprintf("http://us-east-1.localhost:4200/100010001000/%s", QueueName), - }, +var CreateQueueResult = models.CreateQueueResult{ + QueueUrl: fmt.Sprintf("http://us-east-1.localhost:4200/100010001000/%s", QueueName), +} + +var CreateQueueResponse = models.CreateQueueResponse{ + Xmlns: "http://queue.amazonaws.com/doc/2012-11-05/", + Result: CreateQueueResult, Metadata: app.ResponseMetadata{ RequestId: "00000000-0000-0000-0000-000000000000", }, diff --git a/app/gosns/gosns.go b/app/gosns/gosns.go index 76a836f7d..52b8e8bc9 100644 --- a/app/gosns/gosns.go +++ b/app/gosns/gosns.go @@ -10,6 +10,8 @@ import ( "strings" "time" + "github.com/Admiral-Piett/goaws/app/models" + "bytes" "crypto" "crypto/rand" @@ -769,8 +771,8 @@ func extractMessageFromJSON(msg string, protocol string) (string, error) { func createErrorResponse(w http.ResponseWriter, req *http.Request, err string) { er := app.SnsErrors[err] - respStruct := app.ErrorResponse{ - Result: app.ErrorResult{Type: er.Type, Code: er.Code, Message: er.Message}, + respStruct := models.ErrorResponse{ + Result: models.ErrorResult{Type: er.Type, Code: er.Code, Message: er.Message}, RequestId: "00000000-0000-0000-0000-000000000000", } diff --git a/app/gosqs/gosqs.go b/app/gosqs/gosqs.go index 9f01ec1c4..9ec13b9d8 100644 --- a/app/gosqs/gosqs.go +++ b/app/gosqs/gosqs.go @@ -9,6 +9,8 @@ import ( "strings" "time" + "github.com/Admiral-Piett/goaws/app/interfaces" + "github.com/Admiral-Piett/goaws/app/models" "github.com/Admiral-Piett/goaws/app/utils" @@ -118,7 +120,7 @@ func ListQueues(w http.ResponseWriter, req *http.Request) { } } -func CreateQueueV1(req *http.Request) (int, interface{}) { +func CreateQueueV1(req *http.Request) (int, interfaces.AbstractResponseBody) { requestBody := models.NewCreateQueueRequest() ok := utils.REQUEST_TRANSFORMER(requestBody, req) if !ok { @@ -153,7 +155,11 @@ func CreateQueueV1(req *http.Request) (int, interface{}) { app.SyncQueues.Unlock() } - respStruct := app.CreateQueueResponse{"http://queue.amazonaws.com/doc/2012-11-05/", app.CreateQueueResult{QueueUrl: queueUrl}, app.ResponseMetadata{RequestId: "00000000-0000-0000-0000-000000000000"}} + respStruct := models.CreateQueueResponse{ + Xmlns: "http://queue.amazonaws.com/doc/2012-11-05/", + Result: models.CreateQueueResult{QueueUrl: queueUrl}, + Metadata: app.ResponseMetadata{RequestId: "00000000-0000-0000-0000-000000000000"}, + } return http.StatusOK, respStruct } @@ -996,8 +1002,8 @@ func getQueueFromPath(formVal string, theUrl string) string { func createErrorResponse(w http.ResponseWriter, req *http.Request, err string) { er := app.SqsErrors[err] - respStruct := app.ErrorResponse{ - Result: app.ErrorResult{Type: er.Type, Code: er.Code, Message: er.Message}, + respStruct := models.ErrorResponse{ + Result: models.ErrorResult{Type: er.Type, Code: er.Code, Message: er.Message}, RequestId: "00000000-0000-0000-0000-000000000000", } @@ -1009,10 +1015,10 @@ func createErrorResponse(w http.ResponseWriter, req *http.Request, err string) { } } -func createErrorResponseV1(err string) (int, app.ErrorResponse) { +func createErrorResponseV1(err string) (int, interfaces.AbstractResponseBody) { er := app.SqsErrors[err] - respStruct := app.ErrorResponse{ - Result: app.ErrorResult{Type: er.Type, Code: er.Code, Message: er.Message}, + respStruct := models.ErrorResponse{ + Result: models.ErrorResult{Type: er.Type, Code: er.Code, Message: er.Message}, RequestId: "00000000-0000-0000-0000-000000000000", // TODO - fix } return er.HttpError, respStruct diff --git a/app/gosqs/gosqs_test.go b/app/gosqs/gosqs_test.go index a8ccec3d9..3511cb64a 100644 --- a/app/gosqs/gosqs_test.go +++ b/app/gosqs/gosqs_test.go @@ -2234,8 +2234,8 @@ func TestGetQueueAttributes_GetSelectedAttributes(t *testing.T) { } func TestCreateErrorResponseV1(t *testing.T) { - expectedResponse := app.ErrorResponse{ - Result: app.ErrorResult{ + expectedResponse := models.ErrorResponse{ + Result: models.ErrorResult{ Type: "Not Found", Code: "AWS.SimpleQueueService.NonExistentQueue", Message: "The specified queue does not exist for this wsdl version.", diff --git a/app/interfaces/interfaces.go b/app/interfaces/interfaces.go index 9d1eeef98..fbe63f531 100644 --- a/app/interfaces/interfaces.go +++ b/app/interfaces/interfaces.go @@ -7,3 +7,8 @@ import ( type AbstractRequestBody interface { SetAttributesFromForm(values url.Values) } + +type AbstractResponseBody interface { + GetResult() interface{} + GetRequestId() string +} diff --git a/app/mocks/mocks.go b/app/mocks/mocks.go index 49c0bd89c..6db051c37 100644 --- a/app/mocks/mocks.go +++ b/app/mocks/mocks.go @@ -1,6 +1,10 @@ package mocks -import "net/url" +import ( + "net/url" + + af "github.com/Admiral-Piett/goaws/app/fixtures" +) type MockRequestBody struct { RequestFieldStr string `json:"field" schema:"field"` @@ -19,3 +23,24 @@ func (m *MockRequestBody) SetAttributesFromForm(values url.Values) { m.MockSetAttributesFromFormCalledWith(values) } } + +type BaseResponse struct { + Message string `json:"Message" xml:"Message"` + + MockGetResult func() interface{} `json:"-" xml:"-"` + MockGetRequestId func() string `json:"-" xml:"-"` +} + +func (r BaseResponse) GetResult() interface{} { + if r.MockGetResult != nil { + return r.MockGetResult() + } + return r +} + +func (r BaseResponse) GetRequestId() string { + if r.MockGetRequestId != nil { + return r.GetRequestId() + } + return af.REQUEST_ID +} diff --git a/app/models/models_test.go b/app/models/models_test.go index c84f4b016..041222d90 100644 --- a/app/models/models_test.go +++ b/app/models/models_test.go @@ -72,12 +72,12 @@ func TestCreateQueueRequest_SetAttributesFromForm_success(t *testing.T) { } cqr.SetAttributesFromForm(form) - assert.Equal(t, 1, cqr.Attributes.DelaySeconds) - assert.Equal(t, 2, cqr.Attributes.MaximumMessageSize) - assert.Equal(t, 3, cqr.Attributes.MessageRetentionPeriod) + assert.Equal(t, StringToInt(1), cqr.Attributes.DelaySeconds) + assert.Equal(t, StringToInt(2), cqr.Attributes.MaximumMessageSize) + assert.Equal(t, StringToInt(3), cqr.Attributes.MessageRetentionPeriod) assert.Equal(t, map[string]interface{}{"i-am": "the-policy"}, cqr.Attributes.Policy) - assert.Equal(t, 4, cqr.Attributes.ReceiveMessageWaitTimeSeconds) - assert.Equal(t, 5, cqr.Attributes.VisibilityTimeout) + assert.Equal(t, StringToInt(4), cqr.Attributes.ReceiveMessageWaitTimeSeconds) + assert.Equal(t, StringToInt(5), cqr.Attributes.VisibilityTimeout) assert.Equal(t, expectedRedrivePolicy, cqr.Attributes.RedrivePolicy) assert.Equal(t, map[string]interface{}{"i-am": "the-redrive-allow-policy"}, cqr.Attributes.RedriveAllowPolicy) } @@ -166,12 +166,12 @@ func TestCreateQueueRequest_SetAttributesFromForm_success_skips_invalid_values(t } cqr.SetAttributesFromForm(form) - assert.Equal(t, 1, cqr.Attributes.DelaySeconds) - assert.Equal(t, 262144, cqr.Attributes.MaximumMessageSize) - assert.Equal(t, 345600, cqr.Attributes.MessageRetentionPeriod) + assert.Equal(t, StringToInt(1), cqr.Attributes.DelaySeconds) + assert.Equal(t, StringToInt(262144), cqr.Attributes.MaximumMessageSize) + assert.Equal(t, StringToInt(345600), cqr.Attributes.MessageRetentionPeriod) assert.Equal(t, map[string]interface{}(nil), cqr.Attributes.Policy) - assert.Equal(t, 10, cqr.Attributes.ReceiveMessageWaitTimeSeconds) - assert.Equal(t, 30, cqr.Attributes.VisibilityTimeout) + assert.Equal(t, StringToInt(10), cqr.Attributes.ReceiveMessageWaitTimeSeconds) + assert.Equal(t, StringToInt(30), cqr.Attributes.VisibilityTimeout) assert.Equal(t, RedrivePolicy{}, cqr.Attributes.RedrivePolicy) assert.Equal(t, map[string]interface{}(nil), cqr.Attributes.RedriveAllowPolicy) } diff --git a/app/models/responses.go b/app/models/responses.go new file mode 100644 index 000000000..84b21a3e2 --- /dev/null +++ b/app/models/responses.go @@ -0,0 +1,45 @@ +package models + +import "github.com/Admiral-Piett/goaws/app" + +// NOTE: Every response in here MUST implement the `AbstractResponseBody` interface in order to be used +// in `encodeResponse` + +/*** Error Responses ***/ +type ErrorResult struct { + Type string `xml:"Type,omitempty"` + Code string `xml:"Code,omitempty"` + Message string `xml:"Message,omitempty"` +} + +type ErrorResponse struct { + Result ErrorResult `xml:"Error"` + RequestId string `xml:"RequestId"` +} + +func (r ErrorResponse) GetResult() interface{} { + return r.Result +} + +func (r ErrorResponse) GetRequestId() string { + return r.RequestId +} + +/*** Create Queue Response */ +type CreateQueueResult struct { + QueueUrl string `json:"QueueUrl" xml:"QueueUrl"` +} + +type CreateQueueResponse struct { + Xmlns string `xml:"xmlns,attr"` + Result CreateQueueResult `xml:"CreateQueueResult"` + Metadata app.ResponseMetadata `xml:"ResponseMetadata"` +} + +func (r CreateQueueResponse) GetResult() interface{} { + return r.Result +} + +func (r CreateQueueResponse) GetRequestId() string { + return r.Metadata.RequestId +} diff --git a/app/router/router.go b/app/router/router.go index 9172ff5a5..f7eb19be3 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -1,11 +1,14 @@ package router import ( + "encoding/json" "encoding/xml" "io" "net/http" "strings" + "github.com/Admiral-Piett/goaws/app/interfaces" + log "github.com/sirupsen/logrus" "fmt" @@ -29,19 +32,34 @@ func New() http.Handler { return r } -func encodeResponse(w http.ResponseWriter, statusCode int, body interface{}) { - w.Header().Set("Content-Type", "application/xml") - w.WriteHeader(statusCode) - // TODO - replace with gorilla/schema - enc := xml.NewEncoder(w) - enc.Indent(" ", " ") - if err := enc.Encode(body); err != nil { - log.Errorf("error: %v\n", err) +func encodeResponse(w http.ResponseWriter, req *http.Request, statusCode int, body interfaces.AbstractResponseBody) { + protocol := resolveProtocol(req) + switch protocol { + case AwsJsonProtocol: + w.Header().Set("x-amzn-RequestId", body.GetRequestId()) + w.Header().Set("Content-Type", "application/x-amz-json-1.0") + // Stupidly these `WriteHeader` calls have to be here, if they're at the start + // they lock the headers, at the end they're ignored. + w.WriteHeader(statusCode) + err := json.NewEncoder(w).Encode(body.GetResult()) + if err != nil { + log.Errorf("Response Encoding Error: %v\nResponse: %+v", err, body) + http.Error(w, "General Error", http.StatusInternalServerError) + } + case AwsQueryProtocol: + w.Header().Set("Content-Type", "application/xml") + w.WriteHeader(statusCode) + result, err := xml.Marshal(body) + if err != nil { + log.Errorf("Response Encoding Error: %v\nResponse: %+v", err, body) + http.Error(w, "General Error", http.StatusInternalServerError) + } + _, _ = w.Write(result) } } // V1 - includes JSON Support (and of course the old XML). -var routingTableV1 = map[string]func(r *http.Request) (int, interface{}){ +var routingTableV1 = map[string]func(r *http.Request) (int, interfaces.AbstractResponseBody){ "CreateQueue": sqs.CreateQueueV1, } @@ -93,7 +111,7 @@ func actionHandler(w http.ResponseWriter, req *http.Request) { jsonFn, ok := routingTableV1[action] if ok { statusCode, responseBody := jsonFn(req) - encodeResponse(w, statusCode, responseBody) + encodeResponse(w, req, statusCode, responseBody) return } fn, ok := routingTable[action] diff --git a/app/router/router_test.go b/app/router/router_test.go index e0223315c..76c8608f5 100644 --- a/app/router/router_test.go +++ b/app/router/router_test.go @@ -7,8 +7,13 @@ import ( "net/http" "net/http/httptest" "net/url" + "strings" "testing" + "github.com/Admiral-Piett/goaws/app/mocks" + + "github.com/Admiral-Piett/goaws/app/interfaces" + sns "github.com/Admiral-Piett/goaws/app/gosns" sqs "github.com/Admiral-Piett/goaws/app/gosqs" @@ -145,47 +150,67 @@ func TestIndexServerhandler_GET_GoodRequest_Pem_cert(t *testing.T) { } } -func TestEncodeResponse_success(t *testing.T) { - w, _ := utils.GenerateRequestInfo("POST", "/url", nil, false) - - type responseStruct struct { - Message string `xml:"message"` - } +func TestEncodeResponse_success_xml(t *testing.T) { + w, r := utils.GenerateRequestInfo("POST", "/url", nil, false) - encodeResponse(w, http.StatusOK, responseStruct{Message: "response-body"}) + encodeResponse(w, r, http.StatusOK, mocks.BaseResponse{Message: "test"}) assert.Equal(t, http.StatusOK, w.Code) - tmp := responseStruct{} + tmp := mocks.BaseResponse{} xml.Unmarshal(w.Body.Bytes(), &tmp) - assert.Equal(t, responseStruct{Message: "response-body"}, tmp) + assert.Equal(t, mocks.BaseResponse{Message: "test"}, tmp) } -func TestEncodeResponse_success_skips_malformed_body(t *testing.T) { - w, _ := utils.GenerateRequestInfo("POST", "/url", nil, false) +func TestEncodeResponse_success_skips_nil_body_xml(t *testing.T) { + w, r := utils.GenerateRequestInfo("POST", "/url", nil, false) - encodeResponse(w, http.StatusOK, nil) + encodeResponse(w, r, http.StatusOK, nil) assert.Equal(t, http.StatusOK, w.Code) assert.Equal(t, &bytes.Buffer{}, w.Body) } -func TestActionHandler_json(t *testing.T) { - type responseStruct struct { - Message string `xml:"message"` +func TestEncodeResponse_success_json(t *testing.T) { + w, r := utils.GenerateRequestInfo("POST", "/url", nil, true) + + encodeResponse(w, r, http.StatusOK, mocks.BaseResponse{Message: "test"}) + + assert.Equal(t, http.StatusOK, w.Code) + + tmp := mocks.BaseResponse{} + json.Unmarshal(w.Body.Bytes(), &tmp) + assert.Equal(t, mocks.BaseResponse{Message: "test"}, tmp) +} + +func TestEncodeResponse_success_skips_malformed_body_json(t *testing.T) { + mock := mocks.BaseResponse{ + Message: "test", + } + mock.MockGetResult = func() interface{} { + return make(chan int) } + w, r := utils.GenerateRequestInfo("POST", "/url", nil, true) + + encodeResponse(w, r, http.StatusOK, mock) + + assert.Equal(t, http.StatusOK, w.Code) + assert.Equal(t, "General Error", strings.TrimSpace(string(w.Body.Bytes()))) +} + +func TestActionHandler_v1_json(t *testing.T) { defer func() { - routingTableV1 = map[string]func(r *http.Request) (int, interface{}){ + routingTableV1 = map[string]func(r *http.Request) (int, interfaces.AbstractResponseBody){ "CreateQueue": sqs.CreateQueueV1, } }() mockCalled := false - mockFunction := func(req *http.Request) (int, interface{}) { + mockFunction := func(req *http.Request) (int, interfaces.AbstractResponseBody) { mockCalled = true - return http.StatusOK, responseStruct{Message: "response-body"} + return http.StatusOK, mocks.BaseResponse{Message: "response-body"} } - routingTableV1 = map[string]func(r *http.Request) (int, interface{}){ + routingTableV1 = map[string]func(r *http.Request) (int, interfaces.AbstractResponseBody){ "CreateQueue": mockFunction, } @@ -197,14 +222,45 @@ func TestActionHandler_json(t *testing.T) { assert.True(t, mockCalled) assert.Equal(t, http.StatusOK, w.Code) - tmp := responseStruct{} + tmp := mocks.BaseResponse{} + json.Unmarshal(w.Body.Bytes(), &tmp) + assert.Equal(t, mocks.BaseResponse{Message: "response-body"}, tmp) +} + +func TestActionHandler_v1_xml(t *testing.T) { + defer func() { + routingTableV1 = map[string]func(r *http.Request) (int, interfaces.AbstractResponseBody){ + "CreateQueue": sqs.CreateQueueV1, + } + }() + + mockCalled := false + mockFunction := func(req *http.Request) (int, interfaces.AbstractResponseBody) { + mockCalled = true + return http.StatusOK, mocks.BaseResponse{Message: "response-body"} + } + routingTableV1 = map[string]func(r *http.Request) (int, interfaces.AbstractResponseBody){ + "CreateQueue": mockFunction, + } + + w, r := utils.GenerateRequestInfo("POST", "/url", nil, false) + form := url.Values{} + form.Add("Action", "CreateQueue") + r.PostForm = form + + actionHandler(w, r) + + assert.True(t, mockCalled) + assert.Equal(t, http.StatusOK, w.Code) + + tmp := mocks.BaseResponse{} xml.Unmarshal(w.Body.Bytes(), &tmp) - assert.Equal(t, responseStruct{Message: "response-body"}, tmp) + assert.Equal(t, mocks.BaseResponse{Message: "response-body"}, tmp) } -func TestActionHandler_xml(t *testing.T) { +func TestActionHandler_v0_xml(t *testing.T) { defer func() { - routingTableV1 = map[string]func(r *http.Request) (int, interface{}){ + routingTableV1 = map[string]func(r *http.Request) (int, interfaces.AbstractResponseBody){ "CreateQueue": sqs.CreateQueueV1, } routingTable = map[string]http.HandlerFunc{ @@ -245,7 +301,7 @@ func TestActionHandler_xml(t *testing.T) { mockCalled = true w.WriteHeader(http.StatusOK) } - routingTableV1 = map[string]func(r *http.Request) (int, interface{}){} + routingTableV1 = map[string]func(r *http.Request) (int, interfaces.AbstractResponseBody){} routingTable = map[string]http.HandlerFunc{ "CreateQueue": mockFunction, } diff --git a/app/sqs_messages.go b/app/sqs_messages.go index faf5df571..9b51b11ca 100644 --- a/app/sqs_messages.go +++ b/app/sqs_messages.go @@ -11,17 +11,6 @@ type ListQueuesResponse struct { Metadata ResponseMetadata `xml:"ResponseMetadata"` } -/*** Create Queue Response */ -type CreateQueueResult struct { - QueueUrl string `xml:"QueueUrl"` -} - -type CreateQueueResponse struct { - Xmlns string `xml:"xmlns,attr"` - Result CreateQueueResult `xml:"CreateQueueResult"` - Metadata ResponseMetadata `xml:"ResponseMetadata"` -} - /*** Send Message Response */ type SendMessageResult struct { diff --git a/app/utils/tests.go b/app/utils/tests.go index 77cf3fc35..bac67374d 100644 --- a/app/utils/tests.go +++ b/app/utils/tests.go @@ -12,7 +12,10 @@ import ( func ResetApp() { app.CurrentEnvironment = app.Environment{} + ResetResources() +} +func ResetResources() { app.SyncQueues.Lock() app.SyncQueues.Queues = make(map[string]*app.Queue) app.SyncQueues.Unlock() diff --git a/go.mod b/go.mod index fa8c4b15a..24515f72e 100644 --- a/go.mod +++ b/go.mod @@ -4,8 +4,11 @@ go 1.18 require ( github.com/aws/aws-sdk-go v1.47.3 + github.com/gavv/httpexpect/v2 v2.16.0 github.com/ghodss/yaml v1.0.0 github.com/gorilla/mux v1.8.0 + github.com/gorilla/schema v1.2.1 + github.com/mitchellh/copystructure v1.2.0 github.com/sirupsen/logrus v1.9.0 github.com/stretchr/testify v1.7.0 ) @@ -17,23 +20,22 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/fatih/color v1.15.0 // indirect github.com/fatih/structs v1.1.0 // indirect - github.com/gavv/httpexpect/v2 v2.16.0 // indirect github.com/gobwas/glob v0.2.3 // indirect github.com/google/go-querystring v1.1.0 // indirect - github.com/gorilla/schema v1.2.1 // indirect github.com/gorilla/websocket v1.4.2 // indirect + github.com/hpcloud/tail v1.0.0 // indirect github.com/imkira/go-interpol v1.1.0 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/klauspost/compress v1.15.0 // indirect github.com/kr/pretty v0.1.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.18 // indirect - github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/sanity-io/litter v1.5.5 // indirect github.com/sergi/go-diff v1.0.0 // indirect + github.com/stretchr/objx v0.1.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasthttp v1.34.0 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect @@ -45,6 +47,8 @@ require ( golang.org/x/net v0.17.0 // indirect golang.org/x/sys v0.13.0 // indirect gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect + gopkg.in/fsnotify.v1 v1.4.7 // indirect + gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.0 // indirect moul.io/http2curl/v2 v2.3.0 // indirect diff --git a/go.sum b/go.sum index 37cff5d62..74268a2fb 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,6 @@ github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU= github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= -github.com/aws/aws-sdk-go v1.34.0 h1:brux2dRrlwCF5JhTL7MUT3WUwo9zfDHZZp3+g3Mvlmo= -github.com/aws/aws-sdk-go v1.34.0/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go v1.47.3 h1:e0H6NFXiniCpR8Lu3lTphVdRaeRCDLAeRyTHd1tJSd8= github.com/aws/aws-sdk-go v1.47.3/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -20,9 +18,9 @@ github.com/gavv/httpexpect/v2 v2.16.0 h1:Ty2favARiTYTOkCRZGX7ojXXjGyNAIohM1lZ3vq github.com/gavv/httpexpect/v2 v2.16.0/go.mod h1:uJLaO+hQ25ukBJtQi750PsztObHybNllN+t+MbbW8PY= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= +github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= @@ -32,12 +30,14 @@ github.com/gorilla/schema v1.2.1 h1:tjDxcmdb+siIqkTNoV+qRH2mjYdr2hHe5MKXbp61ziM= github.com/gorilla/schema v1.2.1/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/hokaccha/go-prettyjson v0.0.0-20211117102719-0474bc63780f h1:7LYC+Yfkj3CTRcShK0KOL/w6iTiKyqqBA9a41Wnggw8= +github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/imkira/go-interpol v1.1.0 h1:KIiKr0VSG2CUW1hl1jpiyuzuJeKUUpC8iM1AIE7N1Vk= github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA= -github.com/jmespath/go-jmespath v0.3.0 h1:OS12ieG61fsCg5+qLJ+SsW9NicxNkg3b25OyT2yCeUc= -github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= +github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/klauspost/compress v1.15.0 h1:xqfchp4whNFxn5A4XFyyYtitiWI8Hy5EW59jEwcyL6U= github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= @@ -57,8 +57,9 @@ github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQ github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/onsi/ginkgo v1.10.1 h1:q/mM8GF/n0shIN8SaAZ0V+jnLPzen6WIVZdiwrRlMlo= +github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME= github.com/pkg/diff v0.0.0-20200914180035-5b29258ca4f7/go.mod h1:zO8QMzTeZd5cpnIkz/Gn6iK0jDfGicM1nynOkkPIl28= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -68,11 +69,11 @@ github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v0.0.0-20161117074351-18a02ba4a312/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/tailscale/depaware v0.0.0-20210622194025-720c4b409502/go.mod h1:p9lPsd+cx33L3H9nNoecRRxPssFKUwwI50I3pZ0yT+8= @@ -94,6 +95,7 @@ github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCO github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M= github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= +github.com/yudai/pp v2.0.1+incompatible h1:Q4//iY4pNF6yPLZIigmvcl7k/bPgrcTPIFIcmawg5bI= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -103,7 +105,6 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= @@ -121,8 +122,6 @@ golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -132,6 +131,7 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20201211185031-d93e913c1a58/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= @@ -142,6 +142,10 @@ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8T gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= diff --git a/smoke_tests/sqs_create_queue_test.go b/smoke_tests/sqs_create_queue_test.go index 02caaacac..f14bdc25b 100644 --- a/smoke_tests/sqs_create_queue_test.go +++ b/smoke_tests/sqs_create_queue_test.go @@ -1,6 +1,7 @@ package smoke_tests import ( + "encoding/json" "encoding/xml" "fmt" "net/http" @@ -21,11 +22,13 @@ import ( ) // TODO - Is there a way to also capture the defaults we set and/or load from the config here? (review the xml -// -// code below) +// code below) func Test_CreateQueueV1_json_no_attributes(t *testing.T) { server := generateServer() - defer server.Close() + defer func() { + server.Close() + utils.ResetResources() + }() e := httpexpect.Default(t, server.URL) @@ -42,14 +45,10 @@ func Test_CreateQueueV1_json_no_attributes(t *testing.T) { Status(http.StatusOK). Body().Raw() - exp1 := app.CreateQueueResponse{ - Xmlns: "http://queue.amazonaws.com/doc/2012-11-05/", - Result: app.CreateQueueResult{QueueUrl: fmt.Sprintf("%s/new-queue-1", sf.BASE_URL)}, - Metadata: app.ResponseMetadata{RequestId: sf.REQUEST_ID}, - } + exp1 := models.CreateQueueResult{QueueUrl: fmt.Sprintf("%s/new-queue-1", sf.BASE_URL)} - r1 := app.CreateQueueResponse{} - xml.Unmarshal([]byte(r), &r1) + r1 := models.CreateQueueResult{} + json.Unmarshal([]byte(r), &r1) assert.Equal(t, exp1, r1) r = e.POST("/"). @@ -80,7 +79,10 @@ func Test_CreateQueueV1_json_no_attributes(t *testing.T) { func Test_CreateQueueV1_json_with_attributes(t *testing.T) { server := generateServer() - defer server.Close() + defer func() { + server.Close() + utils.ResetResources() + }() e := httpexpect.Default(t, server.URL) @@ -94,14 +96,10 @@ func Test_CreateQueueV1_json_with_attributes(t *testing.T) { Status(http.StatusOK). Body().Raw() - exp1 := app.CreateQueueResponse{ - Xmlns: "http://queue.amazonaws.com/doc/2012-11-05/", - Result: app.CreateQueueResult{QueueUrl: fmt.Sprintf("%s/new-queue-1", sf.BASE_URL)}, - Metadata: app.ResponseMetadata{RequestId: sf.REQUEST_ID}, - } + exp1 := models.CreateQueueResult{QueueUrl: fmt.Sprintf("%s/new-queue-1", sf.BASE_URL)} - r1 := app.CreateQueueResponse{} - xml.Unmarshal([]byte(r), &r1) + r1 := models.CreateQueueResult{} + json.Unmarshal([]byte(r), &r1) assert.Equal(t, exp1, r1) r = e.POST("/"). @@ -135,9 +133,13 @@ func Test_CreateQueueV1_json_with_attributes(t *testing.T) { assert.Equal(t, exp3, r3) } +// TODO - fix broken tests func Test_CreateQueueV1_json_with_attributes_ints_as_strings(t *testing.T) { server := generateServer() - defer server.Close() + defer func() { + server.Close() + utils.ResetResources() + }() e := httpexpect.Default(t, server.URL) @@ -204,14 +206,10 @@ func Test_CreateQueueV1_json_with_attributes_ints_as_strings(t *testing.T) { Status(http.StatusOK). Body().Raw() - exp1 := app.CreateQueueResponse{ - Xmlns: "http://queue.amazonaws.com/doc/2012-11-05/", - Result: app.CreateQueueResult{QueueUrl: fmt.Sprintf("%s/new-string-queue", sf.BASE_URL)}, - Metadata: app.ResponseMetadata{RequestId: sf.REQUEST_ID}, - } + exp1 := models.CreateQueueResult{QueueUrl: fmt.Sprintf("%s/new-string-queue", sf.BASE_URL)} - r1 := app.CreateQueueResponse{} - xml.Unmarshal([]byte(r), &r1) + r1 := models.CreateQueueResult{} + json.Unmarshal([]byte(r), &r1) assert.Equal(t, exp1, r1) gqar := struct { @@ -242,7 +240,11 @@ func Test_CreateQueueV1_json_with_attributes_ints_as_strings(t *testing.T) { func Test_CreateQueueV1_xml_no_attributes(t *testing.T) { server := generateServer() - defer server.Close() + defer func() { + server.Close() + utils.ResetResources() + }() + utils.InitializeDecoders() e := httpexpect.Default(t, server.URL) @@ -253,13 +255,13 @@ func Test_CreateQueueV1_xml_no_attributes(t *testing.T) { Status(http.StatusOK). Body().Raw() - exp1 := app.CreateQueueResponse{ + exp1 := models.CreateQueueResponse{ Xmlns: "http://queue.amazonaws.com/doc/2012-11-05/", - Result: app.CreateQueueResult{QueueUrl: fmt.Sprintf("%s/new-queue-1", sf.BASE_URL)}, + Result: models.CreateQueueResult{QueueUrl: fmt.Sprintf("%s/new-queue-1", sf.BASE_URL)}, Metadata: app.ResponseMetadata{RequestId: sf.REQUEST_ID}, } - r1 := app.CreateQueueResponse{} + r1 := models.CreateQueueResponse{} xml.Unmarshal([]byte(r), &r1) assert.Equal(t, exp1, r1) @@ -291,7 +293,11 @@ func Test_CreateQueueV1_xml_no_attributes(t *testing.T) { func Test_CreateQueueV1_xml_with_attributes(t *testing.T) { server := generateServer() - defer server.Close() + defer func() { + server.Close() + utils.ResetResources() + }() + utils.InitializeDecoders() e := httpexpect.Default(t, server.URL) @@ -336,13 +342,13 @@ func Test_CreateQueueV1_xml_with_attributes(t *testing.T) { Status(http.StatusOK). Body().Raw() - exp1 := app.CreateQueueResponse{ + exp1 := models.CreateQueueResponse{ Xmlns: "http://queue.amazonaws.com/doc/2012-11-05/", - Result: app.CreateQueueResult{QueueUrl: fmt.Sprintf("%s/new-queue-2", sf.BASE_URL)}, + Result: models.CreateQueueResult{QueueUrl: fmt.Sprintf("%s/new-queue-2", sf.BASE_URL)}, Metadata: app.ResponseMetadata{RequestId: sf.REQUEST_ID}, } - r1 := app.CreateQueueResponse{} + r1 := models.CreateQueueResponse{} xml.Unmarshal([]byte(r), &r1) assert.Equal(t, exp1, r1)