File 767-skip-xc20p-tests.patch of Package python-Authlib

From 8f823db3fe552b8337cce1eb4ec4207411c63d0b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89loi=20Rivard?= <eloi@yaal.coop>
Date: Thu, 1 May 2025 10:04:21 +0200
Subject: [PATCH] fix: skip xc20p unit tests when unavailable in cryptodome

---
 tests/jose/test_chacha20.py |    6 ++++++
 1 file changed, 6 insertions(+)

Index: authlib-1.5.2/tests/jose/test_chacha20.py
===================================================================
--- authlib-1.5.2.orig/tests/jose/test_chacha20.py	2025-04-02 12:30:25.000000000 +0200
+++ authlib-1.5.2/tests/jose/test_chacha20.py	2025-05-02 18:21:41.958090585 +0200
@@ -1,5 +1,7 @@
 import unittest
 
+import pytest
+
 from authlib.jose import JsonWebEncryption
 from authlib.jose import OctKey
 from authlib.jose.drafts import register_jwe_draft
@@ -22,6 +24,8 @@
         self.assertRaises(ValueError, jwe.serialize_compact, protected, b"hello", key2)
 
     def test_dir_alg_xc20p(self):
+        pytest.importorskip("Cryptodome.Cipher.ChaCha20_Poly1305")
+
         jwe = JsonWebEncryption()
         key = OctKey.generate_key(256, is_private=True)
         protected = {"alg": "dir", "enc": "XC20P"}
@@ -35,6 +39,8 @@
         self.assertRaises(ValueError, jwe.serialize_compact, protected, b"hello", key2)
 
     def test_xc20p_content_encryption_decryption(self):
+        pytest.importorskip("Cryptodome.Cipher.ChaCha20_Poly1305")
+
         # https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha-03#appendix-A.3.1
         enc = JsonWebEncryption.ENC_REGISTRY["XC20P"]
 
openSUSE Build Service is sponsored by