Mercurial > libervia-backend
annotate tests/unit/test_plugin_xep_0176.py @ 4226:3f7ca590a5da
cli (pubsub): use `PEP` when service is not specified in error message.
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 05 Mar 2024 17:31:56 +0100 |
parents | 716dd791be46 |
children | 0fbe5c605eb6 |
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"}, |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
43 "transport_data": { |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 "local_ice_data": { |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
45 "ufrag": "testufrag", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 "pwd": "testpwd", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
47 "candidates": [ |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
48 { |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
49 "id": "candidate_1", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
50 "component_id": 1, |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
51 "foundation": "1", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
52 "address": "192.0.2.1", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
53 "port": 1234, |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
54 "priority": 1, |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
55 "transport": "udp", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
56 "type": "host", |
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 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
65 def test_build_transport(self, host, monkeypatch): |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
66 """ICE data is correctly transformed into transport element""" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
67 xep_0176 = XEP_0176(host) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
68 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
69 ice_data = { |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
70 "ufrag": "user1", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
71 "pwd": "password1", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
72 "candidates": [ |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
73 { |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
74 "component_id": 1, |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
75 "foundation": "1", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
76 "address": "192.168.0.1", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
77 "port": 1234, |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
78 "priority": 100, |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
79 "transport": "udp", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
80 "type": "host", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
81 "generation": "0", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
82 "network": "0", |
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 { |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
85 "component_id": 2, |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
86 "foundation": "1", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
87 "address": "192.168.0.2", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
88 "port": 5678, |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
89 "priority": 100, |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
90 "transport": "udp", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
91 "type": "host", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
92 "generation": "0", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
93 "network": "0", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
94 "rel_addr": "10.0.0.1", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
95 "rel_port": 9012, |
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 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
100 transport_elt = xep_0176.build_transport(ice_data) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
101 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
102 assert transport_elt.name == "transport" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
103 assert transport_elt.uri == NS_JINGLE_ICE_UDP |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
104 assert transport_elt.getAttribute("ufrag") == "user1" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
105 assert transport_elt.getAttribute("pwd") == "password1" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
106 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
107 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
|
108 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
109 assert len(candidates) == len(ice_data["candidates"]) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
110 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
111 for i, candidate_elt in enumerate(candidates): |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
112 ice_candidate = ice_data["candidates"][i] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
113 assert ( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
114 int(candidate_elt.getAttribute("component")) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
115 == ice_candidate["component_id"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
116 ) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
117 assert candidate_elt.getAttribute("foundation") == ice_candidate["foundation"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
118 assert candidate_elt.getAttribute("ip") == ice_candidate["address"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
119 assert int(candidate_elt.getAttribute("port")) == ice_candidate["port"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
120 assert ( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
121 int(candidate_elt.getAttribute("priority")) == ice_candidate["priority"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
122 ) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
123 assert candidate_elt.getAttribute("protocol") == ice_candidate["transport"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
124 assert candidate_elt.getAttribute("type") == ice_candidate["type"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
125 assert candidate_elt.getAttribute("generation") == str( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
126 ice_candidate.get("generation", "0") |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
127 ) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
128 assert candidate_elt.getAttribute("network") == str( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
129 ice_candidate.get("network", "0") |
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 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
132 if "rel_addr" in ice_candidate: |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
133 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
|
134 assert ( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
135 int(candidate_elt.getAttribute("rel-port")) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
136 == ice_candidate["rel_port"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
137 ) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
138 else: |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
139 assert candidate_elt.getAttribute("rel-addr") is None |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
140 assert candidate_elt.getAttribute("rel-port") is None |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
141 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
142 def test_parse_transport(self, host): |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
143 """Transport element is correctly parsed into ICE data""" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
144 xep_0176 = XEP_0176(host) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
145 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
146 transport_elt = xml_tools.parse( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
147 """ |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
148 <transport xmlns="urn:xmpp:jingle:transports:ice-udp:1" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
149 pwd="password1" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
150 ufrag="user1"> |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
151 <candidate component="1" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
152 foundation="1" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
153 generation="0" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
154 id="uuid1" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
155 ip="192.168.0.1" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
156 network="0" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
157 port="1234" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
158 priority="100" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
159 protocol="udp" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
160 type="host" /> |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
161 <candidate component="2" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
162 foundation="1" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
163 generation="0" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
164 id="uuid2" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
165 ip="192.168.0.2" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
166 network="0" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
167 port="5678" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
168 priority="100" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
169 protocol="udp" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
170 type="host" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
171 rel-addr="10.0.0.1" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
172 rel-port="9012" /> |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
173 </transport> |
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 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
177 ice_data = xep_0176.parse_transport(transport_elt) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
178 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
179 assert transport_elt.getAttribute("ufrag") == "user1" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
180 assert transport_elt.getAttribute("pwd") == "password1" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
181 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
182 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
|
183 assert len(candidates) == len(ice_data["candidates"]) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
184 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
185 for i, candidate_elt in enumerate(candidates): |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
186 ice_candidate = ice_data["candidates"][i] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
187 assert ( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
188 int(candidate_elt.getAttribute("component")) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
189 == ice_candidate["component_id"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
190 ) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
191 assert candidate_elt.getAttribute("foundation") == ice_candidate["foundation"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
192 assert candidate_elt.getAttribute("ip") == ice_candidate["address"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
193 assert int(candidate_elt.getAttribute("port")) == ice_candidate["port"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
194 assert ( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
195 int(candidate_elt.getAttribute("priority")) == ice_candidate["priority"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
196 ) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
197 assert candidate_elt.getAttribute("protocol") == ice_candidate["transport"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
198 assert candidate_elt.getAttribute("type") == ice_candidate["type"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
199 assert candidate_elt.getAttribute("generation") == str( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
200 ice_candidate.get("generation", "0") |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
201 ) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
202 assert candidate_elt.getAttribute("network") == str( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
203 ice_candidate.get("network", "0") |
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 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
206 if "rel_addr" in ice_candidate: |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
207 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
|
208 assert ( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
209 int(candidate_elt.getAttribute("rel-port")) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
210 == ice_candidate["rel_port"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
211 ) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
212 else: |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
213 assert candidate_elt.getAttribute("rel-addr") is None |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
214 assert candidate_elt.getAttribute("rel-port") is None |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
215 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
216 @ed |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
217 async def test_jingle_session_init(self, host, client): |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
218 """<transport/> element is built on initiator side during init""" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
219 xep_0176 = XEP_0176(host) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
220 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
221 content_name = "test-content" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
222 session = self.create_mock_session(content_name) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
223 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
224 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
|
225 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
226 expected_transport_elt = xep_0176.build_transport( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
227 session["contents"][content_name]["transport_data"]["local_ice_data"] |
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 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
230 assert transport_elt.toXml() == expected_transport_elt.toXml() |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
231 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
232 @ed |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
233 async def test_jingle_handler(self, host, client): |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
234 """<transport/> element is built on responder side during init""" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
235 xep_0176 = XEP_0176(host) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
236 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
237 content_name = "test-content" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
238 action = "session-initiate" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
239 session = self.create_mock_session(content_name) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
240 transport_elt = xml_tools.parse("<transport/>") |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
241 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
242 returned_transport_elt = await xep_0176.jingle_handler( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
243 client, action, session, content_name, transport_elt |
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 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
246 expected_transport_elt = xep_0176.build_transport( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
247 session["contents"][content_name]["transport_data"]["local_ice_data"] |
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 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
250 assert returned_transport_elt.toXml() == expected_transport_elt.toXml() |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
251 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
252 @ed |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
253 async def test_ice_candidates_add(self, host, client): |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
254 """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
|
255 xep_0176 = XEP_0176(host) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
256 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
257 content_name = "test-content" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
258 session_id = "test-session-id" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
259 media_ice_data_s = { |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
260 "audio": { |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
261 # 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
|
262 # trigger an ICE restart |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
263 "ufrag": "new_testufrag", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
264 "pwd": "new_testpwd", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
265 "candidates": [ |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
266 { |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
267 "component_id": 2, |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
268 "foundation": "2", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
269 "address": "192.0.2.2", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
270 "port": 1235, |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
271 "priority": 2, |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
272 "transport": "udp", |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
273 "type": "host", |
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 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
279 mock_session = self.create_mock_session(content_name) |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
280 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
|
281 xep_0176._j.build_action = MagicMock() |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
282 iq_elt = AsyncMock() |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
283 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
|
284 xep_0176.host.bridge.ice_restart = MagicMock() |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
285 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
286 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
|
287 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
288 xep_0176._j.build_action.assert_called() |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
289 iq_elt.send.assert_called() |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
290 xep_0176.host.bridge.ice_restart.assert_called() |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
291 |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
292 # Checking that local ICE data is updated correctly |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
293 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
|
294 "local_ice_data" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
295 ] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
296 assert updated_local_ice_data["ufrag"] == "new_testufrag" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
297 assert updated_local_ice_data["pwd"] == "new_testpwd" |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
298 assert ( |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
299 updated_local_ice_data["candidates"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
300 == media_ice_data_s["audio"]["candidates"] |
0e3ce379aae3
tests (unit): tests for plugin XEP-0176:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
301 ) |