gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-merchant-frontends] branch master updated (84800fd -


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant-frontends] branch master updated (84800fd -> 2ac0880)
Date: Fri, 28 Jul 2017 13:13:12 +0200

This is an automated email from the git hooks/post-receive script.

marcello pushed a change to branch master
in repository merchant-frontends.

    from 84800fd  fix unchecked /generate-contract arguments
     new 838b311  test bad donation receiver, use exceptions for 
'expect_parameter()'
     new 2ac0880  test /donate endpoint

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 talerfrontends/donations/donations.py |  9 ++++++++-
 talerfrontends/tests.py               | 11 +++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/talerfrontends/donations/donations.py 
b/talerfrontends/donations/donations.py
index 6fb15d9..061685f 100644
--- a/talerfrontends/donations/donations.py
+++ b/talerfrontends/donations/donations.py
@@ -28,7 +28,8 @@ import jinja2
 from talerfrontends.talerconfig import TalerConfig
 from talerfrontends.helpers import (make_url,
 expect_parameter, amount_from_float, amount_to_float,
-join_urlparts, get_query_string, MissingParameterException)
+join_urlparts, get_query_string, MissingParameterException,
+backend_error)
 
 logger = logging.getLogger(__name__)
 
@@ -119,6 +120,12 @@ def generate_contract():
         ),
     )
     r = requests.post(urljoin(BACKEND_URL, 'proposal'), json=dict(order=order))
+    if 200 != r.status_code:
+        # It is important to use 'backend_error()', as it handles
+        # the case where the backend gives NO JSON as response.
+        # For example, if it dies, or nginx hijacks somehow the
+        # response.
+        return backend_error(r)
     return flask.jsonify(r.json()), r.status_code
 
 @app.route("/donate")
diff --git a/talerfrontends/tests.py b/talerfrontends/tests.py
index 7bdac73..71944b2 100755
--- a/talerfrontends/tests.py
+++ b/talerfrontends/tests.py
@@ -8,7 +8,9 @@ a wallet (resume Python wallet?)!
 import unittest
 from donations import donations
 from blog import blog
+import logging
 
+logger = logging.getLogger(__name__)
 dapp = donations.app
 bapp = donations.app
 
@@ -24,10 +26,19 @@ class DonationsTestCase(unittest.TestCase):
     def test_proposal_creation(self):
         qs = "/generate-contract?donation_receiver=Tor&donation_amount=1.0"
         bad_qs = "/generate-contract?buggy=qs"
+        bad_receiver = 
"/generate-contract?donation_receiver=Torrone&donation_amount=2"
         response = self.app.get(qs)
         assert 200 == response.status_code
         response = self.app.get(bad_qs)
         assert 400 == response.status_code
+        response = self.app.get(bad_receiver)
+        assert 404 == response.status_code
+
+    def test_donate(self):
+        qs = 
"/donate?donation_receiver=Tor&donation_amount=1&payment_system=taler"
+        response = self.app.get(qs)
+        print(response.status_code)
+        assert 402 == response.status_code
 
 class BlogTestCase(unittest.TestCase):
     def setUp(self):

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]