Skip to content

Commit

Permalink
Update to apm-data version to handle empty rquest bodies gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
simitt committed Dec 19, 2023
1 parent a4e31f9 commit 74785ec
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 41 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/dgraph-io/badger/v2 v2.2007.3-0.20201012072640-f5a7e0a1c83b
github.com/dustin/go-humanize v1.0.1
github.com/elastic/apm-aggregation v0.0.0-20230815024520-e75a37d9ddd6
github.com/elastic/apm-data v0.1.1-0.20231218185351-dca9298f9dda
github.com/elastic/apm-data v0.1.1-0.20231023025237-39e2a3ca9117
github.com/elastic/beats/v7 v7.0.0-alpha2.0.20231218141841-a633696068ed
github.com/elastic/elastic-agent-client/v7 v7.5.0
github.com/elastic/elastic-agent-libs v0.7.2
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,8 @@ github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFP
github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM=
github.com/elastic/apm-aggregation v0.0.0-20230815024520-e75a37d9ddd6 h1:Js+C3HEE0a5BDFmhEmJV/Uo4uzj/paHjd7yl6+KYguw=
github.com/elastic/apm-aggregation v0.0.0-20230815024520-e75a37d9ddd6/go.mod h1:ba3gaJCuhxXN/O5AuiI56xxd6DukQdVOK0NfpzBntNo=
github.com/elastic/apm-data v0.1.1-0.20231019120308-82201b991ae5 h1:URlDi0TZetSAo8KAIbaMZQhM5EG8+SDgs0jTen7WvMg=
github.com/elastic/apm-data v0.1.1-0.20231019120308-82201b991ae5/go.mod h1:z4iJVl8vyQa5v5o7UapWGHTsycBKsKfJfILuf2TZpYo=
github.com/elastic/apm-data v0.1.1-0.20231218185351-dca9298f9dda h1:ZV1/XIvB0UMU5Mq7HGAmBsNZKHM55mQFPS3b+hcqK4o=
github.com/elastic/apm-data v0.1.1-0.20231218185351-dca9298f9dda/go.mod h1:z4iJVl8vyQa5v5o7UapWGHTsycBKsKfJfILuf2TZpYo=
github.com/elastic/apm-data v0.1.1-0.20231023025237-39e2a3ca9117 h1:qglWR4P715EJJD1CnrmKtWm1PaizFSpjhSP+h9+I3xE=
github.com/elastic/apm-data v0.1.1-0.20231023025237-39e2a3ca9117/go.mod h1:z4iJVl8vyQa5v5o7UapWGHTsycBKsKfJfILuf2TZpYo=
github.com/elastic/beats/v7 v7.0.0-alpha2.0.20231218141841-a633696068ed h1:2ABWyeeCuBbi4ReJFeEAvfPUctfYLc0x5x3ZaQCAuWs=
github.com/elastic/beats/v7 v7.0.0-alpha2.0.20231218141841-a633696068ed/go.mod h1:IyDGwc1d+ERmSiMOZZ2mJIJfCnFnIl85zQP7ZvtkSfY=
github.com/elastic/elastic-agent-autodiscover v0.6.5 h1:5DeMpuNc8c/tN6HN0A4A2uOFTNFHSg7xrKApzfhvF1U=
Expand Down
4 changes: 2 additions & 2 deletions internal/beater/api/intake/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ func TestIntakeHandler(t *testing.T) {
}(),
code: http.StatusBadRequest, id: request.IDResponseErrorsValidate,
},
"BodyReader": {
"EmptyBody": {
path: "errors.ndjson",
r: func() *http.Request {
req := httptest.NewRequest(http.MethodPost, "/", nil)
req.Header.Set(headers.ContentType, "application/x-ndjson")
return req
}(),
code: http.StatusBadRequest, id: request.IDResponseErrorsValidate,
code: http.StatusAccepted, id: request.IDResponseValidAccepted,
},
"CompressedBodyReaderDeflateInvalid": {
path: "errors.ndjson",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"accepted": 0
}

This file was deleted.

This file was deleted.

12 changes: 2 additions & 10 deletions internal/beater/api/mux_intake_rum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@ func TestRUMHandler_NoAuthorizationRequired(t *testing.T) {
cfg.AgentAuth.SecretToken = "1234"
rec, err := requestToMuxerWithPattern(cfg, IntakeRUMPath)
require.NoError(t, err)
assert.NotEqual(t, http.StatusUnauthorized, rec.Code)

expected, err := os.ReadFile(approvalPathIntakeRUM(t.Name()) + ".approved.json")
require.NoError(t, err)
assert.JSONEq(t, string(expected), rec.Body.String())
assert.Equal(t, http.StatusAccepted, rec.Code)
}

func TestRUMHandler_KillSwitchMiddleware(t *testing.T) {
Expand All @@ -96,11 +92,7 @@ func TestRUMHandler_KillSwitchMiddleware(t *testing.T) {
t.Run("On", func(t *testing.T) {
rec, err := requestToMuxerWithPattern(cfgEnabledRUM(), IntakeRUMPath)
require.NoError(t, err)
assert.NotEqual(t, http.StatusForbidden, rec.Code)

expected, err := os.ReadFile(approvalPathIntakeRUM(t.Name()) + ".approved.json")
require.NoError(t, err)
assert.JSONEq(t, string(expected), rec.Body.String())
assert.Equal(t, http.StatusAccepted, rec.Code)
})
}

Expand Down

0 comments on commit 74785ec

Please sign in to comment.