Skip to content

Commit

Permalink
Fixed redundant SQL query during CA cert creation openwisp#168
Browse files Browse the repository at this point in the history
  • Loading branch information
SitaGanesh committed Jan 1, 2025
1 parent f6e28fe commit 00723a0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions django_x509/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ def clean(self):

def save(self, *args, **kwargs):
if not self.pk and not self.certificate and not self.private_key:
#removed these lines and any reference to the generate variable
if not self.serial_number:
self.serial_number = self._generate_serial_number()
self._generate()
Expand Down
1 change: 1 addition & 0 deletions django_x509/tests/test_cert.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class TestCert(TestX509Mixin, TestCase):
"""

def test_new(self):
#added assertNumQueries to check the number of queries made
with self.assertNumQueries(3): # 3 query to be made
cert = self._create_cert()
self.assertNotEqual(cert.certificate, '')
Expand Down

0 comments on commit 00723a0

Please sign in to comment.