Fix DB query for cert count for authority
This commit is contained in:
parent
42957cffc7
commit
576c69c8e5
|
@ -872,5 +872,4 @@ def get_issued_cert_count_for_authority(authority):
|
|||
|
||||
:return:
|
||||
"""
|
||||
query = database.session_query(Certificate.id).filter(Authority.id == authority.id)
|
||||
return database.get_count(query)
|
||||
return database.db.session.query(Certificate).filter(Certificate.authority_id == authority.id).count()
|
||||
|
|
|
@ -1377,3 +1377,15 @@ def test_boolean_filter(client):
|
|||
headers=VALID_ADMIN_HEADER_TOKEN,
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
|
||||
|
||||
def test_issued_cert_count_for_authority(authority):
|
||||
from lemur.tests.factories import CertificateFactory
|
||||
from lemur.certificates.service import get_issued_cert_count_for_authority
|
||||
|
||||
# create a few certs issued by the authority
|
||||
CertificateFactory(authority=authority, name="test_issued_cert_count_for_authority1")
|
||||
CertificateFactory(authority=authority, name="test_issued_cert_count_for_authority2")
|
||||
CertificateFactory(authority=authority, name="test_issued_cert_count_for_authority3")
|
||||
|
||||
assert get_issued_cert_count_for_authority(authority) == 3
|
||||
|
|
Loading…
Reference in New Issue