feature: Add client ip to inbound request information (#1678)

* feature: Add client ip to inbound request information
* feature (workers): Add the user's client IP to a session's connection information (#1749)
This commit is contained in:
Jim authored and GitHub committed 2021-12-09 20:41:08 -05:00
1 parent 2cfa027406
commit baa1d88f1f
36 files changed
+563 -169

No files matched your search

+9 -1
View File
@@ -22,6 +22,7 @@ import (
"github.com/hashicorp/eventlogger/filters/gated"
"github.com/hashicorp/eventlogger/formatter_filters/cloudevents"
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-sockaddr"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -164,6 +165,8 @@ func Test_WrapWithOptionals(t *testing.T) {
}
func Test_WrapWithEventsHandler(t *testing.T) {
// This cannot run in parallel because it relies on a pkg var common.privateNets
// this cannot run in parallel because it relies on envvar
// globals.BOUNDARY_DEVELOPER_ENABLE_EVENTS
event.TestEnableEventing(t, true)
@@ -176,6 +179,11 @@ func Test_WrapWithEventsHandler(t *testing.T) {
fmt.Fprintln(w, "I'm a little teapot short and stout")
})
goodAddr, err := sockaddr.NewIPAddr("127.0.0.1")
require.NoError(t, err)
testListenerCfg := cfgListener(goodAddr)
testListenerCfg.XForwardedForRejectNotPresent = false
c := event.TestEventerConfig(t, "Test_WrapWithEventsHandler", event.TestWithAuditSink(t), event.TestWithObservationSink(t))
testLock := &sync.Mutex{}
testLogger := hclog.New(&hclog.LoggerOptions{
@@ -257,7 +265,7 @@ func Test_WrapWithEventsHandler(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert, require := assert.New(t), require.New(t)
got, err := WrapWithEventsHandler(tt.h, tt.e, tt.kms)
got, err := WrapWithEventsHandler(tt.h, tt.e, tt.kms, testListenerCfg)
if tt.wantErrMatch != nil {
require.Error(err)
assert.Nil(got)