Merge lp:~jtv/maas/bug-1075597 into lp:~maas-committers/maas/trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Jeroen T. Vermeulen | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 1334 | ||||
Proposed branch: | lp:~jtv/maas/bug-1075597 | ||||
Merge into: | lp:~maas-committers/maas/trunk | ||||
Diff against target: |
177 lines (+70/-38) 4 files modified
src/maasserver/api.py (+5/-1) src/maasserver/tests/test_api.py (+48/-10) src/maasserver/utils/__init__.py (+10/-13) src/maasserver/utils/tests/test_utils.py (+7/-14) |
||||
To merge this branch: | bzr merge lp:~jtv/maas/bug-1075597 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Julian Edwards (community) | Approve | ||
Review via email: mp+133328@code.launchpad.net |
Commit message
Don't include the script_name prefix in build_absolute_uri; it was already in the path it appends.
Description of the change
Pre-imp'ed with Raphaël. We were getting duplicate path prefixes in the URLs in the API description, along the lines of “http://
The test should have caught this, except Django seems to initialize its URL prefix at WSGI startup. Which means that it's just not happening in tests. And so we needed to set it explicitly for the test (not as straightforward as the code makes it look!) and then change the meaning of build_absolute_
Previously this parameter was supposed to be the http path from the application root to a given API resource, which meant duplicating the prefix, but now it's actually simpler: it's simply the absolute http path to the resource.
The purpose of this whole URL dance was to allow clients to use these links despite talking to the API on different server addresses — e.g. if the server had multiple network interfaces and addresses facing multiple networks. So it's actually fine to recompute the entire path; the request is only interesting because of its network addressing.
Jeroen
81 + django. core.urlresolve rs.set_ script_ prefix( self.script_ name)
It took me a while to work out where self.script_name was set and then realised it's part of the test scenarios. It might be worth passing it into this function (patch_ script_ prefix) as a parameter otherwise it looks like the usual testing antipattern stuff.
Everything else looks good. Cheers.