MCPcopy Create free account
hub / github.com/pion/ice / TestAddRemoteCandidateHonorsRemoteIPFilter

Function TestAddRemoteCandidateHonorsRemoteIPFilter

agent_test.go:2027–2065  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2025}
2026
2027func 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
2067func TestGetLocalCandidates(t *testing.T) {
2068 var config AgentConfig

Callers

nothing calls this directly

Calls 7

CloseMethod · 0.95
AddRemoteCandidateMethod · 0.95
GetRemoteCandidatesMethod · 0.95
NewAgentFunction · 0.85
NewCandidateHostFunction · 0.85
EqualMethod · 0.65
AddressMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…