implement SCL3 httpd redirects in Django#4215
Conversation
|
|
||
| # other | ||
| 'kuma.humans', | ||
| 'redirect_urls', |
There was a problem hiding this comment.
Is this needed? I would think that the kuma.redirects app added above should be sufficient.
There was a problem hiding this comment.
It is needed. This loads the machinery that then goes to find the redirects.py files in the other apps.
| redirectpatterns = [ | ||
| # RewriteRule ^/media/(redesign/)?css/(.*)-min.css$ | ||
| # /static/build/styles/$2.css [L,R=301] | ||
| redirect(r'^media/(?:redesign/)?css/(?P<doc>.*)-min.css$', |
There was a problem hiding this comment.
Might want the prepend_locale=False arg on some/most of these. Probably works without, but more regex than you need.
There was a problem hiding this comment.
- An empty file is needed at
tests/redirects/__init__.pyUpdate - was tests_redirects.py, which makes no sense
After adding that file, I was able to run py.test tests/redirects/test_redirects.py, and get 6 passing tests. I'll have to read a little more of tests/redirects/base.py to see what that means...
There's a few more items, noted in the diff, but this is the first 5 min feedback.
| Werkzeug==0.11.4 \ | ||
| --hash=sha256:7db3cb2d4725be0680abf64a45b18229186f03ad8b9989abbe053f9357b17b37 \ | ||
| --hash=sha256:e48fb7e3f2bb5a740dd9a666624699a4d83e2e028555f9c46bcc8ecfc2cd8c32 | ||
| django-redirect-urls==0.1 \ |
There was a problem hiding this comment.
dev.txt includes default.txt, so this should be removed
| pytest-base-url==1.1.0 \ | ||
| --hash=sha256:90a1ce6a00a558231117b5aee32300edecbc0c2fd701c13e8cec62177900d28c \ | ||
| --hash=sha256:001c1b2678dae82c2891db415251361b29ed6824cb2085e4821635119499071e | ||
| pytest-django==3.1.2 \ |
There was a problem hiding this comment.
Is pytest-django actually needed in functional tests?
There was a problem hiding this comment.
I couldn't test redirects without it.
tests/redirects/map_301.py
Outdated
| @@ -0,0 +1,34 @@ | |||
| import pytest | |||
There was a problem hiding this comment.
pytest imported but unused
tests/redirects/map_301.py
Outdated
| @@ -0,0 +1,34 @@ | |||
| import pytest | |||
| from redirect_urls import redirect | |||
There was a problem hiding this comment.
redirect imported but unused
tests/redirects/test_redirects.py
Outdated
| @@ -0,0 +1,14 @@ | |||
| from __future__ import absolute_import | |||
| from operator import itemgetter | |||
There was a problem hiding this comment.
itemgetter imported but unused
kuma/redirects/models.py
Outdated
| @@ -0,0 +1 @@ | |||
| from django.db import models | |||
There was a problem hiding this comment.
can this file be omitted?
There was a problem hiding this comment.
I believe the file is required for django to consider it an "app" (that could be old info though). It can be empty though. Looks like the default models.py when you use manage.py startapp.
| pytest-django==3.1.2 \ | ||
| --hash=sha256:038ccc5a9daa1b1b0eb739ab7dce54e495811eca5ea3af4815a2a3ac45152309 \ | ||
| --hash=sha256:00995c2999b884a38ae9cd30a8c00ed32b3d38c1041250ea84caf18085589662 | ||
| django-redirect-urls==0.1 \ |
There was a problem hiding this comment.
I think this is unused in functional tests
|
Also, moving |
Codecov Report
@@ Coverage Diff @@
## master #4215 +/- ##
==========================================
+ Coverage 86.31% 86.31% +<.01%
==========================================
Files 147 148 +1
Lines 9103 9105 +2
Branches 1222 1222
==========================================
+ Hits 7857 7859 +2
Misses 1005 1005
Partials 241 241
Continue to review full report at Codecov.
|
|
going to split this into 2 PRs: one for requirements so the base Docker image can be updated, and another with the redirects impl. |
This PR uses @pmac's https://github.com/pmac/django-redirect-urls lib to implement SCL3 Apache httpd redirects in Python/Django. Original rewrite rules are saved as comments to each Django redirect. Test layout is similar to the Bedrock redirect tests.
Some (or all) of these redirects may be unusued/leftover from A Long Time Ago.
The only rewrite rule that isn't implemented in this PR is as follows:
which redirects requests to
developer.mozilla.com/*-->developer.mozilla.org/*Tracked in this infra issue
cc @jgmize @pmac @jwhitlock @escattone
This site was a great help when working with mod_rewrite.