@@ -21,6 +21,16 @@ defmodule ExICE.Priv.ICEAgentTest do
21
21
end
22
22
end
23
23
24
+ defmodule IfDiscovery.IPV6.Mock do
25
+ @ behaviour ExICE.Priv.IfDiscovery
26
+
27
+ @ impl true
28
+ def getifaddrs ( ) do
29
+ ifs = [ { ~c" mockif" , [ { :flags , [ :up , :running ] } , { :addr , { 64_512 , 0 , 0 , 0 , 0 , 0 , 0 , 1 } } ] } ]
30
+ { :ok , ifs }
31
+ end
32
+ end
33
+
24
34
defmodule Candidate.Mock do
25
35
@ moduledoc false
26
36
@ behaviour ExICE.Priv.Candidate
@@ -68,38 +78,6 @@ defmodule ExICE.Priv.ICEAgentTest do
68
78
end
69
79
end
70
80
71
- describe "gather_candidates/1" do
72
- setup do
73
- ice_agent =
74
- ICEAgent . new (
75
- gathering_state: :new ,
76
- ice_transport_policy: :all ,
77
- controlling_process: self ( ) ,
78
- role: :controlling ,
79
- if_discovery_module: IfDiscovery.Mock ,
80
- transport_module: Transport.Mock
81
- )
82
-
83
- % { ice_agent: ice_agent }
84
- end
85
-
86
- test ~c" Agent with invalid TURN server url doesn't raise an exception" , % {
87
- ice_agent: ice_agent
88
- } do
89
- assert % ICEAgent { gathering_state: :complete } =
90
- ICEAgent . gather_candidates ( % {
91
- ice_agent
92
- | turn_servers: [
93
- % {
94
- url: "invalid.turn.url" ,
95
- username: "user" ,
96
- credential: "pass"
97
- }
98
- ]
99
- } )
100
- end
101
- end
102
-
103
81
describe "add_remote_candidate/2" do
104
82
setup do
105
83
ice_agent =
@@ -1550,6 +1528,46 @@ defmodule ExICE.Priv.ICEAgentTest do
1550
1528
# assert gathering transaction failed
1551
1529
assert ice_agent . gathering_transactions == % { }
1552
1530
end
1531
+
1532
+ test "invalid TURN URL" do
1533
+ ice_agent =
1534
+ ICEAgent . new (
1535
+ controlling_process: self ( ) ,
1536
+ role: :controlling ,
1537
+ transport_module: Transport.Mock ,
1538
+ if_discovery_module: IfDiscovery.Mock ,
1539
+ ice_servers: [
1540
+ % {
1541
+ urls: "turn:invalid.turn.url:#{ @ turn_port } ?transport=udp" ,
1542
+ username: @ turn_username ,
1543
+ credential: @ turn_password
1544
+ }
1545
+ ]
1546
+ )
1547
+ |> ICEAgent . set_remote_credentials ( "someufrag" , "somepwd" )
1548
+
1549
+ assert % ICEAgent { gathering_state: :complete } = ICEAgent . gather_candidates ( ice_agent )
1550
+ end
1551
+
1552
+ test "non-matching IP families" do
1553
+ ice_agent =
1554
+ ICEAgent . new (
1555
+ controlling_process: self ( ) ,
1556
+ role: :controlling ,
1557
+ transport_module: Transport.Mock ,
1558
+ if_discovery_module: IfDiscovery.IPV6.Mock ,
1559
+ ice_servers: [
1560
+ % {
1561
+ urls: "turn:#{ @ turn_ip_str } :#{ @ turn_port } ?transport=udp" ,
1562
+ username: @ turn_username ,
1563
+ credential: @ turn_password
1564
+ }
1565
+ ]
1566
+ )
1567
+ |> ICEAgent . set_remote_credentials ( "someufrag" , "somepwd" )
1568
+
1569
+ assert % ICEAgent { gathering_state: :complete } = ICEAgent . gather_candidates ( ice_agent )
1570
+ end
1553
1571
end
1554
1572
1555
1573
test "relay ice_transport_policy" do
0 commit comments