Skip to content
Snippets Groups Projects
Verified Commit b32c37be authored by Levente Polyak's avatar Levente Polyak :rocket:
Browse files

feature(keyringctl): raise exception on duplicate uid data

parent b653edfc
No related branches found
No related tags found
No related merge requests found
......@@ -354,6 +354,10 @@ def convert_certificate(
current_packet_fingerprint = None
current_packet_uid = Uid(simplify_ascii(packet_dump_field(packet, "Value")))
if current_packet_uid in uids:
raise Exception(
f"Duplicate User ID {current_packet_uid} used in packet {uids[current_packet_uid]} and {packet}"
)
uids[current_packet_uid] = packet
elif packet.name.endswith("UserAttribute"):
current_packet_mode = "uattr"
......
......@@ -423,6 +423,22 @@ def test_convert_signature_packet(
"bar",
does_not_raise(),
),
(
Path("foo.asc"),
[
Path("--PublicKey"),
Path("--Signature"),
Path("--UserID"),
Path("--UserID"),
],
[
"".join(choice("ABCDEF" + digits) for _ in range(40)),
"foo <foo@bar.com>",
"foo <foo@bar.com>",
],
"bar",
raises(Exception),
),
(
Path("foo.asc"),
[
......
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