Mercurial > libervia-backend
comparison tests/e2e/libervia-cli/test_libervia-cli.py @ 3962:2d9d0b77e82b
tests (e2e/cli): add a test for Pubsub Signing:
rel 381
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 30 Oct 2022 01:06:55 +0200 |
parents | f2a5936f2496 |
children | 9b1d74a6b48c |
comparison
equal
deleted
inserted
replaced
3961:a15c171836bb | 3962:2d9d0b77e82b |
---|---|
14 # GNU Affero General Public License for more details. | 14 # GNU Affero General Public License for more details. |
15 | 15 |
16 # You should have received a copy of the GNU Affero General Public License | 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/>. | 17 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
18 | 18 |
19 import json | |
19 import os | 20 import os |
20 import shutil | 21 import shutil |
21 from time import sleep | 22 from time import sleep |
22 | 23 |
23 import pytest | |
24 from sat.plugins.plugin_xep_0277 import NS_ATOM | |
25 from sat.plugins.plugin_sec_oxps import NS_OXPS | |
26 from sat.tools.common import uri | |
27 import sh | 24 import sh |
28 from sh import li | 25 from sh import li |
26 | |
27 import pytest | |
28 from sat.plugins.plugin_sec_oxps import NS_OXPS | |
29 from sat.plugins.plugin_xep_0277 import NS_ATOM | |
30 from sat.tools.common import uri | |
29 | 31 |
30 | 32 |
31 if os.getenv("LIBERVIA_TEST_ENV_E2E") is None: | 33 if os.getenv("LIBERVIA_TEST_ENV_E2E") is None: |
32 pytest.skip( | 34 pytest.skip( |
33 "skipping end-to-end tests, we are not in a test environment", | 35 "skipping end-to-end tests, we are not in a test environment", |
347 # now it should be decrypted | 349 # now it should be decrypted |
348 entry_elt = parsed_item.firstChildElement() | 350 entry_elt = parsed_item.firstChildElement() |
349 assert entry_elt.name == "entry" | 351 assert entry_elt.name == "entry" |
350 assert entry_elt.uri == NS_ATOM | 352 assert entry_elt.uri == NS_ATOM |
351 assert secret_blog in parsed_item.toXml() | 353 assert secret_blog in parsed_item.toXml() |
354 | |
355 def test_pubsub_signature(self, li_json): | |
356 """A pubsub item can be signed, and the signature can be verified""" | |
357 body = "this message is signed" | |
358 service="account1@server1.test" | |
359 node ="blog_signing" | |
360 item="signed_item" | |
361 li.blog.set(_in=body, service=service, node=node, item=item, sign=True) | |
362 attachments = li_json.pubsub.attachments.get( | |
363 service=service, node=node, item=item | |
364 ) | |
365 assert len(attachments) == 1 | |
366 attachment = attachments[0] | |
367 assert attachment["from"] == "account1@server1.test" | |
368 signature_json = attachment["signature"] | |
369 sign_data = li_json.pubsub.signature.check( | |
370 json.dumps(signature_json), service=service, node=node, item=item, | |
371 ) | |
372 assert sign_data["signer"] == "account1@server1.test" | |
373 assert sign_data["validated"] == True | |
374 assert all(t == "undecided" for t in sign_data["trusts"].values()) |