Mercurial > libervia-backend
annotate tests/unit/test_plugin_xep_0320.py @ 4340:ea72364131d5 default tip @
doc (components): Update Email Gateway documentation:
A section has been added to explain how attachments are handled.
fix 453
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 03 Dec 2024 00:53:18 +0100 |
parents | f1d0cde61af7 |
children |
rev | line source |
---|---|
4049 | 1 #!/usr/bin/env python3 |
2 | |
3 # Libervia: an XMPP client | |
4 # Copyright (C) 2009-2023 Jérôme Poisson (goffi@goffi.org) | |
5 | |
6 # This program is free software: you can redistribute it and/or modify | |
7 # it under the terms of the GNU Affero General Public License as published by | |
8 # the Free Software Foundation, either version 3 of the License, or | |
9 # (at your option) any later version. | |
10 | |
11 # This program is distributed in the hope that it will be useful, | |
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 # GNU Affero General Public License for more details. | |
15 | |
16 # You should have received a copy of the GNU Affero General Public License | |
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | |
19 from twisted.words.xish import domish | |
20 | |
4071
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4049
diff
changeset
|
21 from libervia.backend.plugins.plugin_xep_0320 import NS_JINGLE_DTLS, XEP_0320 |
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4049
diff
changeset
|
22 from libervia.backend.tools import xml_tools |
4049 | 23 |
24 | |
25 class TestXEP0320: | |
26 def test_parse_transport_trigger(self, host): | |
27 """<transport> element is parsed correctly in trigger""" | |
28 xep_0320 = XEP_0320(host) | |
29 | |
30 transport_elt = xml_tools.parse( | |
31 f"<transport><fingerprint xmlns='{NS_JINGLE_DTLS}' hash='sha-256' " | |
32 "setup='active'>6D:8F:6A:53:A3:7E:10:B2:58:16:AB:A3:92:6F:8A:5B:2D:55:1C:FB:" | |
33 "2F:E3:6E:94:FE:4F:4E:FE:D4:77:49:B6</fingerprint></transport>" | |
34 ) | |
35 | |
36 ice_data = {} | |
37 result = xep_0320._parse_transport_trigger(transport_elt, ice_data) | |
38 | |
39 expected_ice_data = { | |
40 "fingerprint": { | |
41 "hash": "sha-256", | |
42 "setup": "active", | |
4285
f1d0cde61af7
tests (unit): fix tests + black reformatting.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
43 "fingerprint": "6D:8F:6A:53:A3:7E:10:B2:58:16:AB:A3:92:6F:8A:5B:2D:55:1C:" |
4049 | 44 "FB:2F:E3:6E:94:FE:4F:4E:FE:D4:77:49:B6", |
45 }, | |
46 } | |
47 | |
48 assert ice_data == expected_ice_data | |
49 assert result | |
50 | |
51 def test_build_transport(self, host): | |
52 """<transport> element is buid correctly in trigger""" | |
53 xep_0320 = XEP_0320(host) | |
54 | |
55 transport_elt = domish.Element((None, "transport")) | |
56 | |
57 ice_data = { | |
58 "fingerprint": { | |
59 "hash": "sha-256", | |
60 "setup": "active", | |
4285
f1d0cde61af7
tests (unit): fix tests + black reformatting.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
61 "fingerprint": "6D:8F:6A:53:A3:7E:10:B2:58:16:AB:A3:92:6F:8A:5B:2D:55:1C:" |
4049 | 62 "FB:2F:E3:6E:94:FE:4F:4E:FE:D4:77:49:B6", |
63 }, | |
64 } | |
65 | |
66 result = xep_0320._build_transport_trigger(transport_elt, ice_data) | |
67 | |
68 expected_transport_elt = xml_tools.parse( | |
69 f"<transport><fingerprint xmlns='{NS_JINGLE_DTLS}' hash='sha-256' " | |
70 "setup='active'>6D:8F:6A:53:A3:7E:10:B2:58:16:AB:A3:92:6F:8A:5B:2D:55:1C:FB:" | |
4285
f1d0cde61af7
tests (unit): fix tests + black reformatting.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
71 "2F:E3:6E:94:FE:4F:4E:FE:D4:77:49:B6</fingerprint></transport>" |
f1d0cde61af7
tests (unit): fix tests + black reformatting.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
72 "" |
4049 | 73 ) |
74 | |
75 assert transport_elt.toXml() == expected_transport_elt.toXml() | |
76 assert result |