Merge lp://staging/~wallyworld/launchpad/recursive-branch-resolution-failure into lp://staging/launchpad

Proposed by Ian Booth
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: no longer in the source branch.
Merged at revision: 11613
Proposed branch: lp://staging/~wallyworld/launchpad/recursive-branch-resolution-failure
Merge into: lp://staging/launchpad
Diff against target: 168 lines (+68/-15)
2 files modified
lib/canonical/launchpad/browser/launchpad.py (+21/-7)
lib/canonical/launchpad/browser/tests/test_launchpad.py (+47/-8)
To merge this branch: bzr merge lp://staging/~wallyworld/launchpad/recursive-branch-resolution-failure
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle Approve
Review via email: mp+36403@code.staging.launchpad.net

Commit message

When parsing short from branch urls of the for +branch/foo/bar, in the case of an error, handle the case where the referring url is None.

Description of the change

Bug 645544 describes a recursive failure when navigating to a url like +/branch/foo. This is a bug resulting from work done on lp:~wallyworld/lanchpad/tales-linkify-broken-links for bug 404131.

The problem is that when a url is entered directly, the http referer is None and the redirection logic tries to send the browser to an invalid url.

Proposed fix

Simple fix in the error handling logic to simply raise an exception if there is no referer in the http request header. This is how the system used to work before the fix for bug 404131 was done.

Implementation Details

The only code changes were to:
    - lib/canonical/launchpad/browser/launchpad.py
    - lib/canonical/launchpad/browser/tests/test_launchpad.py

Tests

    bin/test -vvm canonical.launchpad.browser.tests.test_launchpad TestBranchTraversal

    New tests were written to test for the cases where the referring url is None:
    - test_nonexistent_product_without_referer
    - test_private_without_referer

The TestBranchTraversal class (and friends) needed to be changed to pass a default referring url to the business logic being tested since previously the referring url was always None. The test cases never made the distinction between navigating from a valid url or hacking the url directly.

lint

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/canonical/launchpad/browser/launchpad.py
  lib/canonical/launchpad/browser/tests/test_launchpad.py

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

As I said on IRC I'd like you to change the name of the 'url' variable redirect_branch to http_referer or referer. Otherwise it's all fine.

Cheers!

review: Approve
Revision history for this message
Ian Booth (wallyworld) wrote :

I noticed there was still a code path were a redirect to None could occur - if an attempt was made to navigate directly to a private branch. Code fixed and new unit tested added.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

The changes look fine too.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.