Mercurial > libervia-backend
annotate tests/unit/test_plugin_xep_0176.py @ 4307:6a0155f410bd
test (unit): add test for plugin XEP-0033:
those replace the legacy XEP-0033 test from libervia/backend/test/test_plugin_xep_0033.py.
rel 450
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 26 Sep 2024 16:12:01 +0200 |
parents | 0fbe5c605eb6 |
children |
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 |
4071
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4046
diff
changeset
|
24 from libervia.backend.plugins.plugin_xep_0166 import XEP_0166 |
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4046
diff
changeset
|
25 from libervia.backend.plugins.plugin_xep_0176 import NS_JINGLE_ICE_UDP, XEP_0176 |
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4046
diff
changeset
|
26 from libervia.backend.tools import xml_tools |
4046
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", |
4213 | 39 "state": XEP_0166.STATE_ACTIVE, |
4046
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 "contents": { |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
41 content_name: { |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
42 "application_data": {"media": "audio"}, |
4232
0fbe5c605eb6
tests (unit/webrtc,XEP-0176, XEP-0234): Fix tests and add webrtc file transfer tests:
Goffi <goffi@goffi.org>
parents:
4213
diff
changeset
|
43 "transport": MagicMock(), |
4046
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 "transport_data": { |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
45 "local_ice_data": { |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 "ufrag": "testufrag", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
47 "pwd": "testpwd", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
48 "candidates": [ |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
49 { |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
50 "id": "candidate_1", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
51 "component_id": 1, |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
52 "foundation": "1", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
53 "address": "192.0.2.1", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
54 "port": 1234, |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
55 "priority": 1, |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
56 "transport": "udp", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
57 "type": "host", |
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 } |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
65 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
66 def test_build_transport(self, host, monkeypatch): |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
67 """ICE data is correctly transformed into transport element""" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
68 xep_0176 = XEP_0176(host) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
69 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
70 ice_data = { |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
71 "ufrag": "user1", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
72 "pwd": "password1", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
73 "candidates": [ |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
74 { |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
75 "component_id": 1, |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
76 "foundation": "1", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
77 "address": "192.168.0.1", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
78 "port": 1234, |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
79 "priority": 100, |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
80 "transport": "udp", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
81 "type": "host", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
82 "generation": "0", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
83 "network": "0", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
84 }, |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
85 { |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
86 "component_id": 2, |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
87 "foundation": "1", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
88 "address": "192.168.0.2", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
89 "port": 5678, |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
90 "priority": 100, |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
91 "transport": "udp", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
92 "type": "host", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
93 "generation": "0", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
94 "network": "0", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
95 "rel_addr": "10.0.0.1", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
96 "rel_port": 9012, |
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 } |
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 transport_elt = xep_0176.build_transport(ice_data) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
102 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
103 assert transport_elt.name == "transport" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
104 assert transport_elt.uri == NS_JINGLE_ICE_UDP |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
105 assert transport_elt.getAttribute("ufrag") == "user1" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
106 assert transport_elt.getAttribute("pwd") == "password1" |
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 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
|
109 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
110 assert len(candidates) == len(ice_data["candidates"]) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
111 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
112 for i, candidate_elt in enumerate(candidates): |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
113 ice_candidate = ice_data["candidates"][i] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
114 assert ( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
115 int(candidate_elt.getAttribute("component")) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
116 == ice_candidate["component_id"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
117 ) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
118 assert candidate_elt.getAttribute("foundation") == ice_candidate["foundation"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
119 assert candidate_elt.getAttribute("ip") == ice_candidate["address"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
120 assert int(candidate_elt.getAttribute("port")) == ice_candidate["port"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
121 assert ( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
122 int(candidate_elt.getAttribute("priority")) == ice_candidate["priority"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
123 ) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
124 assert candidate_elt.getAttribute("protocol") == ice_candidate["transport"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
125 assert candidate_elt.getAttribute("type") == ice_candidate["type"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
126 assert candidate_elt.getAttribute("generation") == str( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
127 ice_candidate.get("generation", "0") |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
128 ) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
129 assert candidate_elt.getAttribute("network") == str( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
130 ice_candidate.get("network", "0") |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
131 ) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
132 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
133 if "rel_addr" in ice_candidate: |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
134 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
|
135 assert ( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
136 int(candidate_elt.getAttribute("rel-port")) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
137 == ice_candidate["rel_port"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
138 ) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
139 else: |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
140 assert candidate_elt.getAttribute("rel-addr") is None |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
141 assert candidate_elt.getAttribute("rel-port") is None |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
142 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
143 def test_parse_transport(self, host): |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
144 """Transport element is correctly parsed into ICE data""" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
145 xep_0176 = XEP_0176(host) |
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_elt = xml_tools.parse( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
148 """ |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
149 <transport xmlns="urn:xmpp:jingle:transports:ice-udp:1" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
150 pwd="password1" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
151 ufrag="user1"> |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
152 <candidate component="1" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
153 foundation="1" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
154 generation="0" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
155 id="uuid1" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
156 ip="192.168.0.1" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
157 network="0" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
158 port="1234" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
159 priority="100" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
160 protocol="udp" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
161 type="host" /> |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
162 <candidate component="2" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
163 foundation="1" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
164 generation="0" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
165 id="uuid2" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
166 ip="192.168.0.2" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
167 network="0" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
168 port="5678" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
169 priority="100" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
170 protocol="udp" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
171 type="host" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
172 rel-addr="10.0.0.1" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
173 rel-port="9012" /> |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
174 </transport> |
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 ) |
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 ice_data = xep_0176.parse_transport(transport_elt) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
179 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
180 assert transport_elt.getAttribute("ufrag") == "user1" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
181 assert transport_elt.getAttribute("pwd") == "password1" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
182 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
183 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
|
184 assert len(candidates) == len(ice_data["candidates"]) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
185 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
186 for i, candidate_elt in enumerate(candidates): |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
187 ice_candidate = ice_data["candidates"][i] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
188 assert ( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
189 int(candidate_elt.getAttribute("component")) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
190 == ice_candidate["component_id"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
191 ) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
192 assert candidate_elt.getAttribute("foundation") == ice_candidate["foundation"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
193 assert candidate_elt.getAttribute("ip") == ice_candidate["address"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
194 assert int(candidate_elt.getAttribute("port")) == ice_candidate["port"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
195 assert ( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
196 int(candidate_elt.getAttribute("priority")) == ice_candidate["priority"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
197 ) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
198 assert candidate_elt.getAttribute("protocol") == ice_candidate["transport"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
199 assert candidate_elt.getAttribute("type") == ice_candidate["type"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
200 assert candidate_elt.getAttribute("generation") == str( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
201 ice_candidate.get("generation", "0") |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
202 ) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
203 assert candidate_elt.getAttribute("network") == str( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
204 ice_candidate.get("network", "0") |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
205 ) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
206 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
207 if "rel_addr" in ice_candidate: |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
208 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
|
209 assert ( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
210 int(candidate_elt.getAttribute("rel-port")) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
211 == ice_candidate["rel_port"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
212 ) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
213 else: |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
214 assert candidate_elt.getAttribute("rel-addr") is None |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
215 assert candidate_elt.getAttribute("rel-port") is None |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
216 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
217 @ed |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
218 async def test_jingle_session_init(self, host, client): |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
219 """<transport/> element is built on initiator side during init""" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
220 xep_0176 = XEP_0176(host) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
221 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
222 content_name = "test-content" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
223 session = self.create_mock_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 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
|
226 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
227 expected_transport_elt = xep_0176.build_transport( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
228 session["contents"][content_name]["transport_data"]["local_ice_data"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
229 ) |
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 assert transport_elt.toXml() == expected_transport_elt.toXml() |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
232 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
233 @ed |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
234 async def test_jingle_handler(self, host, client): |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
235 """<transport/> element is built on responder side during init""" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
236 xep_0176 = XEP_0176(host) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
237 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
238 content_name = "test-content" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
239 action = "session-initiate" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
240 session = self.create_mock_session(content_name) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
241 transport_elt = xml_tools.parse("<transport/>") |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
242 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
243 returned_transport_elt = await xep_0176.jingle_handler( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
244 client, action, session, content_name, transport_elt |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
245 ) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
246 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
247 expected_transport_elt = xep_0176.build_transport( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
248 session["contents"][content_name]["transport_data"]["local_ice_data"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
249 ) |
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 assert returned_transport_elt.toXml() == expected_transport_elt.toXml() |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
252 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
253 @ed |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
254 async def test_ice_candidates_add(self, host, client): |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
255 """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
|
256 xep_0176 = XEP_0176(host) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
257 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
258 content_name = "test-content" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
259 session_id = "test-session-id" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
260 media_ice_data_s = { |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
261 "audio": { |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
262 # 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
|
263 # trigger an ICE restart |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
264 "ufrag": "new_testufrag", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
265 "pwd": "new_testpwd", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
266 "candidates": [ |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
267 { |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
268 "component_id": 2, |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
269 "foundation": "2", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
270 "address": "192.0.2.2", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
271 "port": 1235, |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
272 "priority": 2, |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
273 "transport": "udp", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
274 "type": "host", |
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 } |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
279 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
280 mock_session = self.create_mock_session(content_name) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
281 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
|
282 xep_0176._j.build_action = MagicMock() |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
283 iq_elt = AsyncMock() |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
284 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
|
285 xep_0176.host.bridge.ice_restart = MagicMock() |
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 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
|
288 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
289 xep_0176._j.build_action.assert_called() |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
290 iq_elt.send.assert_called() |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
291 xep_0176.host.bridge.ice_restart.assert_called() |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
292 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
293 # Checking that local ICE data is updated correctly |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
294 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
|
295 "local_ice_data" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
296 ] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
297 assert updated_local_ice_data["ufrag"] == "new_testufrag" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
298 assert updated_local_ice_data["pwd"] == "new_testpwd" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
299 assert ( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
300 updated_local_ice_data["candidates"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
301 == media_ice_data_s["audio"]["candidates"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
302 ) |