mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-29 08:57:18 +02:00
device enrollment: fix ip address (#3430)
This commit is contained in:
parent
d1037d784a
commit
a938a23ea2
3 changed files with 44 additions and 5 deletions
26
internal/httputil/httputil_test.go
Normal file
26
internal/httputil/httputil_test.go
Normal file
|
@ -0,0 +1,26 @@
|
|||
package httputil
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestGetClientIPAddress(t *testing.T) {
|
||||
r1, err := http.NewRequest("GET", "https://example.com", nil)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "127.0.0.1", GetClientIPAddress(r1))
|
||||
|
||||
r2, err := http.NewRequest("GET", "https://example.com", nil)
|
||||
require.NoError(t, err)
|
||||
r2.RemoteAddr = "127.0.0.2:1234"
|
||||
assert.Equal(t, "127.0.0.2", GetClientIPAddress(r2))
|
||||
|
||||
r3, err := http.NewRequest("GET", "https://example.com", nil)
|
||||
require.NoError(t, err)
|
||||
r3.RemoteAddr = "127.0.0.3:1234"
|
||||
r3.Header.Set("X-Envoy-External-Address", "127.0.0.3")
|
||||
assert.Equal(t, "127.0.0.3", GetClientIPAddress(r3))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue