Merge ~ines-almeida/launchpad:change-traverse-archive-redirect-status into launchpad:master

Proposed by Ines Almeida
Status: Merged
Approved by: Ines Almeida
Approved revision: 8a06d445bdd0550843a77ee99afb617f04a76d99
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~ines-almeida/launchpad:change-traverse-archive-redirect-status
Merge into: launchpad:master
Diff against target: 34 lines (+4/-2)
2 files modified
lib/lp/registry/browser/person.py (+2/-1)
lib/lp/registry/browser/tests/test_person.py (+2/-1)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+452572@code.launchpad.net

Commit message

Update the redirection status code from 301 to 303 when traversing an archive

The 301 signals a permanent redirect, which means that these redirects get cached. This permanent redirection can lead to issues where the wrong redirection gets cached in a browser.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve
8a06d44... by Ines Almeida

Update the default value for the status code redirection tests

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/registry/browser/person.py b/lib/lp/registry/browser/person.py
2index c359df7..3bd82ec 100644
3--- a/lib/lp/registry/browser/person.py
4+++ b/lib/lp/registry/browser/person.py
5@@ -516,7 +516,8 @@ class PersonNavigation(BranchTraversalMixin, Navigation):
6 self.request.stepstogo.consume()
7 if redirect:
8 return self.redirectSubTree(
9- canonical_url(ppa, request=self.request)
10+ canonical_url(ppa, request=self.request),
11+ status=303,
12 )
13 else:
14 return ppa
15diff --git a/lib/lp/registry/browser/tests/test_person.py b/lib/lp/registry/browser/tests/test_person.py
16index 098c2a6..88bca93 100644
17--- a/lib/lp/registry/browser/tests/test_person.py
18+++ b/lib/lp/registry/browser/tests/test_person.py
19@@ -111,13 +111,14 @@ from lp.testing.views import create_initialized_view, create_view
20 class TestPersonNavigation(TestCaseWithFactory):
21 layer = DatabaseFunctionalLayer
22
23- def assertRedirect(self, path, redirect):
24+ def assertRedirect(self, path, redirect, status_code=303):
25 view = test_traverse(path)[1]
26 self.assertIsInstance(view, RedirectionView)
27 self.assertEqual(
28 urljoin(allvhosts.configs["mainsite"].rooturl, redirect),
29 removeSecurityProxy(view).target,
30 )
31+ self.assertEqual(status_code, removeSecurityProxy(view).status)
32
33 def test_traverse_archive_distroful(self):
34 archive = self.factory.makeArchive(purpose=ArchivePurpose.PPA)

Subscribers

People subscribed via source and target branches

to status/vote changes: