diff --git a/authentik/crypto/tests.py b/authentik/crypto/tests.py index f42f32172..59df86b32 100644 --- a/authentik/crypto/tests.py +++ b/authentik/crypto/tests.py @@ -1,7 +1,10 @@ """Crypto tests""" +import datetime + from django.test import TestCase from authentik.crypto.api import CertificateKeyPairSerializer +from authentik.crypto.builder import CertificateBuilder from authentik.crypto.models import CertificateKeyPair @@ -29,3 +32,16 @@ class TestCrypto(TestCase): } ).is_valid() ) + + def test_builder(self): + """Test Builder""" + builder = CertificateBuilder() + builder.common_name = "test-cert" + builder.build( + subject_alt_names=[], + validity_days=3, + ) + instance = builder.save() + now = datetime.datetime.today() + self.assertEqual(instance.name, "test-cert") + self.assertEqual((instance.certificate.not_valid_after - now).days, 2) diff --git a/authentik/root/urls.py b/authentik/root/urls.py index e892bc358..95c0a1646 100644 --- a/authentik/root/urls.py +++ b/authentik/root/urls.py @@ -60,7 +60,7 @@ urlpatterns += [ path("-/health/ready/", ReadyView.as_view(), name="health-ready"), ] -if settings.DEBUG: +if settings.DEBUG: # pragma: no cover urlpatterns = ( static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)