Mercurial > libervia-backend
changeset 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 | a15c171836bb |
children | d105ead599b6 |
files | tests/e2e/libervia-cli/test_libervia-cli.py |
diffstat | 1 files changed, 27 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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 <http://www.gnu.org/licenses/>. +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())