[openstack-swift-plugin-swift3/el6-grizzly] replace webob with Swift's swob
Alan Pevec
apevec at fedoraproject.org
Wed Jun 19 12:33:44 UTC 2013
commit fd92a6f289fd93d96ce322f412f3616c38fe761b
Author: Alan Pevec <apevec at redhat.com>
Date: Wed Jun 19 14:17:30 2013 +0200
replace webob with Swift's swob
0001-webob-swob.patch | 212 ++++++++++++++++++++++++++++++++++++
openstack-swift-plugin-swift3.spec | 8 +-
2 files changed, 219 insertions(+), 1 deletions(-)
---
diff --git a/0001-webob-swob.patch b/0001-webob-swob.patch
new file mode 100644
index 0000000..3983a41
--- /dev/null
+++ b/0001-webob-swob.patch
@@ -0,0 +1,212 @@
+From 7c2c8d5ce1ce3b68d07f1201f42cdfd3984d2757 Mon Sep 17 00:00:00 2001
+From: Victor Rodionov <vito.ordaz at gmail.com>
+Date: Wed, 17 Oct 2012 04:09:52 +0400
+Subject: [PATCH] webob => swob
+
+---
+ swift3/middleware.py | 16 ++++++-----
+ swift3/test/unit/test_swift3.py | 59 ++++++++++++++++++++++-------------------
+ 2 files changed, 41 insertions(+), 34 deletions(-)
+
+diff --git a/swift3/middleware.py b/swift3/middleware.py
+index ec6a2d6..1141a49 100644
+--- a/swift3/middleware.py
++++ b/swift3/middleware.py
+@@ -55,13 +55,13 @@ import base64
+ from xml.sax.saxutils import escape as xml_escape
+ import urlparse
+
+-from webob import Request, Response
+ from simplejson import loads
+ import email.utils
+ import datetime
+
+ from swift.common.utils import split_path
+ from swift.common.wsgi import WSGIContext
++from swift.common.swob import Request, Response
+ from swift.common.http import HTTP_OK, HTTP_CREATED, HTTP_ACCEPTED, \
+ HTTP_NO_CONTENT, HTTP_BAD_REQUEST, HTTP_UNAUTHORIZED, HTTP_FORBIDDEN, \
+ HTTP_NOT_FOUND, HTTP_CONFLICT, HTTP_UNPROCESSABLE_ENTITY, is_success
+@@ -152,7 +152,9 @@ def canonical_string(req):
+ for k in sorted(key.lower() for key in amz_headers):
+ buf += "%s:%s\n" % (k, amz_headers[k])
+
+- path = req.path_qs
++ path = req.path
++ if req.query_string:
++ path += '?' + req.query_string
+ if '?' in path:
+ path, args = path.split('?', 1)
+ for key in urlparse.parse_qs(args, keep_blank_values=True):
+@@ -291,7 +293,7 @@ class BucketController(WSGIContext):
+ return get_err_response('InvalidURI')
+
+ resp = Response()
+- resp.headers.add('Location', self.container_name)
++ resp.headers['Location'] = self.container_name
+ resp.status = HTTP_OK
+ return resp
+
+@@ -461,15 +463,15 @@ class Swift3Middleware(object):
+ def __call__(self, env, start_response):
+ req = Request(env)
+
+- if 'AWSAccessKeyId' in req.GET:
++ if 'AWSAccessKeyId' in req.params:
+ try:
+- req.headers['Date'] = req.GET['Expires']
++ req.headers['Date'] = req.params['Expires']
+ req.headers['Authorization'] = \
+- 'AWS %(AWSAccessKeyId)s:%(Signature)s' % req.GET
++ 'AWS %(AWSAccessKeyId)s:%(Signature)s' % req.params
+ except KeyError:
+ return get_err_response('InvalidArgument')(env, start_response)
+
+- if not 'Authorization' in req.headers:
++ if 'Authorization' not in req.headers:
+ return self.app(env, start_response)
+
+ try:
+diff --git a/swift3/test/unit/test_swift3.py b/swift3/test/unit/test_swift3.py
+index 56663ac..0502c53 100644
+--- a/swift3/test/unit/test_swift3.py
++++ b/swift3/test/unit/test_swift3.py
+@@ -18,12 +18,13 @@ from datetime import datetime
+ import cgi
+ import hashlib
+
+-from webob import Request, Response
+-from webob.exc import HTTPUnauthorized, HTTPCreated, HTTPNoContent,\
+- HTTPAccepted, HTTPBadRequest, HTTPNotFound, HTTPConflict
+ import xml.dom.minidom
+ import simplejson
+
++from swift.common.swob import Request, Response, HTTPUnauthorized, \
++ HTTPCreated,HTTPNoContent, HTTPAccepted, HTTPBadRequest, HTTPNotFound, \
++ HTTPConflict
++
+ from swift3 import middleware as swift3
+
+
+@@ -129,41 +130,42 @@ class FakeAppObject(FakeApp):
+ 'last-modified': '2011-01-05T02:19:14.275290'}
+
+ def __call__(self, env, start_response):
++ req = Request(env)
+ if env['REQUEST_METHOD'] == 'GET' or env['REQUEST_METHOD'] == 'HEAD':
+ if self.status == 200:
+ if 'HTTP_RANGE' in env:
+- resp = Response(body=self.object_body,
++ resp = Response(request=req, body=self.object_body,
+ conditional_response=True)
+ return resp(env, start_response)
+- start_response(Response().status,
++ start_response(Response(request=req).status,
+ self.response_headers.items())
+ if env['REQUEST_METHOD'] == 'GET':
+ return self.object_body
+ elif self.status == 401:
+- start_response(HTTPUnauthorized().status, [])
++ start_response(HTTPUnauthorized(request=req).status, [])
+ elif self.status == 404:
+- start_response(HTTPNotFound().status, [])
++ start_response(HTTPNotFound(request=req).status, [])
+ else:
+- start_response(HTTPBadRequest().status, [])
++ start_response(HTTPBadRequest(request=req).status, [])
+ elif env['REQUEST_METHOD'] == 'PUT':
+ if self.status == 201:
+- start_response(HTTPCreated().status,
++ start_response(HTTPCreated(request=req).status,
+ [('etag', self.response_headers['etag'])])
+ elif self.status == 401:
+- start_response(HTTPUnauthorized().status, [])
++ start_response(HTTPUnauthorized(request=req).status, [])
+ elif self.status == 404:
+- start_response(HTTPNotFound().status, [])
++ start_response(HTTPNotFound(request=req).status, [])
+ else:
+- start_response(HTTPBadRequest().status, [])
++ start_response(HTTPBadRequest(request=req).status, [])
+ elif env['REQUEST_METHOD'] == 'DELETE':
+ if self.status == 204:
+- start_response(HTTPNoContent().status, [])
++ start_response(HTTPNoContent(request=req).status, [])
+ elif self.status == 401:
+- start_response(HTTPUnauthorized().status, [])
++ start_response(HTTPUnauthorized(request=req).status, [])
+ elif self.status == 404:
+- start_response(HTTPNotFound().status, [])
++ start_response(HTTPNotFound(request=req).status, [])
+ else:
+- start_response(HTTPBadRequest().status, [])
++ start_response(HTTPBadRequest(request=req).status, [])
+ return []
+
+
+@@ -187,7 +189,7 @@ class TestSwift3(unittest.TestCase):
+ dom = xml.dom.minidom.parseString("".join(resp))
+ self.assertEquals(dom.firstChild.nodeName, 'Error')
+ code = dom.getElementsByTagName('Code')[0].childNodes[0].nodeValue
+- self.assertEquals(code, 'InvalidArgument')
++ self.assertEquals(code, 'AccessDenied')
+
+ def test_bad_method(self):
+ req = Request.blank('/',
+@@ -415,9 +417,10 @@ class TestSwift3(unittest.TestCase):
+ resp = local_app(req.environ, local_app.app.do_start_response)
+ self.assertEquals(local_app.app.response_args[0].split()[0], '200')
+
+- headers = dict(local_app.app.response_args[1])
++ headers = dict((k.lower(), v) for k, v in
++ local_app.app.response_args[1])
+ for key, val in local_app.app.response_headers.iteritems():
+- if key in ('Content-Length', 'Content-Type', 'Content-Encoding',
++ if key in ('content-length', 'content-type', 'content-encoding',
+ 'etag', 'last-modified'):
+ self.assertTrue(key in headers)
+ self.assertEquals(headers[key], val)
+@@ -455,9 +458,10 @@ class TestSwift3(unittest.TestCase):
+ resp = local_app(req.environ, local_app.app.do_start_response)
+ self.assertEquals(local_app.app.response_args[0].split()[0], '206')
+
+- headers = dict(local_app.app.response_args[1])
+- self.assertTrue('Content-Range' in headers)
+- self.assertTrue(headers['Content-Range'].startswith('bytes 0-3'))
++ headers = dict((k.lower(), v) for k, v in
++ local_app.app.response_args[1])
++ self.assertTrue('content-range' in headers)
++ self.assertTrue(headers['content-range'].startswith('bytes=0-3'))
+
+ def test_object_PUT_error(self):
+ code = self._test_method_error(FakeAppObject, 'PUT',
+@@ -482,8 +486,9 @@ class TestSwift3(unittest.TestCase):
+ resp = local_app(req.environ, local_app.app.do_start_response)
+ self.assertEquals(local_app.app.response_args[0].split()[0], '200')
+
+- headers = dict(local_app.app.response_args[1])
+- self.assertEquals(headers['ETag'],
++ headers = dict((k.lower(), v) for k, v in
++ local_app.app.response_args[1])
++ self.assertEquals(headers['etag'],
+ "\"%s\"" % local_app.app.response_headers['etag'])
+
+ def test_object_PUT_headers(self):
+@@ -601,11 +606,11 @@ class TestSwift3(unittest.TestCase):
+ local_app = swift3.filter_factory({})(app)
+ req = Request.blank('/bucket/object?Signature=X&Expires=Y&'
+ 'AWSAccessKeyId=Z', environ={'REQUEST_METHOD': 'GET'})
+- req.date = datetime.now()
++ req.headers['Date'] = datetime.utcnow()
+ req.content_type = 'text/plain'
+ resp = local_app(req.environ, lambda *args: None)
+- self.assertEquals(app.req.headers['Authorization'], 'AWS Z:X')
+- self.assertEquals(app.req.headers['Date'], 'Y')
++ self.assertEquals(req.headers['Authorization'], 'AWS Z:X')
++ self.assertEquals(req.headers['Date'], 'Y')
+
+ if __name__ == '__main__':
+ unittest.main()
+--
+1.8.2.1
+
diff --git a/openstack-swift-plugin-swift3.spec b/openstack-swift-plugin-swift3.spec
index 791de9c..57ad942 100644
--- a/openstack-swift-plugin-swift3.spec
+++ b/openstack-swift-plugin-swift3.spec
@@ -2,7 +2,7 @@
Name: openstack-swift-plugin-swift3
Version: 1.0.0
-Release: 0.20120711git%{?dist}
+Release: 0.20120711git.1%{?dist}
Summary: The swift3 plugin for Openstack Swift
License: ASL 2.0
@@ -10,6 +10,8 @@ URL: https://github.com/fujita/swift3
# git config --global tar.tar.xz.command "xz -c"
# git archive --format=tar.xz --prefix=swift3-1.0.0-%{git_rev}/ %{git_rev}
Source0: swift3-1.0.0-%{git_rev}.tar.xz
+# webob->swob rhbz#975579
+Patch0: 0001-webob-swob.patch
BuildArch: noarch
BuildRequires: python2-devel
@@ -23,6 +25,7 @@ Amazon S3 API.
%prep
%setup -q -n swift3-1.0.0-%{git_rev}
+%patch0 -p1
%build
%{__python} setup.py build
@@ -43,6 +46,9 @@ rm -rf %{buildroot}
%doc AUTHORS LICENSE README.md
%changelog
+* Wed Jun 19 2013 apevec at redhat.com - 1.0.0-0.20120711git.1
+- replace webob with Swift's swob rhbz#975579
+
* Mon Sep 17 2012 Alan Pevec <apevec at redhat.com> - 1.0.0-0.20120711git
- Pull bugfixes from upstream git.
More information about the scm-commits
mailing list