# HG changeset patch # User Goffi # Date 1667084815 -7200 # Node ID 2d9d0b77e82b20be24d978c89ccba56bb77268a0 # Parent a15c171836bba944a2dbfec5d634b3c9a8491fc0 tests (e2e/cli): add a test for Pubsub Signing: rel 381 diff -r a15c171836bb -r 2d9d0b77e82b tests/e2e/libervia-cli/test_libervia-cli.py --- a/tests/e2e/libervia-cli/test_libervia-cli.py Sun Oct 30 01:06:35 2022 +0200 +++ b/tests/e2e/libervia-cli/test_libervia-cli.py Sun Oct 30 01:06:55 2022 +0200 @@ -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 @@ 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())