24 Commits

Author SHA1 Message Date
Steve Kowalik
5a06e3da3b No longer import nose
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
2017-11-07 15:39:25 +11:00
Romain LE DISEZ
420e73fabd Allow to configure the nameservers in cname_lookup
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
2017-06-01 14:02:08 -07:00
Romain LE DISEZ
107ba79770 Rewrite redirection in cname_lookup & domain_remap
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
2017-05-11 09:46:29 -04:00
Romain LE DISEZ
110d7856de Use real mocking in unit tests test_cname_lookup
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
2017-03-08 18:20:48 +01:00
Romain LE DISEZ
da92fe4c1a Cache all answers from nameservers in cname_lookup
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
2017-03-07 16:55:09 +01:00
Romain LE DISEZ
9a17e61e7f Do not follow CNAME when host is in storage_domain
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
2017-02-23 10:39:05 +01:00
Romain LE DISEZ
e6245d198f Register cname_lookup on /info
Change-Id: I4f68b2f84f32e2c9e567c08f7e66ce0a81b7d867
2017-02-19 17:32:33 +01:00
janonymous
f5f9d791b0 pep8 fix: assertEquals -> assertEqual
assertEquals is deprecated in py3, replacing it.

Change-Id: Ida206abbb13c320095bb9e3b25a2b66cc31bfba8
Co-Authored-By: Ondřej Nový <ondrej.novy@firma.seznam.cz>
2015-10-11 12:57:25 +02:00
Chmouel Boudjnah
053cd092b1 Allow multiple storage_domain in cname_lookup.
Implements: blueprint multiple-domains-in-domain-remap
Change-Id: Ia647f6777717e9ff4955ea66b29f072ac03d2785
2014-01-26 10:45:19 +00:00
ZhiQiang Fan
f72704fc82 Change OpenStack LLC to Foundation
Change-Id: I7c3df47c31759dbeb3105f8883e2688ada848d58
Closes-bug: #1214176
2013-09-20 01:02:31 +08:00
Peter Portante
be1cff4f1f Pep8 unit test modules w/ <= 10 violations (5 of 12)
Change-Id: I8e82c14ada52d44df5a31e08982ac79cd7e5c969
Signed-off-by: Peter Portante <peter.portante@redhat.com>
2013-09-01 15:12:48 -04:00
Alex Gaynor
ff5a6d0111 Corrected many style violations in the tests.
I focussed primarily on F-category violations, they are all but all fixed with
this patch.

Change-Id: I343f6945c97984ed1093bc347b6def6994297041
2013-07-24 10:18:47 -07:00
Samuel Merritt
e3da6b07a0 Skip IPv6 addresses in cname_lookup middleware.
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
2013-05-03 14:08:08 -07:00
Matthieu Huin
b61b177a3f Skip cname_lookup when host is an IP address
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
2013-05-03 17:48:31 +02:00
Eohyung Lee
04037aee5d Fixed bug in domain_remap and cname_lookup middleware
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
2013-01-23 09:36:37 +09:00
Michael Barton
5e3e9a882d local WSGI Request and Response classes
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
2012-09-28 14:48:48 -07:00
John Dickinson
1e90b61076 Re-add cname lookup and domain remap middleware
Revert "removed cname lookup middleware"

This reverts commit b47bcf19e41e862ca84d77a7b8843f836e084b6a.

Revert "removed domain remap middleware"

This reverts commit 317cf868bdf66dbc17c02d4ca383efafa5e2f229.

Change-Id: I260498d555c93b28896ace48a6f0e96701cbcc38
2012-05-21 20:02:04 -05:00
John Dickinson
b47bcf19e4 removed cname lookup middleware
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
2012-05-09 14:00:51 -05:00
John Dickinson
edf2637026 updated docs for domain remap and cname lookup middleware
Change-Id: I1c571951f25a6e724cdd4699eb94baad5e47eb95
2012-04-05 15:02:15 -05:00
John Dickinson
1ecf5ebba1 updated copyright date for all files
Change-Id: Ifd909d3561c2647770a7e0caa3cd91acd1b4f298
2012-03-19 13:45:34 -05:00
Anne Gentle
8823427161 Changed copyright notices on py files and the single rst file with a copyright notice 2011-01-04 17:34:43 -06:00
John Dickinson
d122e5e98f added SkipTest for cname tests if dnspython is not installed 2010-11-04 16:31:20 -05:00
John Dickinson
10d4609c17 fixed some tests and edge cases 2010-11-03 15:56:08 -05:00
John Dickinson
282b023fda added tests for cname lookup middleware 2010-11-01 10:30:32 -05:00