Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[change!] Fixed the URL structure for downloading CA's CRL #147

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading