(t *testing.T)
| 215 | } |
| 216 | |
| 217 | func TestLoopbackCandidate(t *testing.T) { |
| 218 | defer test.CheckRoutines(t)() |
| 219 | |
| 220 | defer test.TimeOut(time.Second * 30).Stop() |
| 221 | type testCase struct { |
| 222 | name string |
| 223 | agentConfig *AgentConfig |
| 224 | loExpected bool |
| 225 | } |
| 226 | mux, err := NewMultiUDPMuxFromPort(12500) |
| 227 | require.NoError(t, err) |
| 228 | muxWithLo, errlo := NewMultiUDPMuxFromPort(12501, UDPMuxFromPortWithLoopback()) |
| 229 | require.NoError(t, errlo) |
| 230 | |
| 231 | unspecConn, errconn := net.ListenPacket("udp", ":0") // nolint: noctx |
| 232 | require.NoError(t, errconn) |
| 233 | defer func() { |
| 234 | _ = unspecConn.Close() |
| 235 | }() |
| 236 | muxUnspecDefault := NewUDPMuxDefault(UDPMuxParams{ |
| 237 | UDPConn: unspecConn, |
| 238 | }) |
| 239 | |
| 240 | testCases := []testCase{ |
| 241 | { |
| 242 | name: "mux should not have loopback candidate", |
| 243 | agentConfig: &AgentConfig{ |
| 244 | NetworkTypes: []NetworkType{NetworkTypeUDP4, NetworkTypeUDP6}, |
| 245 | UDPMux: mux, |
| 246 | }, |
| 247 | loExpected: false, |
| 248 | }, |
| 249 | { |
| 250 | name: "mux with loopback should not have loopback candidate", |
| 251 | agentConfig: &AgentConfig{ |
| 252 | NetworkTypes: []NetworkType{NetworkTypeUDP4, NetworkTypeUDP6}, |
| 253 | UDPMux: muxWithLo, |
| 254 | }, |
| 255 | loExpected: true, |
| 256 | }, |
| 257 | { |
| 258 | name: "UDPMuxDefault with unspecified IP should not have loopback candidate", |
| 259 | agentConfig: &AgentConfig{ |
| 260 | NetworkTypes: []NetworkType{NetworkTypeUDP4, NetworkTypeUDP6}, |
| 261 | UDPMux: muxUnspecDefault, |
| 262 | }, |
| 263 | loExpected: false, |
| 264 | }, |
| 265 | { |
| 266 | name: "UDPMuxDefault with unspecified IP should respect agent includeloopback", |
| 267 | agentConfig: &AgentConfig{ |
| 268 | NetworkTypes: []NetworkType{NetworkTypeUDP4, NetworkTypeUDP6}, |
| 269 | UDPMux: muxUnspecDefault, |
| 270 | IncludeLoopback: true, |
| 271 | }, |
| 272 | loExpected: true, |
| 273 | }, |
| 274 | { |
nothing calls this directly
no test coverage detected
searching dependent graphs…