diff -Nru python-etcd3gw-0.2.1/debian/changelog python-etcd3gw-0.2.1/debian/changelog --- python-etcd3gw-0.2.1/debian/changelog 2018-02-10 19:34:12.000000000 +0000 +++ python-etcd3gw-0.2.1/debian/changelog 2020-12-10 22:22:56.000000000 +0000 @@ -1,3 +1,22 @@ +python-etcd3gw (0.2.1-1.1) bionic; urgency=medium + + * d/p/0001-When-gateway-sends-failure-response-include-text-in-.patch (LP: #1900617) + - Include response text in raised exception + d/p/0001-Include-resp.text-as-detail-in-all-etcd-exceptions.patch + - Add new unit test for return exception + d/p/0001-Fix-exception-signature.patch + - Derived exceptions can use arguments again + + -- Heather Lemon Thu, 10 Dec 2020 22:22:56 +0000 + +python-etcd3gw (0.2.1-3) unstable; urgency=medium + + * Add patch from Chris Lamb to make the build + reproducible (Closes: #934918). + + -- Thomas Goirand Mon, 02 Sep 2019 12:32:47 +0200 + + python-etcd3gw (0.2.1-1) unstable; urgency=medium * Initial release. (Closes: #890071) diff -Nru python-etcd3gw-0.2.1/debian/patches/0001-Fix-exception-signature.patch python-etcd3gw-0.2.1/debian/patches/0001-Fix-exception-signature.patch --- python-etcd3gw-0.2.1/debian/patches/0001-Fix-exception-signature.patch 1970-01-01 00:00:00.000000000 +0000 +++ python-etcd3gw-0.2.1/debian/patches/0001-Fix-exception-signature.patch 2020-12-10 22:20:51.000000000 +0000 @@ -0,0 +1,37 @@ +From 19abd85b710682b326702e2290a30d084fb0af71 Mon Sep 17 00:00:00 2001 +From: Neil Jerram +Date: Tue, 17 Sep 2019 22:33:46 +0100 +Subject: [PATCH] Fix exception signature + +I previously extended the Etcd3Exception constructor signature such +that it was no longer possible for the derived exception types to +construct with no args. This change makes that possible again, while +still allowing an Etcd3Exception to be constructed with detail text as +well as the traditional "Bad Request" message. +--- + etcd3gw/client.py | 2 +- + etcd3gw/exceptions.py | 4 ++-- + 2 files changed, 3 insertions(+), 3 deletions(-) + +--- a/etcd3gw/client.py ++++ b/etcd3gw/client.py +@@ -86,7 +86,7 @@ + resp.reason + ) + if resp.status_code != requests.codes['ok']: +- raise exceptions.Etcd3Exception(resp.reason, resp.text) ++ raise exceptions.Etcd3Exception(resp.text, resp.reason) + except requests.exceptions.Timeout as ex: + raise exceptions.ConnectionTimeoutError(six.text_type(ex)) + except requests.exceptions.ConnectionError as ex: +--- a/etcd3gw/exceptions.py ++++ b/etcd3gw/exceptions.py +@@ -12,8 +12,8 @@ + + + class Etcd3Exception(Exception): +- def __init__(self, msg, detail_text=None): +- super(Etcd3Exception, self).__init__(msg) ++ def __init__(self, detail_text=None, *args): ++ super(Etcd3Exception, self).__init__(*args) + self.detail_text = detail_text diff -Nru python-etcd3gw-0.2.1/debian/patches/0001-Include-resp.text-as-detail-in-all-etcd-exceptions.patch python-etcd3gw-0.2.1/debian/patches/0001-Include-resp.text-as-detail-in-all-etcd-exceptions.patch --- python-etcd3gw-0.2.1/debian/patches/0001-Include-resp.text-as-detail-in-all-etcd-exceptions.patch 1970-01-01 00:00:00.000000000 +0000 +++ python-etcd3gw-0.2.1/debian/patches/0001-Include-resp.text-as-detail-in-all-etcd-exceptions.patch 2020-12-10 22:21:10.000000000 +0000 @@ -0,0 +1,58 @@ +From 5a3157a122368c2314c7a961f61722e47355f981 Mon Sep 17 00:00:00 2001 +From: Spike Curtis +Date: Wed, 12 Feb 2020 17:00:40 -0800 +Subject: [PATCH] Include resp.text as detail in all etcd exceptions + +Signed-off-by: Spike Curtis +--- + etcd3gw/client.py | 5 ++++- + etcd3gw/tests/test_client.py | 20 ++++++++++++++++++++ + 2 files changed, 24 insertions(+), 1 deletion(-) + +--- a/etcd3gw/client.py ++++ b/etcd3gw/client.py +@@ -81,7 +81,10 @@ + try: + resp = self.session.post(*args, **kwargs) + if resp.status_code in _EXCEPTIONS_BY_CODE: +- raise _EXCEPTIONS_BY_CODE[resp.status_code](resp.reason) ++ raise _EXCEPTIONS_BY_CODE[resp.status_code]( ++ resp.text, ++ resp.reason ++ ) + if resp.status_code != requests.codes['ok']: + raise exceptions.Etcd3Exception(resp.reason, resp.text) + except requests.exceptions.Timeout as ex: +--- a/etcd3gw/tests/test_client.py ++++ b/etcd3gw/tests/test_client.py +@@ -14,6 +14,7 @@ + + from etcd3gw.client import Etcd3Client + from etcd3gw.exceptions import Etcd3Exception ++from etcd3gw.exceptions import InternalServerError + from etcd3gw.tests import base + + +@@ -54,3 +55,22 @@ + "error": "etcdserver: mvcc: required revision has been compacted", + "code": 11 + }''') ++ ++ def test_client_exceptions_by_code(self): ++ client = Etcd3Client(host="127.0.0.1") ++ with mock.patch.object(client, "session") as mock_session: ++ mock_response = mock.Mock() ++ mock_response.status_code = 500 ++ mock_response.reason = "Internal Server Error" ++ mock_response.text = '''{ ++"error": "etcdserver: unable to reach quorum" ++}''' ++ mock_session.post.return_value = mock_response ++ try: ++ client.status() ++ self.assertFalse(True) ++ except InternalServerError as e: ++ self.assertEqual(str(e), "Internal Server Error") ++ self.assertEqual(e.detail_text, '''{ ++"error": "etcdserver: unable to reach quorum" ++}''') diff -Nru python-etcd3gw-0.2.1/debian/patches/0001-When-gateway-sends-failure-response-include-text-in-.patch python-etcd3gw-0.2.1/debian/patches/0001-When-gateway-sends-failure-response-include-text-in-.patch --- python-etcd3gw-0.2.1/debian/patches/0001-When-gateway-sends-failure-response-include-text-in-.patch 1970-01-01 00:00:00.000000000 +0000 +++ python-etcd3gw-0.2.1/debian/patches/0001-When-gateway-sends-failure-response-include-text-in-.patch 2020-12-10 22:21:25.000000000 +0000 @@ -0,0 +1,74 @@ +From 483a37e28a59e29239dcae7eeabf6f24c1f0b440 Mon Sep 17 00:00:00 2001 +From: Neil Jerram +Date: Thu, 12 Sep 2019 14:37:44 +0100 +Subject: [PATCH] When gateway sends failure response, include text in raised + exception + +--- + etcd3gw/client.py | 2 +- + etcd3gw/exceptions.py | 4 +++- + etcd3gw/tests/test_client.py | 24 ++++++++++++++++++++++++ + 3 files changed, 28 insertions(+), 2 deletions(-) + +--- a/etcd3gw/client.py ++++ b/etcd3gw/client.py +@@ -83,7 +83,7 @@ + if resp.status_code in _EXCEPTIONS_BY_CODE: + raise _EXCEPTIONS_BY_CODE[resp.status_code](resp.reason) + if resp.status_code != requests.codes['ok']: +- raise exceptions.Etcd3Exception(resp.reason) ++ raise exceptions.Etcd3Exception(resp.reason, resp.text) + except requests.exceptions.Timeout as ex: + raise exceptions.ConnectionTimeoutError(six.text_type(ex)) + except requests.exceptions.ConnectionError as ex: +--- a/etcd3gw/exceptions.py ++++ b/etcd3gw/exceptions.py +@@ -12,7 +12,9 @@ + + + class Etcd3Exception(Exception): +- pass ++ def __init__(self, msg, detail_text=None): ++ super(Etcd3Exception, self).__init__(msg) ++ self.detail_text = detail_text + + + class WatchTimedOut(Etcd3Exception): +--- a/etcd3gw/tests/test_client.py ++++ b/etcd3gw/tests/test_client.py +@@ -10,7 +10,10 @@ + # License for the specific language governing permissions and limitations + # under the License. + ++import mock ++ + from etcd3gw.client import Etcd3Client ++from etcd3gw.exceptions import Etcd3Exception + from etcd3gw.tests import base + + +@@ -30,3 +33,24 @@ + client = Etcd3Client(host="::1") + self.assertEqual("http://[::1]:2379/v3alpha/lease/grant", + client.get_url("/lease/grant")) ++ ++ def test_client_bad_request(self): ++ client = Etcd3Client(host="127.0.0.1") ++ with mock.patch.object(client, "session") as mock_session: ++ mock_response = mock.Mock() ++ mock_response.status_code = 400 ++ mock_response.reason = "Bad Request" ++ mock_response.text = '''{ ++"error": "etcdserver: mvcc: required revision has been compacted", ++"code": 11 ++}''' ++ mock_session.post.return_value = mock_response ++ try: ++ client.status() ++ self.assertFalse(True) ++ except Etcd3Exception as e: ++ self.assertEqual(str(e), "Bad Request") ++ self.assertEqual(e.detail_text, '''{ ++"error": "etcdserver: mvcc: required revision has been compacted", ++"code": 11 ++}''') diff -Nru python-etcd3gw-0.2.1/debian/patches/0001_reproducible-build.patch python-etcd3gw-0.2.1/debian/patches/0001_reproducible-build.patch --- python-etcd3gw-0.2.1/debian/patches/0001_reproducible-build.patch 1970-01-01 00:00:00.000000000 +0000 +++ python-etcd3gw-0.2.1/debian/patches/0001_reproducible-build.patch 2020-12-10 22:21:39.000000000 +0000 @@ -0,0 +1,25 @@ +Description: Make the package reproducible +Author: Chris Lamb +Forwarded: https://github.com/dims/etcd3-gateway/pull/30 +Bug-Debian: https://bugs.debian.org/934918 +Last-Update: 2019-09-02 + +--- a/etcd3gw/client.py ++++ b/etcd3gw/client.py +@@ -115,13 +115,15 @@ + json={"TTL": ttl, "ID": 0}) + return Lease(int(result['ID']), client=self) + +- def lock(self, id=str(uuid.uuid4()), ttl=DEFAULT_TIMEOUT): ++ def lock(self, id=None, ttl=DEFAULT_TIMEOUT): + """Create a Lock object given an ID and timeout + + :param id: ID for the lock, creates a new uuid if not provided + :param ttl: timeout + :return: Lock object + """ ++ if id is None: ++ id = str(uuid.uuid4()) + return Lock(id, ttl=ttl, client=self) + + def create(self, key, value): diff -Nru python-etcd3gw-0.2.1/debian/patches/series python-etcd3gw-0.2.1/debian/patches/series --- python-etcd3gw-0.2.1/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 +++ python-etcd3gw-0.2.1/debian/patches/series 2020-12-10 22:21:54.000000000 +0000 @@ -0,0 +1,4 @@ +0001_reproducible-build.patch +0001-When-gateway-sends-failure-response-include-text-in-.patch +0001-Include-resp.text-as-detail-in-all-etcd-exceptions.patch +0001-Fix-exception-signature.patch