Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

service/lookoutmetrics: Fixes handling of API requests #3835

Merged
merged 2 commits into from
Mar 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
### SDK Enhancements

### SDK Bugs
* `service/lookoutmetrics`: Fixes handling of API requests.
* Fix SDK's serialization of request to include expected Content-Type header.

18 changes: 18 additions & 0 deletions service/lookoutmetrics/cust_integ_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// +build go1.7,integration

package lookoutmetrics

import (
"testing"

"github.com/aws/aws-sdk-go/awstesting/integration"
)

func TestInteg_ListAnomalyDetectors(t *testing.T) {
sess := integration.SessionWithDefaultRegion("us-west-2")
client := New(sess)
_, err := client.ListAnomalyDetectors(&ListAnomalyDetectorsInput{})
if err != nil {
t.Fatalf("expect API call, got %v", err)
}
}
18 changes: 18 additions & 0 deletions service/lookoutmetrics/customizations.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package lookoutmetrics

import (
"strings"

"github.com/aws/aws-sdk-go/aws/client"
"github.com/aws/aws-sdk-go/aws/request"
)

func init() {
initClient = func(c *client.Client) {
c.Handlers.Build.PushBack(func(r *request.Request) {
if strings.EqualFold(r.HTTPRequest.Header.Get("Content-Type"), "application/json") {
r.HTTPRequest.Header.Set("Content-Type", "application/x-amz-json-1.1")
}
})
}
}
35 changes: 35 additions & 0 deletions service/lookoutmetrics/customizations_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// +build go1.7

package lookoutmetrics

import (
"net/http"
"net/http/httptest"
"strings"
"testing"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/awstesting/unit"
)

func TestClientContentType(t *testing.T) {
sess := unit.Session.Copy()

server := httptest.NewServer(http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
contentType := r.Header.Get("Content-Type")
if e, a := contentType, "application/x-amz-json-1.1"; !strings.EqualFold(e, a) {
t.Errorf("expect %v content-type, got %v", e, a)
}
},
))
defer server.Close()

client := New(sess, &aws.Config{Endpoint: &server.URL})
_, err := client.ActivateAnomalyDetector(&ActivateAnomalyDetectorInput{
AnomalyDetectorArn: aws.String("foo"),
})
if err != nil {
t.Fatalf("expect no error, got %v", err)
}
}