def test_certificate_only_san_no_cn(session, issuer_plugin, optional_cn_authority, logged_in_user, user):
    """Only SAN is okay with the authority having option cn_optional set to true. Checks new naming with SAN"""
    from lemur.certificates.schemas import CertificateInputSchema
    from lemur.certificates.service import create

    input_data = {
        "owner": "joe@example.com",
        "authority": {"id": optional_cn_authority.id},
        "description": "testtestest",
        "extensions": {
            "subAltNames": {
                "names": [
                    {"nameType": "IPAddress", "value": "192.168.7.1"},
                ]
            }
        }
    }

    data, errors = CertificateInputSchema().load(input_data)
    assert not errors

    csr_text, pkey = create_csr(
        owner=data["owner"],
        key_type=data["key_type"],
        extensions=data["extensions"]
    )
    assert csr_text

    parsed_csr = utils.parse_csr(csr_text)
    san = parsed_csr.extensions.get_extension_for_oid(ExtensionOID.SUBJECT_ALTERNATIVE_NAME)
    assert san
    assert san.value.get_values_for_type(x509.IPAddress)
    assert "192.168.7.1" == str(san.value.get_values_for_type(x509.IPAddress)[0])

    cert = create(
        authority=data["authority"], csr=csr_text, owner=data["owner"], creator=user["user"]
    )

    assert cert
    assert cert.name == "192.168.7.1-LemurTrustUnittestsClass1CA2018-20211108-20211109"
Only SAN is okay with the authority having option cn_optional set to true. Checks new naming with SAN
lemur/tests/test_certificates.py