oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package egress
2
3import (
4 "context"
5 "errors"
6 "net"
7 "net/netip"
8 "testing"
9)
10
11func TestEgressDenialCount(t *testing.T) {
12 p := fixtureProxy(t, []netip.Addr{netip.MustParseAddr("127.0.0.1")}, func(context.Context, string, string) (net.Conn, error) { return nil, errors.New("unexpected dial") })
13 counter, ok := any(p).(interface{ Denials() uint64 })
14 if !ok {
15 t.Fatal("denials unavailable")
16 }
17 if counter.Denials() != 0 {
18 t.Fatal("nonzero initial count")
19 }
20 connect(t, p, request("unknown.example:443"))
21 connect(t, p, request("fixture.example:443"))
22 if counter.Denials() != 2 {
23 t.Fatal("denials not recorded", counter.Denials())
24 }
25}
26