Skip to content

Commit 4c03145

Browse files
committed
add: should be failed test on decode non-AEAD message without enable_non_aead=True
1 parent 241b4cd commit 4c03145

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

tests/test_recipient.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,13 @@ def test_recipients_aes(self, kw_alg, enc_alg):
840840
enable_non_aead=True,
841841
)
842842

843+
# The recipient side (must fail):
844+
recipient = COSE.new()
845+
with pytest.raises(ValueError) as err:
846+
_ = recipient.decode(encoded, keys=[kw_key]) # the option enable_non_aead=False by default
847+
pytest.fail("decode() should fail for non-AEAD without enable_non_aead=True.")
848+
assert f"Deprecated non-AEAD algorithm: {enc_key._alg}." == str(err.value)
849+
843850
# The recipient side:
844851
recipient = COSE.new()
845852
assert b"Hello world!" == recipient.decode(encoded, keys=[kw_key], enable_non_aead=True)

0 commit comments

Comments
 (0)