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

Function TestAgentUpdateOptions

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

Source from the content-addressed store, hash-verified

3093}
3094
3095func TestAgentUpdateOptions(t *testing.T) {
3096 defer test.CheckRoutines(t)()
3097
3098 t.Run("URLs can be updated on a running agent", func(t *testing.T) {
3099 a, err := NewAgent(&AgentConfig{})
3100 require.NoError(t, err)
3101 defer func() {
3102 require.NoError(t, a.Close())
3103 }()
3104
3105 newURLs := []*stun.URI{
3106 {Scheme: SchemeTypeSTUN, Host: "1.2.3.4", Port: 3478, Proto: stun.ProtoTypeUDP},
3107 }
3108
3109 require.NoError(t, a.UpdateOptions(WithUrls(newURLs)))
3110 })
3111
3112 t.Run("UpdateOptions on closed agent fails", func(t *testing.T) {
3113 a, err := NewAgent(&AgentConfig{})
3114 require.NoError(t, err)
3115 require.NoError(t, a.Close())
3116
3117 require.Equal(t, ErrClosed, a.UpdateOptions(WithUrls([]*stun.URI{})))
3118 })
3119
3120 t.Run("Non-updatable options are rejected", func(t *testing.T) { //nolint:varnamelen
3121 agent, err := NewAgent(&AgentConfig{})
3122 require.NoError(t, err)
3123 defer func() {
3124 require.NoError(t, agent.Close())
3125 }()
3126
3127 // All options except WithUrls should be rejected on a running agent.
3128 // When adding new options, add them here if they are not runtime-updatable.
3129 nonUpdatableOptions := map[string]AgentOption{
3130 "WithAddressRewriteRules": WithAddressRewriteRules(AddressRewriteRule{External: []string{"1.2.3.4"}}),
3131 "WithICELite": WithICELite(true),
3132 "WithPortRange": WithPortRange(5000, 6000),
3133 "WithDisconnectedTimeout": WithDisconnectedTimeout(time.Second),
3134 "WithFailedTimeout": WithFailedTimeout(time.Second),
3135 "WithKeepaliveInterval": WithKeepaliveInterval(time.Second),
3136 "WithHostAcceptanceMinWait": WithHostAcceptanceMinWait(time.Second),
3137 "WithSrflxAcceptanceMinWait": WithSrflxAcceptanceMinWait(time.Second),
3138 "WithPrflxAcceptanceMinWait": WithPrflxAcceptanceMinWait(time.Second),
3139 "WithRelayAcceptanceMinWait": WithRelayAcceptanceMinWait(time.Second),
3140 "WithSTUNGatherTimeout": WithSTUNGatherTimeout(time.Second),
3141 "WithIPFilter": WithIPFilter(func(net.IP) bool { return true }),
3142 "WithRemoteIPFilter": WithRemoteIPFilter(func(net.IP) bool { return true }),
3143 "WithNet": WithNet(nil),
3144 "WithMulticastDNSMode": WithMulticastDNSMode(MulticastDNSModeDisabled),
3145 "WithMulticastDNSHostName": WithMulticastDNSHostName("test.local"),
3146 "WithLocalCredentials": WithLocalCredentials("", ""),
3147 "WithTCPMux": WithTCPMux(nil),
3148 "WithUDPMux": WithUDPMux(nil),
3149 "WithUDPMuxSrflx": WithUDPMuxSrflx(nil),
3150 "WithProxyDialer": WithProxyDialer(nil),
3151 "WithMaxBindingRequests": WithMaxBindingRequests(10),
3152 "WithCheckInterval": WithCheckInterval(time.Second),

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
UpdateOptionsMethod · 0.95
NewAgentFunction · 0.85
WithUrlsFunction · 0.85
WithAddressRewriteRulesFunction · 0.85
WithICELiteFunction · 0.85
WithPortRangeFunction · 0.85
WithDisconnectedTimeoutFunction · 0.85
WithFailedTimeoutFunction · 0.85
WithKeepaliveIntervalFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…