MCPcopy Create free account
hub / github.com/pion/dtls / TestInvalidNumericOptionsReturnError

Function TestInvalidNumericOptionsReturnError

options_test.go:226–280  ·  view source on GitHub ↗

TestInvalidNumericOptionsReturnError verifies that invalid numeric values return appropriate errors.

(t *testing.T)

Source from the content-addressed store, hash-verified

224// TestInvalidNumericOptionsReturnError verifies that invalid numeric values
225// return appropriate errors.
226func TestInvalidNumericOptionsReturnError(t *testing.T) {
227 t.Run("InvalidFlightInterval", func(t *testing.T) {
228 _, err := buildClientConfig(WithFlightInterval(0))
229 require.ErrorIs(t, err, errInvalidFlightInterval)
230
231 _, err = buildClientConfig(WithFlightInterval(-time.Second))
232 require.ErrorIs(t, err, errInvalidFlightInterval)
233
234 _, err = buildServerConfig(WithFlightInterval(0))
235 require.ErrorIs(t, err, errInvalidFlightInterval)
236 })
237
238 t.Run("InvalidMTU", func(t *testing.T) {
239 _, err := buildClientConfig(WithMTU(0))
240 require.ErrorIs(t, err, errInvalidMTU)
241
242 _, err = buildClientConfig(WithMTU(-100))
243 require.ErrorIs(t, err, errInvalidMTU)
244
245 _, err = buildServerConfig(WithMTU(0))
246 require.ErrorIs(t, err, errInvalidMTU)
247 })
248
249 t.Run("InvalidReplayProtectionWindow", func(t *testing.T) {
250 _, err := buildClientConfig(WithReplayProtectionWindow(-1))
251 require.ErrorIs(t, err, errInvalidReplayProtectionWindow)
252
253 _, err = buildServerConfig(WithReplayProtectionWindow(-1))
254 require.ErrorIs(t, err, errInvalidReplayProtectionWindow)
255 })
256
257 t.Run("InvalidClientAuthType", func(t *testing.T) {
258 _, err := buildServerConfig(WithClientAuth(ClientAuthType(-1)))
259 require.ErrorIs(t, err, errInvalidClientAuthType)
260
261 _, err = buildServerConfig(WithClientAuth(ClientAuthType(100)))
262 require.ErrorIs(t, err, errInvalidClientAuthType)
263 })
264
265 t.Run("InvalidExtendedMasterSecretType", func(t *testing.T) {
266 _, err := buildClientConfig(WithExtendedMasterSecret(ExtendedMasterSecretType(-1)))
267 require.ErrorIs(t, err, errInvalidExtendedMasterSecretType)
268
269 _, err = buildServerConfig(WithExtendedMasterSecret(ExtendedMasterSecretType(100)))
270 require.ErrorIs(t, err, errInvalidExtendedMasterSecretType)
271 })
272
273 t.Run("InvalidVersions", func(t *testing.T) {
274 _, err := buildClientConfig(withMinVersion(protocol.Version{}))
275 require.ErrorIs(t, err, errUnsupportedProtocolVersion)
276
277 _, err = buildClientConfig(withMaxVersion(protocol.Version{}))
278 require.ErrorIs(t, err, errUnsupportedProtocolVersion)
279 })
280}
281
282// TestDefaultsAreApplied verifies that defaults are applied before options.
283func TestDefaultsAreApplied(t *testing.T) {

Callers

nothing calls this directly

Calls 12

buildClientConfigFunction · 0.85
WithFlightIntervalFunction · 0.85
buildServerConfigFunction · 0.85
WithMTUFunction · 0.85
WithClientAuthFunction · 0.85
ClientAuthTypeTypeAlias · 0.85
WithExtendedMasterSecretFunction · 0.85
ExtendedMasterSecretTypeTypeAlias · 0.85
withMinVersionFunction · 0.85
withMaxVersionFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…