(t *testing.T)
| 2025 | } |
| 2026 | |
| 2027 | func TestAddRemoteCandidateHonorsRemoteIPFilter(t *testing.T) { |
| 2028 | agent, err := NewAgent(&AgentConfig{ |
| 2029 | RemoteIPFilter: func(ip net.IP) (keep bool) { |
| 2030 | return !ip.Equal(net.IPv4(203, 0, 113, 11)) |
| 2031 | }, |
| 2032 | }) |
| 2033 | require.NoError(t, err) |
| 2034 | defer func() { |
| 2035 | require.NoError(t, agent.Close()) |
| 2036 | }() |
| 2037 | |
| 2038 | blocked, err := NewCandidateHost(&CandidateHostConfig{ |
| 2039 | Network: "udp", |
| 2040 | Address: "203.0.113.11", |
| 2041 | Port: 41000, |
| 2042 | Component: 1, |
| 2043 | }) |
| 2044 | require.NoError(t, err) |
| 2045 | |
| 2046 | allowed, err := NewCandidateHost(&CandidateHostConfig{ |
| 2047 | Network: "udp", |
| 2048 | Address: "198.51.100.12", |
| 2049 | Port: 41001, |
| 2050 | Component: 1, |
| 2051 | }) |
| 2052 | require.NoError(t, err) |
| 2053 | |
| 2054 | require.NoError(t, agent.AddRemoteCandidate(blocked)) |
| 2055 | require.NoError(t, agent.AddRemoteCandidate(allowed)) |
| 2056 | |
| 2057 | require.Eventually(t, func() bool { |
| 2058 | actual, err := agent.GetRemoteCandidates() |
| 2059 | if err != nil { |
| 2060 | return false |
| 2061 | } |
| 2062 | |
| 2063 | return len(actual) == 1 && actual[0].Address() == allowed.Address() |
| 2064 | }, time.Second, 10*time.Millisecond) |
| 2065 | } |
| 2066 | |
| 2067 | func TestGetLocalCandidates(t *testing.T) { |
| 2068 | var config AgentConfig |
nothing calls this directly
no test coverage detected
searching dependent graphs…