Skip to content

Commit

Permalink
[change!] Fixed the URL structure for downloading CA's CRL
Browse files Browse the repository at this point in the history
Signed-off-by: Gagan Deep <[email protected]>
  • Loading branch information
pandafy committed Jul 26, 2024
1 parent 131d5e5 commit 10fb8f8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion django_x509/base/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ class Media:

def get_urls(self):
return [
path('x509/ca/<int:pk>.crl', self.crl_view, name='crl')
path('x509/ca/<int:pk>.crl', self.crl_view, name='deprecated_crl'),
path('<int:pk>.crl', self.crl_view, name='crl'),
] + super().get_urls()

def crl_view(self, request, pk):
Expand Down
10 changes: 9 additions & 1 deletion django_x509/tests/test_ca.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class TestCa(TestX509Mixin, TestCase):
tests for Ca model
"""

app_label = Ca._meta.app_label

def _prepare_revoked(self):
ca = self._create_ca()
crl = crypto.load_crl(crypto.FILETYPE_PEM, ca.crl)
Expand Down Expand Up @@ -313,7 +315,13 @@ def test_crl(self):

def test_crl_view(self):
ca, cert = self._prepare_revoked()
response = self.client.get(reverse('admin:crl', args=[ca.pk]))
path = reverse('admin:crl', args=[ca.pk])
self.assertEqual(path, f'/admin/{self.app_label}/ca/{ca.pk}.crl')
deprecated_path = reverse('admin:deprecated_crl', args=[ca.pk])
self.assertEqual(
deprecated_path, f'/admin/{self.app_label}/ca/x509/ca/{ca.pk}.crl'
)
response = self.client.get(path)
self.assertEqual(response.status_code, 200)
crl = crypto.load_crl(crypto.FILETYPE_PEM, response.content)
revoked_list = crl.get_revoked()
Expand Down

0 comments on commit 10fb8f8

Please sign in to comment.