Since Python 2.7, unittest in the standard library has included mulitple
facilities for skipping tests by decorators as well as an exception.
Switch to that directly, rather than importing nose.
Change-Id: I4009033473ea24f0d0faed3670db844f40051f30
For various reasons, an operator might want to use specifics nameservers
instead of the systems ones to resolve CNAME in cname_lookup. This patch
creates a new configuration variable nameservers which accepts a list of
nameservers separated by commas. If not specified or empty, systems
namservers are used as previously.
Co-Authored-By: Tim Burke <tim.burke@gmail.com>
Change-Id: I34219e6ab7e45678c1a80ff76a1ac0730c64ddde
cname_lookup and domain_remap are currently not catching redirections
(eg: staticweb). This behavior makes the domain to change when a call
through cname_lookup and domain_remap end up being redirected. Example:
commit fixes it.
- original request: http://mysite.com/subdir
- redirected: http://cont.acct.storage.domain.com/v1/AUTH_acct/cont/subdir/
- expected: http://mysite.com/subdir/
This patch is fixing this.
Closes-Bug: #1190625
Co-Authored-By: Tim Burke <tim.burke@gmail.com>
Change-Id: I67f642b8b070bc21e7760477d0a1e3b902ba7896
Replacing function without mocking creates weird behaviors as the results
of the tests sometimes depends on the order of the execution. Use real
mocking to avoid such behaviors.
Example: using real mock showed that test test_host_is_storage_domain was
wrong because it was not "reseting" the lookup_cname function at the
beginning of the test.
Change-Id: Ibc60697c9c850e6e3a108f0d906e8906c3f53ced
Unlinke DNSException, NXDOMAIN and NoAnswer are not errors. Thus, they
should be cached so that a misconfiguration from a cname_lookup user do
not generate too many requests on the nameservers.
This patch cache NXDOMAIN and NoAnswer response for 60 seconds.
Change-Id: I1d3002bceaf5f5bee364fea6afe52cbf2aeb5fd2
Commit bfbf0d1e78ff47937adb06bce648a0b915c838d1 removed a check that was
meant to avoid to resolve a storage domain. It breaks the behavior of the
middleware as the resolution of a storage domain will return nothing, so
the global resolution will fail.
Example:
Host header: storage.example.com
storage_domain: [.storage.example.com]
Host does not end with one of the storage_domains (because of the dot),
so the middleware will loop to resolve the CNAME of storage.example.com,
but it won't succeed because it's a storage_domain.
Closes-Bug: #1311435
Change-Id: If594b816ff2f7025521de716b32c42bf3137f5dd
assertEquals is deprecated in py3, replacing it.
Change-Id: Ida206abbb13c320095bb9e3b25a2b66cc31bfba8
Co-Authored-By: Ondřej Nový <ondrej.novy@firma.seznam.cz>
It already skips IPv4 addresses, and since IPv6 is the future of the
Internet*, we should probably do the right thing with those too.
* IPv6: Just two years away for over fifteen years!
Change-Id: I54f1db4e936fd38d05ac8b5c709efba76525b9d2
cname_lookup cannot resolve IP addresses as CNAME records, and therefore
should not attempt to resolve the host in that case. The middleware is
skipped when the host is an IP address.
Change-Id: I6961ec205e771116ace1ebcb8c088f3116eb38f0
Fixes: bug #1172289
If domain_remap and cname_lookup received request which has no host header,
then returns 500 error. This fixes that problem.
Change-Id: Ibb457e9b4cb21181d8243858c04ce255365690da
Fixes: bug #1100632
This change replaces WebOb with a mostly compatible local library,
swift.common.swob. Subtle changes to WebOb's API over the years have been a
huge headache. Swift doesn't even run on the current version.
There are a few incompatibilities to simplify the implementation/interface:
* It only implements the header properties we use. More can be easily added.
* Casts header values to str on assignment.
* Response classes ("HTTPNotFound") are no longer subclasses, but partials
on Response, so things like isinstance no longer work on them.
* Unlike newer webob versions, will never return unicode objects.
Change-Id: I76617a0903ee2286b25a821b3c935c86ff95233f
The code has moved to https://github.com/notmyname/swift-cnamelookup.
For current users of cname lookup, this will require installing the new
package and changing the "use" line of the cname lookup conf section's
to:
[filter:cname_lookup]
use = egg:swift_cnamelookup#swift_cnamelookup
And then 'swift-init proxy reload'.
Change-Id: If622486ddb04a53251244c9840aa3cfe72168fc5