Skip to content
Snippets Groups Projects
Commit 7647c72f authored by Moul's avatar Moul
Browse files

Simplify revocation tests (#435)

parent e239f0fc
No related branches found
No related tags found
1 merge request!248Revocation: remove dry-run and display options from save and verify cmds, drop default revocation file path (#435)
......@@ -178,7 +178,7 @@ def test_revocation_cli_dry_run(subcommand, expected_warn, monkeypatch):
with runner.isolated_filesystem():
Path(file).write_text(REV_DOC.signed_raw(), encoding="utf-8")
result = runner.invoke(cli, args=command)
assert "6upqFiJ66WV6N3bPc8x8y7rXT3syqKRmwnVyunCtEj7o" in result.output
assert idty1.pubkey in result.output
assert "Version: 10" in result.output
if expected_warn:
......@@ -187,6 +187,12 @@ def test_revocation_cli_dry_run(subcommand, expected_warn, monkeypatch):
assert warning not in result.output
CREATE_STRINGS = [
idty1.pubkey,
"Do you want to save the revocation document for this identity?",
]
# test cli create
@pytest.mark.parametrize(
("file", "user_input", "expected"),
......@@ -194,41 +200,27 @@ def test_revocation_cli_dry_run(subcommand, expected_warn, monkeypatch):
(
None,
"yes\n",
[
"6upqFiJ66WV6N3bPc8x8y7rXT3syqKRmwnVyunCtEj7o",
"Do you want to save the revocation document for this identity?",
],
CREATE_STRINGS,
),
(
None,
None,
[
"6upqFiJ66WV6N3bPc8x8y7rXT3syqKRmwnVyunCtEj7o",
],
CREATE_STRINGS,
),
(
Path("test_doc"),
"yes\n",
[
"6upqFiJ66WV6N3bPc8x8y7rXT3syqKRmwnVyunCtEj7o",
"Do you want to save the revocation document for this identity?",
],
CREATE_STRINGS,
),
(
Path("test_doc"),
None,
[
"6upqFiJ66WV6N3bPc8x8y7rXT3syqKRmwnVyunCtEj7o",
],
CREATE_STRINGS,
),
(
None,
"no\n",
[
"6upqFiJ66WV6N3bPc8x8y7rXT3syqKRmwnVyunCtEj7o",
"Do you want to save the revocation document for this identity?",
"Ok, goodbye!",
],
[*CREATE_STRINGS, "Ok, goodbye!"],
),
],
)
......@@ -713,7 +705,7 @@ def test_revocation_cli_publish_send_errors(
"yes\n",
REV_DOC,
[
"6upqFiJ66WV6N3bPc8x8y7rXT3syqKRmwnVyunCtEj7o",
idty1.pubkey,
"Do you confirm sending this revocation document immediately?",
],
),
......@@ -723,7 +715,7 @@ def test_revocation_cli_publish_send_errors(
"yes\n",
REV_DOC,
[
"6upqFiJ66WV6N3bPc8x8y7rXT3syqKRmwnVyunCtEj7o",
idty1.pubkey,
"Do you confirm sending this revocation document immediately?",
"Version: 10",
],
......@@ -735,7 +727,7 @@ def test_revocation_cli_publish_send_errors(
REV_DOC,
[
"WARNING: the document will only be displayed and will not be sent.",
"6upqFiJ66WV6N3bPc8x8y7rXT3syqKRmwnVyunCtEj7o",
idty1.pubkey,
"Version: 10",
],
),
......@@ -745,7 +737,7 @@ def test_revocation_cli_publish_send_errors(
"no\n",
REV_DOC,
[
"6upqFiJ66WV6N3bPc8x8y7rXT3syqKRmwnVyunCtEj7o",
idty1.pubkey,
"Do you confirm sending this revocation document immediately?",
],
),
......@@ -755,7 +747,7 @@ def test_revocation_cli_publish_send_errors(
"no\n",
REV_DOC,
[
"6upqFiJ66WV6N3bPc8x8y7rXT3syqKRmwnVyunCtEj7o",
idty1.pubkey,
"Do you confirm sending this revocation document immediately?",
"Version: 10",
],
......@@ -799,7 +791,7 @@ def test_revocation_cli_revoke(
"yes\n",
REV_DOC,
[
"6upqFiJ66WV6N3bPc8x8y7rXT3syqKRmwnVyunCtEj7o",
idty1.pubkey,
"Do you confirm sending this revocation document immediately?",
"Error while publishing revocation",
],
......@@ -809,7 +801,7 @@ def test_revocation_cli_revoke(
"yes\n",
REV_DOC,
[
"6upqFiJ66WV6N3bPc8x8y7rXT3syqKRmwnVyunCtEj7o",
idty1.pubkey,
"Do you confirm sending this revocation document immediately?",
"Version: 10",
"Error while publishing revocation",
......@@ -838,7 +830,7 @@ def test_revocation_cli_revoke_errors(display, user_input, doc, expected, monkey
def test_create_revocation_doc(idty, lookup):
test = revocation.create_revocation_doc(
lookup["results"][0]["uids"][0],
"6upqFiJ66WV6N3bPc8x8y7rXT3syqKRmwnVyunCtEj7o",
idty1.pubkey,
"g1-test",
)
expected = Revocation(
......@@ -857,13 +849,13 @@ def test_create_revocation_doc(idty, lookup):
Path("./test_doc.txt"),
REV_DOC,
REV_2,
"6upqFiJ66WV6N3bPc8x8y7rXT3syqKRmwnVyunCtEj7o",
idty1.pubkey,
),
(
Path("revocation"),
REV_DOC,
REV_2,
"6upqFiJ66WV6N3bPc8x8y7rXT3syqKRmwnVyunCtEj7o",
idty1.pubkey,
),
],
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment