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
  • Loading branch information
pandafy committed Jul 26, 2024
1 parent 131d5e5 commit cfe3d62
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 1 addition & 3 deletions django_x509/base/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,7 @@ class Media:
js = ('admin/js/jquery.init.js', 'django-x509/js/x509-admin.js')

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

def crl_view(self, request, pk):
authenticated = request.user.is_authenticated
Expand Down
6 changes: 5 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,9 @@ 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')
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 cfe3d62

Please sign in to comment.