MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / TestPeer

Function TestPeer

pkg/webmiddleware/peer_test.go:29–43  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

27)
28
29func TestPeer(t *testing.T) {
30 t.Parallel()
31 a := assertions.New(t)
32
33 m := Peer()
34
35 r := httptest.NewRequest(http.MethodGet, "/", nil)
36
37 rec := httptest.NewRecorder()
38 m(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
39 peer, ok := peer.FromContext(r.Context())
40 a.So(ok, should.BeTrue)
41 a.So(peer.Addr.String(), should.Equal, "192.0.2.1:1234")
42 })).ServeHTTP(rec, r)
43}
44
45func TestPeerTLS(t *testing.T) {
46 t.Parallel()

Callers

nothing calls this directly

Calls 5

PeerFunction · 0.70
NewMethod · 0.65
ContextMethod · 0.65
StringMethod · 0.65
ServeHTTPMethod · 0.45

Tested by

no test coverage detected