annotate tests/unit/test_plugin_xep_0176.py @ 4069:3d91d0aa68db

tests (unit): Skip XEP-0373 test if gpg can't be imported
author Goffi <goffi@goffi.org>
date Thu, 01 Jun 2023 21:37:34 +0200
parents 0e3ce379aae3
children 4b842c1fb686
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4046
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python3
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
2
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
3 # Libervia: an XMPP client
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # Copyright (C) 2009-2023 Jérôme Poisson (goffi@goffi.org)
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
5
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
6 # This program is free software: you can redistribute it and/or modify
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # it under the terms of the GNU Affero General Public License as published by
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # the Free Software Foundation, either version 3 of the License, or
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # (at your option) any later version.
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
10
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
11 # This program is distributed in the hope that it will be useful,
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # GNU Affero General Public License for more details.
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
15
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
16 # You should have received a copy of the GNU Affero General Public License
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
18
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
19 from unittest.mock import AsyncMock, MagicMock
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
20
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 from pytest import fixture
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
22 from pytest_twisted import ensureDeferred as ed
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
23
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from sat.plugins.plugin_xep_0166 import XEP_0166
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from sat.plugins.plugin_xep_0176 import NS_JINGLE_ICE_UDP, XEP_0176
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
26 from sat.tools import xml_tools
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
27
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
28
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
29 @fixture(autouse=True)
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
30 def no_transport_register(monkeypatch):
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
31 """Do not register the transport in XEP-0166"""
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
32 monkeypatch.setattr(XEP_0166, "register_transport", lambda *a, **kw: None)
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
33
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
34
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
35 class TestXEP0176:
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
36 def create_mock_session(self, content_name):
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 return {
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
38 "id": "test-session-id",
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
39 "contents": {
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
40 content_name: {
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
41 "application_data": {"media": "audio"},
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
42 "transport_data": {
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
43 "local_ice_data": {
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
44 "ufrag": "testufrag",
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
45 "pwd": "testpwd",
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
46 "candidates": [
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
47 {
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
48 "id": "candidate_1",
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
49 "component_id": 1,
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
50 "foundation": "1",
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
51 "address": "192.0.2.1",
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
52 "port": 1234,
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
53 "priority": 1,
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
54 "transport": "udp",
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
55 "type": "host",
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
56 }
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
57 ],
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
58 }
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
59 },
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
60 }
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
61 },
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
62 }
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
63
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
64 def test_build_transport(self, host, monkeypatch):
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
65 """ICE data is correctly transformed into transport element"""
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
66 xep_0176 = XEP_0176(host)
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
67
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
68 ice_data = {
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
69 "ufrag": "user1",
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
70 "pwd": "password1",
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
71 "candidates": [
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
72 {
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
73 "component_id": 1,
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
74 "foundation": "1",
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
75 "address": "192.168.0.1",
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
76 "port": 1234,
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
77 "priority": 100,
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
78 "transport": "udp",
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
79 "type": "host",
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
80 "generation": "0",
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
81 "network": "0",
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
82 },
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
83 {
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
84 "component_id": 2,
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
85 "foundation": "1",
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
86 "address": "192.168.0.2",
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
87 "port": 5678,
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
88 "priority": 100,
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
89 "transport": "udp",
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
90 "type": "host",
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
91 "generation": "0",
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
92 "network": "0",
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
93 "rel_addr": "10.0.0.1",
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
94 "rel_port": 9012,
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
95 },
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
96 ],
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
97 }
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
98
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
99 transport_elt = xep_0176.build_transport(ice_data)
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
100
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
101 assert transport_elt.name == "transport"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
102 assert transport_elt.uri == NS_JINGLE_ICE_UDP
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
103 assert transport_elt.getAttribute("ufrag") == "user1"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
104 assert transport_elt.getAttribute("pwd") == "password1"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
105
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
106 candidates = list(transport_elt.elements(NS_JINGLE_ICE_UDP, "candidate"))
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
107
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
108 assert len(candidates) == len(ice_data["candidates"])
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
109
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
110 for i, candidate_elt in enumerate(candidates):
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
111 ice_candidate = ice_data["candidates"][i]
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
112 assert (
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
113 int(candidate_elt.getAttribute("component"))
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
114 == ice_candidate["component_id"]
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
115 )
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
116 assert candidate_elt.getAttribute("foundation") == ice_candidate["foundation"]
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
117 assert candidate_elt.getAttribute("ip") == ice_candidate["address"]
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
118 assert int(candidate_elt.getAttribute("port")) == ice_candidate["port"]
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
119 assert (
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
120 int(candidate_elt.getAttribute("priority")) == ice_candidate["priority"]
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
121 )
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
122 assert candidate_elt.getAttribute("protocol") == ice_candidate["transport"]
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
123 assert candidate_elt.getAttribute("type") == ice_candidate["type"]
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
124 assert candidate_elt.getAttribute("generation") == str(
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
125 ice_candidate.get("generation", "0")
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
126 )
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
127 assert candidate_elt.getAttribute("network") == str(
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
128 ice_candidate.get("network", "0")
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
129 )
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
130
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
131 if "rel_addr" in ice_candidate:
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
132 assert candidate_elt.getAttribute("rel-addr") == ice_candidate["rel_addr"]
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
133 assert (
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
134 int(candidate_elt.getAttribute("rel-port"))
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
135 == ice_candidate["rel_port"]
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
136 )
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
137 else:
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
138 assert candidate_elt.getAttribute("rel-addr") is None
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
139 assert candidate_elt.getAttribute("rel-port") is None
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
140
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
141 def test_parse_transport(self, host):
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
142 """Transport element is correctly parsed into ICE data"""
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
143 xep_0176 = XEP_0176(host)
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
144
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
145 transport_elt = xml_tools.parse(
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
146 """
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
147 <transport xmlns="urn:xmpp:jingle:transports:ice-udp:1"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
148 pwd="password1"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
149 ufrag="user1">
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
150 <candidate component="1"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
151 foundation="1"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
152 generation="0"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
153 id="uuid1"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
154 ip="192.168.0.1"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
155 network="0"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
156 port="1234"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
157 priority="100"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
158 protocol="udp"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
159 type="host" />
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
160 <candidate component="2"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
161 foundation="1"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
162 generation="0"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
163 id="uuid2"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
164 ip="192.168.0.2"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
165 network="0"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
166 port="5678"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
167 priority="100"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
168 protocol="udp"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
169 type="host"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
170 rel-addr="10.0.0.1"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
171 rel-port="9012" />
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
172 </transport>
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
173 """
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
174 )
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
175
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
176 ice_data = xep_0176.parse_transport(transport_elt)
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
177
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
178 assert transport_elt.getAttribute("ufrag") == "user1"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
179 assert transport_elt.getAttribute("pwd") == "password1"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
180
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
181 candidates = list(transport_elt.elements(NS_JINGLE_ICE_UDP, "candidate"))
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
182 assert len(candidates) == len(ice_data["candidates"])
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
183
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
184 for i, candidate_elt in enumerate(candidates):
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
185 ice_candidate = ice_data["candidates"][i]
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
186 assert (
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
187 int(candidate_elt.getAttribute("component"))
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
188 == ice_candidate["component_id"]
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
189 )
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
190 assert candidate_elt.getAttribute("foundation") == ice_candidate["foundation"]
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
191 assert candidate_elt.getAttribute("ip") == ice_candidate["address"]
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
192 assert int(candidate_elt.getAttribute("port")) == ice_candidate["port"]
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
193 assert (
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
194 int(candidate_elt.getAttribute("priority")) == ice_candidate["priority"]
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
195 )
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
196 assert candidate_elt.getAttribute("protocol") == ice_candidate["transport"]
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
197 assert candidate_elt.getAttribute("type") == ice_candidate["type"]
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
198 assert candidate_elt.getAttribute("generation") == str(
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
199 ice_candidate.get("generation", "0")
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
200 )
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
201 assert candidate_elt.getAttribute("network") == str(
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
202 ice_candidate.get("network", "0")
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
203 )
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
204
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
205 if "rel_addr" in ice_candidate:
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
206 assert candidate_elt.getAttribute("rel-addr") == ice_candidate["rel_addr"]
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
207 assert (
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
208 int(candidate_elt.getAttribute("rel-port"))
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
209 == ice_candidate["rel_port"]
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
210 )
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
211 else:
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
212 assert candidate_elt.getAttribute("rel-addr") is None
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
213 assert candidate_elt.getAttribute("rel-port") is None
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
214
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
215 @ed
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
216 async def test_jingle_session_init(self, host, client):
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
217 """<transport/> element is built on initiator side during init"""
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
218 xep_0176 = XEP_0176(host)
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
219
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
220 content_name = "test-content"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
221 session = self.create_mock_session(content_name)
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
222
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
223 transport_elt = await xep_0176.jingle_session_init(client, session, content_name)
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
224
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
225 expected_transport_elt = xep_0176.build_transport(
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
226 session["contents"][content_name]["transport_data"]["local_ice_data"]
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
227 )
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
228
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
229 assert transport_elt.toXml() == expected_transport_elt.toXml()
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
230
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
231 @ed
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
232 async def test_jingle_handler(self, host, client):
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
233 """<transport/> element is built on responder side during init"""
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
234 xep_0176 = XEP_0176(host)
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
235
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
236 content_name = "test-content"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
237 action = "session-initiate"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
238 session = self.create_mock_session(content_name)
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
239 transport_elt = xml_tools.parse("<transport/>")
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
240
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
241 returned_transport_elt = await xep_0176.jingle_handler(
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
242 client, action, session, content_name, transport_elt
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
243 )
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
244
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
245 expected_transport_elt = xep_0176.build_transport(
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
246 session["contents"][content_name]["transport_data"]["local_ice_data"]
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
247 )
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
248
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
249 assert returned_transport_elt.toXml() == expected_transport_elt.toXml()
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
250
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
251 @ed
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
252 async def test_ice_candidates_add(self, host, client):
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
253 """local new ICE candidates are added, IQ is sent, bridge signal emitted"""
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
254 xep_0176 = XEP_0176(host)
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
255
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
256 content_name = "test-content"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
257 session_id = "test-session-id"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
258 media_ice_data_s = {
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
259 "audio": {
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
260 # we use different "ufrag" and "pwd" than in "create_mock_session" to
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
261 # trigger an ICE restart
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
262 "ufrag": "new_testufrag",
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
263 "pwd": "new_testpwd",
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
264 "candidates": [
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
265 {
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
266 "component_id": 2,
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
267 "foundation": "2",
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
268 "address": "192.0.2.2",
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
269 "port": 1235,
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
270 "priority": 2,
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
271 "transport": "udp",
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
272 "type": "host",
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
273 }
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
274 ],
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
275 }
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
276 }
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
277
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
278 mock_session = self.create_mock_session(content_name)
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
279 xep_0176._j.get_session = MagicMock(return_value=mock_session)
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
280 xep_0176._j.build_action = MagicMock()
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
281 iq_elt = AsyncMock()
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
282 xep_0176._j.build_action.return_value = (iq_elt, None)
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
283 xep_0176.host.bridge.ice_restart = MagicMock()
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
284
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
285 await xep_0176.ice_candidates_add(client, session_id, media_ice_data_s)
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
286
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
287 xep_0176._j.build_action.assert_called()
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
288 iq_elt.send.assert_called()
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
289 xep_0176.host.bridge.ice_restart.assert_called()
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
290
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
291 # Checking that local ICE data is updated correctly
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
292 updated_local_ice_data = mock_session["contents"][content_name]["transport_data"][
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
293 "local_ice_data"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
294 ]
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
295 assert updated_local_ice_data["ufrag"] == "new_testufrag"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
296 assert updated_local_ice_data["pwd"] == "new_testpwd"
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
297 assert (
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
298 updated_local_ice_data["candidates"]
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
299 == media_ice_data_s["audio"]["candidates"]
0e3ce379aae3 tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff changeset
300 )