From 8cf01c8569f659e44512c9766aa96e61f58521d4 Mon Sep 17 00:00:00 2001 From: Goffi Date: Sun, 30 Oct 2022 01:06:55 +0200 Subject: [PATCH] tests (e2e/cli): add a test for Pubsub Signing: rel 381 --- tests/e2e/libervia-cli/test_libervia-cli.py | 31 ++++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/tests/e2e/libervia-cli/test_libervia-cli.py b/tests/e2e/libervia-cli/test_libervia-cli.py index 47a416ab..c6e9628a 100644 --- a/tests/e2e/libervia-cli/test_libervia-cli.py +++ b/tests/e2e/libervia-cli/test_libervia-cli.py @@ -16,17 +16,19 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +import json import os import shutil from time import sleep -import pytest -from sat.plugins.plugin_xep_0277 import NS_ATOM -from sat.plugins.plugin_sec_oxps import NS_OXPS -from sat.tools.common import uri import sh from sh import li +import pytest +from sat.plugins.plugin_sec_oxps import NS_OXPS +from sat.plugins.plugin_xep_0277 import NS_ATOM +from sat.tools.common import uri + if os.getenv("LIBERVIA_TEST_ENV_E2E") is None: pytest.skip( @@ -349,3 +351,24 @@ class TestE2EEncryption: assert entry_elt.name == "entry" assert entry_elt.uri == NS_ATOM assert secret_blog in parsed_item.toXml() + + def test_pubsub_signature(self, li_json): + """A pubsub item can be signed, and the signature can be verified""" + body = "this message is signed" + service="account1@server1.test" + node ="blog_signing" + item="signed_item" + li.blog.set(_in=body, service=service, node=node, item=item, sign=True) + attachments = li_json.pubsub.attachments.get( + service=service, node=node, item=item + ) + assert len(attachments) == 1 + attachment = attachments[0] + assert attachment["from"] == "account1@server1.test" + signature_json = attachment["signature"] + sign_data = li_json.pubsub.signature.check( + json.dumps(signature_json), service=service, node=node, item=item, + ) + assert sign_data["signer"] == "account1@server1.test" + assert sign_data["validated"] == True + assert all(t == "undecided" for t in sign_data["trusts"].values())