Mercurial > libervia-backend
annotate tests/e2e/libervia-cli/test_libervia-cli.py @ 4052:2ced30f6d5de
plugin XEP-0166, 0176, 0234: minor renaming + type hints
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 29 May 2023 13:32:19 +0200 |
parents | 524856bd7b19 |
children | 4b842c1fb686 |
rev | line source |
---|---|
3415 | 1 #!/usr/bin/env python3 |
2 | |
3480
7550ae9cfbac
Renamed the project from "Salut à Toi" to "Libervia":
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
3 # Libervia: an XMPP client |
3479 | 4 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org) |
3415 | 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 | |
3962
2d9d0b77e82b
tests (e2e/cli): add a test for Pubsub Signing:
Goffi <goffi@goffi.org>
parents:
3946
diff
changeset
|
19 import json |
3415 | 20 import os |
21 import shutil | |
3946
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
22 from time import sleep |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
23 |
3415 | 24 import sh |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
25 from sh import li |
3415 | 26 |
3962
2d9d0b77e82b
tests (e2e/cli): add a test for Pubsub Signing:
Goffi <goffi@goffi.org>
parents:
3946
diff
changeset
|
27 import pytest |
2d9d0b77e82b
tests (e2e/cli): add a test for Pubsub Signing:
Goffi <goffi@goffi.org>
parents:
3946
diff
changeset
|
28 from sat.plugins.plugin_sec_oxps import NS_OXPS |
3974
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
29 from sat.plugins.plugin_sec_pte import NS_PTE |
3962
2d9d0b77e82b
tests (e2e/cli): add a test for Pubsub Signing:
Goffi <goffi@goffi.org>
parents:
3946
diff
changeset
|
30 from sat.plugins.plugin_xep_0277 import NS_ATOM |
2d9d0b77e82b
tests (e2e/cli): add a test for Pubsub Signing:
Goffi <goffi@goffi.org>
parents:
3946
diff
changeset
|
31 from sat.tools.common import uri |
2d9d0b77e82b
tests (e2e/cli): add a test for Pubsub Signing:
Goffi <goffi@goffi.org>
parents:
3946
diff
changeset
|
32 |
3415 | 33 |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
34 if os.getenv("LIBERVIA_TEST_ENV_E2E") is None: |
3415 | 35 pytest.skip( |
36 "skipping end-to-end tests, we are not in a test environment", | |
37 allow_module_level=True | |
38 ) | |
39 | |
40 | |
41 pytestmark = pytest.mark.usefixtures("test_profiles") | |
42 | |
43 | |
44 class TestInstall: | |
45 | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
46 def test_li_can_run(self): |
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
47 li("--version") |
3415 | 48 |
49 | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
50 class TestLiberviaCliAccount: |
3415 | 51 |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
52 def test_create_and_delete(self, li_json): |
3415 | 53 """Create an account in-band, connect it, then delete it and its profile""" |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
54 li.account.create( |
3415 | 55 "test_create@server1.test", |
56 "test", | |
57 profile="test_create", | |
58 host="server1.test" | |
59 ) | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
60 profiles = li_json.profile.list() |
3415 | 61 assert "test_create" in profiles |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
62 li.profile.connect(connect=True, profile="test_create") |
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
63 li.account.delete(profile="test_create", force=True) |
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
64 li.profile.delete("test_create", force=True) |
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
65 profiles = li_json.profile.list() |
3415 | 66 assert "test_create" not in profiles |
67 | |
68 | |
69 @pytest.mark.usefixtures("pubsub_nodes") | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
70 class TestLiberviaCliPubsub: |
3415 | 71 |
72 def test_node_create_info_delete(self): | |
73 node_name = "tmp_node" | |
74 with pytest.raises(sh.ErrorReturnCode_16): | |
75 # the node should not exist | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
76 li.pubsub.node.info(node=node_name) |
3415 | 77 try: |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
78 li.pubsub.node.create(node=node_name) |
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
79 # if node exist as expected, following command won't raise an exception |
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
80 metadata = li.pubsub.node.info(node=node_name) |
3415 | 81 assert len(metadata.strip()) |
82 finally: | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
83 li.pubsub.node.delete(node=node_name, force=True) |
3415 | 84 |
85 with pytest.raises(sh.ErrorReturnCode_16): | |
86 # the node should not exist anymore | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
87 li.pubsub.node.info(node=node_name) |
3415 | 88 |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
89 def test_set_get_delete_purge(self, li_elt): |
3415 | 90 content = "test item" |
91 payload = f"<test>{content}</test>" | |
92 | |
93 # we create 3 items and check them | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
94 item1_id = li.pubsub.set(node="test", quiet=True, _in=payload) |
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
95 item2_id = li.pubsub.set(node="test", quiet=True, _in=payload) |
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
96 item3_id = li.pubsub.set(node="test", quiet=True, _in=payload) |
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
97 parsed_elt = li_elt.pubsub.get(node="test", item=item1_id) |
3415 | 98 payload = parsed_elt.firstChildElement() |
99 assert payload.name == 'test' | |
100 assert str(payload) == content | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
101 parsed_elt = li_elt.pubsub.get(node="test", item=item2_id) |
3415 | 102 payload = parsed_elt.firstChildElement() |
103 assert payload.name == 'test' | |
104 assert str(payload) == content | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
105 parsed_elt = li_elt.pubsub.get(node="test", item=item3_id) |
3415 | 106 payload = parsed_elt.firstChildElement() |
107 assert payload.name == 'test' | |
108 assert str(payload) == content | |
109 | |
110 # deleting first item should work | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
111 li.pubsub.delete(node="test", item=item1_id, force=True) |
3415 | 112 with pytest.raises(sh.ErrorReturnCode_16): |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
113 li.pubsub.get(node="test", item=item1_id) |
3415 | 114 |
115 # there must be a least item2 and item3 in the node | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
116 node_items = li_elt.pubsub.get(node="test") |
3415 | 117 assert len(list(node_items.elements())) >= 2 |
118 | |
119 # after purge, node must be empty | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
120 li.pubsub.node.purge(node="test", force=True) |
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
121 node_items = li_elt.pubsub.get(node="test") |
3415 | 122 assert len(list(node_items.elements())) == 0 |
123 | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
124 def test_edit(self, editor, li_elt): |
3415 | 125 content = "original item" |
126 payload = f"<test>{content}</test>" | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
127 item_id = li.pubsub.set(node="test", quiet=True, _in=payload) |
3415 | 128 editor.set_filter('content.replace("original", "edited")') |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
129 li.pubsub.edit(node="test", item=item_id, _env=editor.env) |
3415 | 130 assert "original item" in editor.original_content |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
131 parsed_elt = li_elt.pubsub.get(node="test", item=item_id) |
3415 | 132 edited_payload = parsed_elt.firstChildElement() |
133 expected_edited_content = content.replace("original", "edited") | |
134 assert edited_payload.name == 'test' | |
135 assert str(edited_payload) == expected_edited_content | |
136 | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
137 def test_affiliations(self, li_json): |
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
138 affiliations = li_json.pubsub.affiliations() |
3415 | 139 assert affiliations["test"] == "owner" |
140 | |
141 def test_uri(self): | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
142 built_uri = li.pubsub.uri( |
3415 | 143 service="pubsub.example.net", node="some_node" |
144 ).strip() | |
145 assert built_uri == "xmpp:pubsub.example.net?;node=some_node" | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
146 built_uri = li.pubsub.uri( |
3415 | 147 service="pubsub.example.net", node="some_node", item="some_item" |
148 ).strip() | |
149 assert built_uri == "xmpp:pubsub.example.net?;node=some_node;item=some_item" | |
150 | |
3674
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
151 def test_cache_search(self, li_json): |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
152 """A Full-Text Search query can be done""" |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
153 sk_txt = "this is a blog post about Slovakia" |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
154 fr_txt = "this is a blog post about France" |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
155 nc_txt = "this is a blog post about New Caledonia" |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
156 au_txt = "this is a blog post about Australia" |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
157 li.blog.set( |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
158 "-t", "travel", "-t", "europe", |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
159 _in=sk_txt, |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
160 syntax="markdown" |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
161 ) |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
162 li.blog.set( |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
163 "-t", "travel", "-t", "europe", |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
164 _in=fr_txt, |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
165 syntax="markdown" |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
166 ) |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
167 li.blog.set( |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
168 "-t", "travel", "-t", "south pacific", |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
169 _in=nc_txt, |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
170 syntax="markdown" |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
171 ) |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
172 li.blog.set( |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
173 "-t", "travel", "-t", "south pacific", |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
174 _in="this is a blog post about Australia", |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
175 title=au_txt, |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
176 syntax="markdown" |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
177 ) |
3769
a75874df92b8
tests (e2e/cli/cache_search): make the test more resilient:
Goffi <goffi@goffi.org>
parents:
3731
diff
changeset
|
178 # we get the blog to activate the cache for it |
3674
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
179 li.blog.get(max_items=1) |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
180 # FTS |
3769
a75874df92b8
tests (e2e/cli/cache_search): make the test more resilient:
Goffi <goffi@goffi.org>
parents:
3731
diff
changeset
|
181 found = [] |
a75874df92b8
tests (e2e/cli/cache_search): make the test more resilient:
Goffi <goffi@goffi.org>
parents:
3731
diff
changeset
|
182 for __ in range(5): |
a75874df92b8
tests (e2e/cli/cache_search): make the test more resilient:
Goffi <goffi@goffi.org>
parents:
3731
diff
changeset
|
183 found = li_json.pubsub.cache.search( |
a75874df92b8
tests (e2e/cli/cache_search): make the test more resilient:
Goffi <goffi@goffi.org>
parents:
3731
diff
changeset
|
184 type="blog", fts='Slovakia OR "New Caledonia"' |
a75874df92b8
tests (e2e/cli/cache_search): make the test more resilient:
Goffi <goffi@goffi.org>
parents:
3731
diff
changeset
|
185 ) |
a75874df92b8
tests (e2e/cli/cache_search): make the test more resilient:
Goffi <goffi@goffi.org>
parents:
3731
diff
changeset
|
186 if found: |
a75874df92b8
tests (e2e/cli/cache_search): make the test more resilient:
Goffi <goffi@goffi.org>
parents:
3731
diff
changeset
|
187 break |
a75874df92b8
tests (e2e/cli/cache_search): make the test more resilient:
Goffi <goffi@goffi.org>
parents:
3731
diff
changeset
|
188 else: |
a75874df92b8
tests (e2e/cli/cache_search): make the test more resilient:
Goffi <goffi@goffi.org>
parents:
3731
diff
changeset
|
189 # retrieving blog triggers the caching, but it's done in parallel |
a75874df92b8
tests (e2e/cli/cache_search): make the test more resilient:
Goffi <goffi@goffi.org>
parents:
3731
diff
changeset
|
190 # thus we may have nothing in cache yet |
a75874df92b8
tests (e2e/cli/cache_search): make the test more resilient:
Goffi <goffi@goffi.org>
parents:
3731
diff
changeset
|
191 sleep(0.5) |
3674
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
192 assert len(found) == 2 |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
193 assert all(i["content"] in (sk_txt, nc_txt) for i in found) |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
194 # search by field |
3769
a75874df92b8
tests (e2e/cli/cache_search): make the test more resilient:
Goffi <goffi@goffi.org>
parents:
3731
diff
changeset
|
195 found = li_json.pubsub.cache.search( |
a75874df92b8
tests (e2e/cli/cache_search): make the test more resilient:
Goffi <goffi@goffi.org>
parents:
3731
diff
changeset
|
196 "-F", "tags", "overlap", "travel", type="blog" |
a75874df92b8
tests (e2e/cli/cache_search): make the test more resilient:
Goffi <goffi@goffi.org>
parents:
3731
diff
changeset
|
197 ) |
3674
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
198 assert len(found) == 4 |
3769
a75874df92b8
tests (e2e/cli/cache_search): make the test more resilient:
Goffi <goffi@goffi.org>
parents:
3731
diff
changeset
|
199 found = li_json.pubsub.cache.search( |
a75874df92b8
tests (e2e/cli/cache_search): make the test more resilient:
Goffi <goffi@goffi.org>
parents:
3731
diff
changeset
|
200 "-F", "tags", "overlap", "europe", type="blog" |
a75874df92b8
tests (e2e/cli/cache_search): make the test more resilient:
Goffi <goffi@goffi.org>
parents:
3731
diff
changeset
|
201 ) |
3674
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
202 assert len(found) == 2 |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
203 assert all(i["content"] in (sk_txt, fr_txt) for i in found) |
3769
a75874df92b8
tests (e2e/cli/cache_search): make the test more resilient:
Goffi <goffi@goffi.org>
parents:
3731
diff
changeset
|
204 found = li_json.pubsub.cache.search( |
a75874df92b8
tests (e2e/cli/cache_search): make the test more resilient:
Goffi <goffi@goffi.org>
parents:
3731
diff
changeset
|
205 "-F", "tags", "ioverlap", "SOUTH PACIFIC", type="blog" |
a75874df92b8
tests (e2e/cli/cache_search): make the test more resilient:
Goffi <goffi@goffi.org>
parents:
3731
diff
changeset
|
206 ) |
3674
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
207 assert all(i["content"] in (nc_txt, au_txt) for i in found) |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
208 |
3415 | 209 |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
210 class TestLiberviaCliBlog: |
3415 | 211 MICROBLOG_NS = "urn:xmpp:microblog:0" |
212 | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
213 def test_set_get(self, li_json): |
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
214 li.blog.set(_in="markdown **bold** [link](https://example.net)") |
3731
7e51cfc36d4e
tests (e2e/CLI/set_get): fix RSM request:
Goffi <goffi@goffi.org>
parents:
3674
diff
changeset
|
215 item_data = li_json.blog.get(max=1, before="") |
3415 | 216 item = item_data[0][0] |
217 metadata = item_data[1] | |
218 assert metadata['service'] == "account1@server1.test" | |
219 assert metadata['node'] == self.MICROBLOG_NS | |
220 assert metadata['rsm'].keys() <= {"first", "last", "index", "count"} | |
221 item_id = item['id'] | |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3974
diff
changeset
|
222 expected_uri = uri.build_xmpp_uri( |
3415 | 223 'pubsub', subtype="microblog", path="account1@server1.test", |
224 node=self.MICROBLOG_NS, item=item_id | |
225 ) | |
226 assert item['uri'] == expected_uri | |
227 assert item['content_xhtml'] == ( | |
228 '<div><p>markdown <strong>bold</strong> ' | |
229 '<a href="https://example.net">link</a></p></div>' | |
230 ) | |
231 assert isinstance(item['published'], int) | |
232 assert isinstance(item['updated'], int) | |
233 assert isinstance(item['comments'], list) | |
234 assert isinstance(item['tags'], list) | |
235 assert item['author'] == 'account1' | |
236 assert item['author_jid'] == 'account1@server1.test' | |
237 | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
238 def test_edit(self, editor, li_json): |
3415 | 239 payload_md = "content in **markdown**" |
240 editor.set_filter(repr(payload_md)) | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
241 li.blog.edit(_env=editor.env) |
3415 | 242 assert len(editor.original_content) == 0 |
243 assert editor.new_content == payload_md | |
3658
9e491b2bab88
test (e2e/cli): use `max_items` instead of `max` when retrieving blog items:
Goffi <goffi@goffi.org>
parents:
3498
diff
changeset
|
244 items_data = li_json.blog.get(max_items=1) |
3415 | 245 last_item = items_data[0][0] |
246 last_item_id = last_item['id'] | |
247 assert last_item['content'] == "content in markdown" | |
248 assert last_item['content_xhtml'] == ( | |
249 "<div><p>content in <strong>markdown</strong></p></div>" | |
250 ) | |
251 editor.set_filter('f"{content} extended"') | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
252 li.blog.edit("--last-item", _env=editor.env) |
3415 | 253 assert editor.original_content == payload_md |
254 assert editor.new_content == f"{payload_md} extended" | |
3658
9e491b2bab88
test (e2e/cli): use `max_items` instead of `max` when retrieving blog items:
Goffi <goffi@goffi.org>
parents:
3498
diff
changeset
|
255 items_data = li_json.blog.get(max_items=1) |
3415 | 256 last_item = items_data[0][0] |
257 # we check that the id hasn't been modified | |
258 assert last_item['id'] == last_item_id | |
259 assert last_item['content'] == "content in markdown extended" | |
260 assert last_item['content_xhtml'] == ( | |
261 "<div><p>content in <strong>markdown</strong> extended</p></div>" | |
262 ) | |
263 | |
264 | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
265 class TestLiberviaCliFile: |
3415 | 266 |
267 def test_upload_get(self, fake_file): | |
268 source_file = fake_file.size(10240) | |
269 source_file_hash = fake_file.get_source_hash(source_file) | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
270 upload_url = li.file.upload(source_file).strip() |
3415 | 271 |
272 dest_file = fake_file.new_dest_file() | |
273 try: | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
274 li.file.get(upload_url, dest_file=dest_file) |
3415 | 275 dest_file_hash = fake_file.get_dest_hash(dest_file) |
276 finally: | |
277 dest_file.unlink() | |
278 | |
279 assert source_file_hash == dest_file_hash | |
280 | |
281 def test_send_receive(self, fake_file): | |
282 source_file = fake_file.size(10240) | |
283 source_file_hash = fake_file.get_source_hash(source_file) | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
284 send_cmd = li.file.send(source_file, "account1@server2.test", _bg=True) |
3415 | 285 dest_path = fake_file.dest_files / "test_send_receive" |
286 dest_path.mkdir() | |
287 try: | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
288 li.file.receive( |
3415 | 289 "account1@server1.test", profile="account1_s2", path=dest_path) |
290 dest_file = dest_path / source_file.name | |
291 dest_file_hash = fake_file.get_dest_hash(dest_file) | |
292 finally: | |
293 shutil.rmtree(dest_path) | |
294 send_cmd.wait() | |
295 | |
296 assert source_file_hash == dest_file_hash | |
3946
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
297 |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
298 |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
299 class TestE2EEncryption: |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
300 |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
301 def test_pubsub_encryption_oxps(self, li_elt): |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
302 secret_blog = "this is a secret blog post" |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
303 node = "e2ee_blog" |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
304 li.blog.set(_in=secret_blog, node="e2ee_blog", item="test_e2ee", encrypt=True) |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
305 |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
306 # the item should be transparently decrypted |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
307 parsed_decrypted = li_elt.pubsub.get( |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
308 node=node, item="test_e2ee", no_cache=True |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
309 ) |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
310 entry_elt = parsed_decrypted.firstChildElement() |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
311 assert entry_elt.name == "entry" |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
312 assert entry_elt.uri == NS_ATOM |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
313 assert secret_blog in parsed_decrypted.toXml() |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
314 |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
315 # with --no-decrypt, we should have the encrypted item |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
316 parsed_ori_item = li_elt.pubsub.get( |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
317 node=node, item="test_e2ee", no_decrypt=True, no_cache=True |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
318 ) |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
319 encrypted_elt = parsed_ori_item.firstChildElement() |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
320 assert encrypted_elt.name == "encrypted" |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
321 assert encrypted_elt.uri == NS_OXPS |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
322 # the body must not be readable in plain text |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
323 assert secret_blog not in parsed_ori_item.toXml() |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
324 |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
325 def test_pubsub_secrets_sharing_oxps(self, li_elt): |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
326 secret_blog = "this is a secret blog post" |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
327 node="secret_sharing" |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
328 |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
329 li.blog.set(_in=secret_blog, node=node, item="test_e2ee", encrypt=True) |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
330 |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
331 # the item must not be decrypted for account1_s2 (secret is not known) |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
332 parsed_item = li_elt.pubsub.get( |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
333 service="account1@server1.test", node=node, item="test_e2ee", no_cache=True, |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
334 profile="account1_s2" |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
335 ) |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
336 encrypted_elt = parsed_item.firstChildElement() |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
337 assert encrypted_elt.name == "encrypted" |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
338 assert encrypted_elt.uri == NS_OXPS |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
339 # the body must not be readable in plain text |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
340 assert secret_blog not in parsed_item.toXml() |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
341 |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
342 # we share the secrets |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
343 li.pubsub.secret.share("account1@server2.test", service="account1@server1.test", node=node) |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
344 |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
345 # and get the item again |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
346 parsed_item = li_elt.pubsub.get( |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
347 service="account1@server1.test", node=node, item="test_e2ee", no_cache=True, |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
348 profile="account1_s2" |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
349 ) |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
350 # now it should be decrypted |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
351 entry_elt = parsed_item.firstChildElement() |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
352 assert entry_elt.name == "entry" |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
353 assert entry_elt.uri == NS_ATOM |
f2a5936f2496
tests (e2e/cli): add test for pubsub encryption:
Goffi <goffi@goffi.org>
parents:
3769
diff
changeset
|
354 assert secret_blog in parsed_item.toXml() |
3962
2d9d0b77e82b
tests (e2e/cli): add a test for Pubsub Signing:
Goffi <goffi@goffi.org>
parents:
3946
diff
changeset
|
355 |
2d9d0b77e82b
tests (e2e/cli): add a test for Pubsub Signing:
Goffi <goffi@goffi.org>
parents:
3946
diff
changeset
|
356 def test_pubsub_signature(self, li_json): |
2d9d0b77e82b
tests (e2e/cli): add a test for Pubsub Signing:
Goffi <goffi@goffi.org>
parents:
3946
diff
changeset
|
357 """A pubsub item can be signed, and the signature can be verified""" |
2d9d0b77e82b
tests (e2e/cli): add a test for Pubsub Signing:
Goffi <goffi@goffi.org>
parents:
3946
diff
changeset
|
358 body = "this message is signed" |
2d9d0b77e82b
tests (e2e/cli): add a test for Pubsub Signing:
Goffi <goffi@goffi.org>
parents:
3946
diff
changeset
|
359 service="account1@server1.test" |
2d9d0b77e82b
tests (e2e/cli): add a test for Pubsub Signing:
Goffi <goffi@goffi.org>
parents:
3946
diff
changeset
|
360 node ="blog_signing" |
2d9d0b77e82b
tests (e2e/cli): add a test for Pubsub Signing:
Goffi <goffi@goffi.org>
parents:
3946
diff
changeset
|
361 item="signed_item" |
2d9d0b77e82b
tests (e2e/cli): add a test for Pubsub Signing:
Goffi <goffi@goffi.org>
parents:
3946
diff
changeset
|
362 li.blog.set(_in=body, service=service, node=node, item=item, sign=True) |
2d9d0b77e82b
tests (e2e/cli): add a test for Pubsub Signing:
Goffi <goffi@goffi.org>
parents:
3946
diff
changeset
|
363 attachments = li_json.pubsub.attachments.get( |
2d9d0b77e82b
tests (e2e/cli): add a test for Pubsub Signing:
Goffi <goffi@goffi.org>
parents:
3946
diff
changeset
|
364 service=service, node=node, item=item |
2d9d0b77e82b
tests (e2e/cli): add a test for Pubsub Signing:
Goffi <goffi@goffi.org>
parents:
3946
diff
changeset
|
365 ) |
2d9d0b77e82b
tests (e2e/cli): add a test for Pubsub Signing:
Goffi <goffi@goffi.org>
parents:
3946
diff
changeset
|
366 assert len(attachments) == 1 |
2d9d0b77e82b
tests (e2e/cli): add a test for Pubsub Signing:
Goffi <goffi@goffi.org>
parents:
3946
diff
changeset
|
367 attachment = attachments[0] |
2d9d0b77e82b
tests (e2e/cli): add a test for Pubsub Signing:
Goffi <goffi@goffi.org>
parents:
3946
diff
changeset
|
368 assert attachment["from"] == "account1@server1.test" |
2d9d0b77e82b
tests (e2e/cli): add a test for Pubsub Signing:
Goffi <goffi@goffi.org>
parents:
3946
diff
changeset
|
369 signature_json = attachment["signature"] |
2d9d0b77e82b
tests (e2e/cli): add a test for Pubsub Signing:
Goffi <goffi@goffi.org>
parents:
3946
diff
changeset
|
370 sign_data = li_json.pubsub.signature.check( |
2d9d0b77e82b
tests (e2e/cli): add a test for Pubsub Signing:
Goffi <goffi@goffi.org>
parents:
3946
diff
changeset
|
371 json.dumps(signature_json), service=service, node=node, item=item, |
2d9d0b77e82b
tests (e2e/cli): add a test for Pubsub Signing:
Goffi <goffi@goffi.org>
parents:
3946
diff
changeset
|
372 ) |
2d9d0b77e82b
tests (e2e/cli): add a test for Pubsub Signing:
Goffi <goffi@goffi.org>
parents:
3946
diff
changeset
|
373 assert sign_data["signer"] == "account1@server1.test" |
2d9d0b77e82b
tests (e2e/cli): add a test for Pubsub Signing:
Goffi <goffi@goffi.org>
parents:
3946
diff
changeset
|
374 assert sign_data["validated"] == True |
2d9d0b77e82b
tests (e2e/cli): add a test for Pubsub Signing:
Goffi <goffi@goffi.org>
parents:
3946
diff
changeset
|
375 assert all(t == "undecided" for t in sign_data["trusts"].values()) |
3971
9b1d74a6b48c
tests (e2e/cli): add tests for JET:
Goffi <goffi@goffi.org>
parents:
3962
diff
changeset
|
376 |
9b1d74a6b48c
tests (e2e/cli): add tests for JET:
Goffi <goffi@goffi.org>
parents:
3962
diff
changeset
|
377 def test_jingle_encrypted_transport_jet(self, fake_file): |
9b1d74a6b48c
tests (e2e/cli): add tests for JET:
Goffi <goffi@goffi.org>
parents:
3962
diff
changeset
|
378 """A file is sent and received properly with JET OMEMO""" |
9b1d74a6b48c
tests (e2e/cli): add tests for JET:
Goffi <goffi@goffi.org>
parents:
3962
diff
changeset
|
379 li.encryption.start("account1@server2.test", name="oldmemo") |
9b1d74a6b48c
tests (e2e/cli): add tests for JET:
Goffi <goffi@goffi.org>
parents:
3962
diff
changeset
|
380 source_file = fake_file.size(10240) |
9b1d74a6b48c
tests (e2e/cli): add tests for JET:
Goffi <goffi@goffi.org>
parents:
3962
diff
changeset
|
381 source_file_hash = fake_file.get_source_hash(source_file) |
9b1d74a6b48c
tests (e2e/cli): add tests for JET:
Goffi <goffi@goffi.org>
parents:
3962
diff
changeset
|
382 send_cmd = li.file.send( |
9b1d74a6b48c
tests (e2e/cli): add tests for JET:
Goffi <goffi@goffi.org>
parents:
3962
diff
changeset
|
383 source_file, "account1@server2.test", encrypt=True, _bg=True |
9b1d74a6b48c
tests (e2e/cli): add tests for JET:
Goffi <goffi@goffi.org>
parents:
3962
diff
changeset
|
384 ) |
9b1d74a6b48c
tests (e2e/cli): add tests for JET:
Goffi <goffi@goffi.org>
parents:
3962
diff
changeset
|
385 dest_path = fake_file.dest_files / "test_send_receive" |
9b1d74a6b48c
tests (e2e/cli): add tests for JET:
Goffi <goffi@goffi.org>
parents:
3962
diff
changeset
|
386 dest_path.mkdir() |
9b1d74a6b48c
tests (e2e/cli): add tests for JET:
Goffi <goffi@goffi.org>
parents:
3962
diff
changeset
|
387 try: |
9b1d74a6b48c
tests (e2e/cli): add tests for JET:
Goffi <goffi@goffi.org>
parents:
3962
diff
changeset
|
388 li.file.receive( |
9b1d74a6b48c
tests (e2e/cli): add tests for JET:
Goffi <goffi@goffi.org>
parents:
3962
diff
changeset
|
389 "account1@server1.test", profile="account1_s2", path=dest_path) |
9b1d74a6b48c
tests (e2e/cli): add tests for JET:
Goffi <goffi@goffi.org>
parents:
3962
diff
changeset
|
390 dest_file = dest_path / source_file.name |
9b1d74a6b48c
tests (e2e/cli): add tests for JET:
Goffi <goffi@goffi.org>
parents:
3962
diff
changeset
|
391 dest_file_hash = fake_file.get_dest_hash(dest_file) |
9b1d74a6b48c
tests (e2e/cli): add tests for JET:
Goffi <goffi@goffi.org>
parents:
3962
diff
changeset
|
392 finally: |
9b1d74a6b48c
tests (e2e/cli): add tests for JET:
Goffi <goffi@goffi.org>
parents:
3962
diff
changeset
|
393 shutil.rmtree(dest_path) |
9b1d74a6b48c
tests (e2e/cli): add tests for JET:
Goffi <goffi@goffi.org>
parents:
3962
diff
changeset
|
394 send_cmd.wait() |
9b1d74a6b48c
tests (e2e/cli): add tests for JET:
Goffi <goffi@goffi.org>
parents:
3962
diff
changeset
|
395 |
9b1d74a6b48c
tests (e2e/cli): add tests for JET:
Goffi <goffi@goffi.org>
parents:
3962
diff
changeset
|
396 assert source_file_hash == dest_file_hash |
9b1d74a6b48c
tests (e2e/cli): add tests for JET:
Goffi <goffi@goffi.org>
parents:
3962
diff
changeset
|
397 li.encryption.stop("account1@server2.test") |
3974
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
398 |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
399 def test_pubsub_targeted_encryption_pte(self, li_elt): |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
400 """An item is encrypted for specific recipients""" |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
401 secret_blog = "this is a secret blog post" |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
402 node = "e2ee_blog" |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
403 item = "test_pte" |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
404 li.encryption.start("account1@server2.test", name="twomemo") |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
405 li.encryption.start( |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
406 "account1@server1.test", name="twomemo", profile="account1_s2" |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
407 ) |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
408 li.blog.set( |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
409 _in=secret_blog, node="e2ee_blog", item=item, |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
410 encrypt_for="account1@server2.test" |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
411 ) |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
412 |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
413 # the item should be transparently decrypted |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
414 parsed_decrypted = li_elt.pubsub.get( |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
415 service="account1@server1.test", node=node, item=item, no_cache=True, |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
416 profile="account1_s2" |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
417 ) |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
418 entry_elt = parsed_decrypted.firstChildElement() |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
419 assert entry_elt.name == "entry" |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
420 assert entry_elt.uri == NS_ATOM |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
421 assert secret_blog in parsed_decrypted.toXml() |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
422 |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
423 # with --no-decrypt, we should have the encrypted item |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
424 parsed_ori_item = li_elt.pubsub.get( |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
425 node=node, item=item, no_decrypt=True, no_cache=True |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
426 ) |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
427 encrypted_elt = parsed_ori_item.firstChildElement() |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
428 assert encrypted_elt.name == "encrypted" |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
429 assert encrypted_elt.uri == NS_PTE |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
430 # the body must not be readable in plain text |
5e3b983ab2c6
tests (e2e/cli): test for Pubsub Targeted Encryption:
Goffi <goffi@goffi.org>
parents:
3971
diff
changeset
|
431 assert secret_blog not in parsed_ori_item.toXml() |