lib: add more tests
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
d2abe6d455
commit
cad6c42fdd
|
@ -33,7 +33,7 @@ class CertificateBuilder:
|
|||
def save(self) -> Optional[CertificateKeyPair]:
|
||||
"""Save generated certificate as model"""
|
||||
if not self.__certificate:
|
||||
return None
|
||||
raise ValueError("Certificated hasn't been built yet")
|
||||
return CertificateKeyPair.objects.create(
|
||||
name=self.common_name,
|
||||
certificate_data=self.certificate,
|
||||
|
|
|
@ -37,6 +37,8 @@ class TestCrypto(TestCase):
|
|||
"""Test Builder"""
|
||||
builder = CertificateBuilder()
|
||||
builder.common_name = "test-cert"
|
||||
with self.assertRaises(ValueError):
|
||||
builder.save()
|
||||
builder.build(
|
||||
subject_alt_names=[],
|
||||
validity_days=3,
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
"""Test Reflection utils"""
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from authentik.lib.utils.reflection import path_to_class
|
||||
|
||||
|
||||
class TestReflectionUtils(TestCase):
|
||||
"""Test Reflection-utils"""
|
||||
|
||||
def test_path_to_class(self):
|
||||
"""Test path_to_class"""
|
||||
self.assertIsNone(path_to_class(None))
|
||||
self.assertEqual(path_to_class("datetime.datetime"), datetime)
|
Reference in New Issue