Skip to content

Commit

Permalink
address pr comment
Browse files Browse the repository at this point in the history
  • Loading branch information
efd6 committed May 30, 2024
1 parent c759ec2 commit 07d320d
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions x-pack/filebeat/input/http_endpoint/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,81 @@ func Test_apiResponse(t *testing.T) {
wantStatus: http.StatusOK,
wantResponse: `{"message": "success"}`,
},
{
name: "hmac_hex",
conf: func() config {
c := defaultConfig()
c.Prefix = "."
c.HMACHeader = "Test-HMAC"
c.HMACKey = "Test-HMAC-Key"
c.HMACType = "sha1"
c.HMACPrefix = "sha1:"
return c
}(),
request: func() *http.Request {
req := httptest.NewRequest(http.MethodPost, "/", bytes.NewBufferString(`{"id":0}`))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Test-HMAC", "sha1:f6bf232bf1f0ca3d768f8b6bd5c26a204ba57e89")
return req
}(),
events: []mapstr.M{
{
"id": int64(0),
},
},
wantStatus: http.StatusOK,
wantResponse: `{"message": "success"}`,
},
{
name: "hmac_base64",
conf: func() config {
c := defaultConfig()
c.Prefix = "."
c.HMACHeader = "Test-HMAC"
c.HMACKey = "Test-HMAC-Key"
c.HMACType = "sha1"
c.HMACPrefix = "sha1:"
return c
}(),
request: func() *http.Request {
req := httptest.NewRequest(http.MethodPost, "/", bytes.NewBufferString(`{"id":0}`))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Test-HMAC", "sha1:9r8jK/Hwyj12j4tr1cJqIEulfok=")
return req
}(),
events: []mapstr.M{
{
"id": int64(0),
},
},
wantStatus: http.StatusOK,
wantResponse: `{"message": "success"}`,
},
{
name: "hmac_raw_base64",
conf: func() config {
c := defaultConfig()
c.Prefix = "."
c.HMACHeader = "Test-HMAC"
c.HMACKey = "Test-HMAC-Key"
c.HMACType = "sha1"
c.HMACPrefix = "sha1:"
return c
}(),
request: func() *http.Request {
req := httptest.NewRequest(http.MethodPost, "/", bytes.NewBufferString(`{"id":0}`))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Test-HMAC", "sha1:9r8jK/Hwyj12j4tr1cJqIEulfok")
return req
}(),
events: []mapstr.M{
{
"id": int64(0),
},
},
wantStatus: http.StatusOK,
wantResponse: `{"message": "success"}`,
},
{
name: "single_event_gzip",
conf: defaultConfig(),
Expand Down

0 comments on commit 07d320d

Please sign in to comment.