From 8b944fdcdacf57bcde25119e7ba79605f1183923 Mon Sep 17 00:00:00 2001 From: sayali Date: Tue, 12 Dec 2023 14:17:03 -0800 Subject: [PATCH] test for only SAN --- lemur/tests/test_certificates.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lemur/tests/test_certificates.py b/lemur/tests/test_certificates.py index 9bd21d74ca..f950ab6a7e 100644 --- a/lemur/tests/test_certificates.py +++ b/lemur/tests/test_certificates.py @@ -1827,6 +1827,31 @@ def test_query_common_name(session): assert len(cn2_valid_certs) == 1 +def test_query_san(session): + from lemur.tests.factories import CertificateFactory + from lemur.certificates.service import query_common_name + + san1 = "testsan1.example.org" + san2 = "testsan2.example.org" + + cert_one_san_valid = CertificateFactory() + cert_one_san_valid.domains = [Domain(name=san1)] + cert_one_san_valid.owner = "owner1@example.org" + + cert_two_san_valid = CertificateFactory() + cert_two_san_valid.domains = [Domain(name=san1), Domain(name=san2)] + cert_two_san_valid.owner = "owner2@example.org" + + san1_valid_certs = query_common_name('%', {"owner": "", "san": san1, "page": "", "count": ""}) + assert len(san1_valid_certs) == 2 + + san1_owner1_valid_certs = query_common_name('%', {"owner": "owner1@example.org", "san": san1, "page": "", "count": ""}) + assert len(san1_owner1_valid_certs) == 1 + + san1_valid_certs = query_common_name('%', {"owner": "", "san": san2, "page": "", "count": ""}) + assert len(san1_valid_certs) == 1 + + def test_reissue_certificate_with_duplicate_destinations_not_allowed(session, logged_in_user, crypto_authority,