[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-bank] branch stable updated (3ac4046 -> ef37242)
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-bank] branch stable updated (3ac4046 -> ef37242) |
Date: |
Thu, 23 May 2019 14:26:50 +0200 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a change to branch stable
in repository bank.
discard 3ac4046 fix empty user history
add 9e650dd taler-bank-manage.1
add 9bb9dc5 Merge branch 'master' of git.taler.net:bank
add 4f1f759 Make tests pass again, after latest changes,
add 9b04f8c fix empty user history
add 25f077c Decompression middleware.
add d406255 implement #5727
add 80b558c remove garbage
add 18d4cd1 request.headers -> request.META.
add 12f2db6 Fix headers names.
add 0a02bfc verbosity
add a670306 testing compression
add ef37242 Remove (breaking) call to old API.
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (3ac4046)
\
N -- N -- N refs/heads/stable (ef37242)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
No new revisions were added by this update.
Summary of changes:
configure.ac | 16 ++++------------
doc/taler-bank-manage.1 | 37 ++++++++++++++++++++-----------------
setup.py | 2 +-
talerbank/app/middleware.py | 33 +++++++++++++++++++++++++++++++++
talerbank/app/tests.py | 45 ++++++++++++++++++++++++++++++++++++---------
talerbank/app/views.py | 14 +++++++++-----
talerbank/settings.py | 1 +
7 files changed, 104 insertions(+), 44 deletions(-)
diff --git a/configure.ac b/configure.ac
index 3a92cde..6c1a34c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -43,18 +43,10 @@ AC_MSG_RESULT([pip3 version: $PIP_VERSION])
AX_COMPARE_VERSION([$PIP_VERSION],[lt],[6.0], [AC_MSG_ERROR([Please install
pip3>=6.0])])
-# On Debian systems, we may need to pass "--system" to pip3 to get
-# to the desired installation target directory
-AC_MSG_CHECKING([for pip3 --system])
-$PIP_EXE install --help | grep '\-\-system' >> /dev/null
-if test $? -ne 0;
-then
- DEBIAN_PIP3_SYSTEM=""
-else
- DEBIAN_PIP3_SYSTEM="--system"
-fi
-AC_SUBST(DEBIAN_PIP3_SYSTEM)
-
+AC_ARG_VAR(DEBIAN_PIP3_SYSTEM,
+ "Custom flags to be used along 'pip install'
+ (this is mandatory on some Debians to be set as '--system',
+ in order to get 'make install' obey the --prefix switch.)")
#
# Check for PostgreSQL
#
diff --git a/doc/taler-bank-manage.1 b/doc/taler-bank-manage.1
index 8c5875a..48d5887 100644
--- a/doc/taler-bank-manage.1
+++ b/doc/taler-bank-manage.1
@@ -3,15 +3,14 @@
.Os
.Sh NAME
.Nm taler-bank-manage
-.Nd
-Manager script for the Taler bank
+.Nd Manager script for the Taler bank
.Sh SYNOPSIS
.Nm
-.Op Fl \-django
-.Op Fl \-serve-http
-.Op Fl \-serve-uwsgi
-.Op Fl \-sampledata
-.Op Fl \-config
+.Op Fl -django
+.Op Fl -serve-http
+.Op Fl -serve-uwsgi
+.Op Fl -sampledata
+.Op Fl -config
.Ao Ar options Ac
.Sh DESCRIPTION
.Nm
@@ -19,28 +18,32 @@ is a command line tool to manage the Taler bank
demonstrator.
It is mandatory to provide a switch.
Each switch has its own set of options.
Give
-.Fl \-help
+.Fl -help
to each switch in order to get the list of supported options.
.Ss SWITCHES
.Bl -tag -width Ds
-.It Fl \-django
-This switch is a mere wrapper for the django native tool \fBdjango-admin\fP,
therefore it takes the same options.
+.It Fl -django
+This switch is a mere wrapper for the django native tool
+.Xr django-admin 1 ,
+therefore it takes the same options.
Refer to the official django-admin documentation.
-.It Fl \-serve-http
+.It Fl -serve-http
Launches the bank Web service at the port given in the
-.Fl \-port
+.Fl -port
option.
-.It Fl \-serve-uwsgi
+.It Fl -serve-uwsgi
Launches the bank over UWSGI.
-Typically used in conjuction with a Web server which acts like a reverse proxy.
-.It Fl \-sampledata
+Typically used in conjuction with a Web server which acts like
+a reverse proxy.
+.It Fl -sampledata
Populates the bank's database with sample wire transfers.
-.It Fl \-config
+.It Fl -config
Shows all of Taler's configuration.
it just retrieves values from default configuration files.
.El
.\".Sh EXAMPLES
-.\".Sh SEE ALSO
+.Sh SEE ALSO
+.Xr django-admin 1
.\".Sh HISTORY
.\".Sh AUTHORS
.\".Sh BUGS
diff --git a/setup.py b/setup.py
index e9d1375..dfd41cc 100755
--- a/setup.py
+++ b/setup.py
@@ -10,7 +10,7 @@ setup(name='talerbank',
author_email='address@hidden, address@hidden',
license='GPL',
packages=find_packages(),
- install_requires=["django>=1.9",
+ install_requires=["django>=2",
"psycopg2",
"requests",
"uWSGI",
diff --git a/talerbank/app/middleware.py b/talerbank/app/middleware.py
index 371d9b6..220fa94 100644
--- a/talerbank/app/middleware.py
+++ b/talerbank/app/middleware.py
@@ -1,4 +1,5 @@
import logging
+import zlib
from django.http import JsonResponse
from django.shortcuts import redirect
from .models import BankAccount, BankTransaction
@@ -16,6 +17,38 @@ LOGGER = logging.getLogger()
##
+# Class decompressing requests.
+class DecompressionMiddleware:
+
+ ##
+ # Init constructor.
+ #
+ # @param self the object itself.
+ # @param get_response a Django-provided callable that calls
+ # whatever comes next in the chain: a further middleware
+ # or the view itself (please refer to the official
+ # documentation for more details).
+ def __init__(self, get_response):
+ self.get_response = get_response
+
+ ##
+ # This function is transparently invoked by Django when
+ # a request traverses the chain made of middleware classes
+ # and the view itself as the last element in the chain.
+ #
+ # Here happens the decompression.
+ #
+ # @param self this class.
+ # @param request Django-specific request object (of the same
+ # type that is handed to views).
+ # @return Django-specific response object.
+ def __call__(self, request):
+ if "deflate" == request.META.get("HTTP_CONTENT_ENCODING"):
+ request._body = zlib.decompress(request.body)
+
+ return self.get_response(request)
+
+##
# Class holding data needed by the handling logic.
class ExceptionMiddleware:
diff --git a/talerbank/app/tests.py b/talerbank/app/tests.py
index 20dccc7..3a8dc26 100644
--- a/talerbank/app/tests.py
+++ b/talerbank/app/tests.py
@@ -19,6 +19,7 @@
import json
import time
+import zlib
import timeit
import logging
from urllib.parse import unquote
@@ -47,6 +48,27 @@ def clear_db():
cursor.execute(
"ALTER SEQUENCE app_banktransaction_id_seq RESTART")
+class PublicAccountsTestCase(TestCase):
+ def setUp(self):
+ clear_db()
+ self.user = User.objects.create_user(
+ username="Bank",
+ password="Bank")
+ self.user.save()
+
+ self.user_bank_account = BankAccount(
+ account_no=100,
+ is_public = True,
+ user=self.user)
+
+ self.user_bank_account.save()
+
+ def test_public_accounts(self):
+ self.assertTrue(User.objects.get(username="Bank"))
+
+ response = self.client.get(
+ reverse("public-accounts", urlconf=urls))
+
class WithdrawTestCase(TestCase):
def setUp(self):
self.user_bank_account = BankAccount(
@@ -69,14 +91,6 @@ class WithdrawTestCase(TestCase):
@patch('time.time')
def test_withdraw(self, mocked_time,
mocked_hashlib, mocked_wire_transfer):
- wire_details = '''{
- "test": {
- "type":"test",
- "account_number":99,
- "bank_url":"http://bank.example/",
- "name":"example"
- }
- }'''
amount = Amount(settings.TALER_CURRENCY, 0, 1)
params = {
"amount_value": str(amount.value),
@@ -85,7 +99,7 @@ class WithdrawTestCase(TestCase):
"reserve_pub": "UVZ789",
"exchange": "https://exchange.example.com/",
"exchange_wire_details":
- wire_details.replace("\n", "").replace(" ", "")
+ "payto://x-taler-bank/bank.example/99"
}
self.client.login(username="test_user",
password="test_password")
@@ -293,6 +307,19 @@ class AddIncomingTestCase(TestCase):
**{"HTTP_X_TALER_BANK_USERNAME": "user_user",
"HTTP_X_TALER_BANK_PASSWORD": "user_password"})
self.assertEqual(200, response.status_code)
+
+ # Trying the same request, but compressed.
+ zdata = zlib.compress(bytes(data, "utf-8"))
+ response = client.post(
+ reverse("add-incoming", urlconf=urls),
+ data=zdata,
+ content_type="application/json",
+ follow=True,
+ **{"HTTP_X_TALER_BANK_USERNAME": "user_user",
+ "HTTP_X_TALER_BANK_PASSWORD": "user_password",
+ "HTTP_CONTENT_ENCODING": "deflate"})
+ self.assertEqual(200, response.status_code)
+
data = '{"auth": {"type": "basic"}, \
"credit_account": 1, \
"subject": "TESTWTID", \
diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index 8f97acf..f4af47c 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -509,10 +509,14 @@ def serve_public_accounts(request, name=None, page=None):
if not user.bankaccount.is_public:
raise PrivateAccountException("Can't display public history for
private account")
- num_records = query_history_raw(user.bankaccount,
- "both",
- start=-1, # makes sign ignored.
- sign="+").count()
+ # How many records does a user have.
+ num_records = query_history(user.bankaccount,
+ "both",
+ # Note: the parameter below is used for
slicing arrays
+ # and django/python is not allowing slicing
with big numbers.
+ (UINT64_MAX / 2 ) / 2,
+ start=0,
+ sign="+").count()
DELTA = 30
# '//' operator is NO floating point.
num_pages = max(num_records // DELTA, 1)
@@ -523,7 +527,7 @@ def serve_public_accounts(request, name=None, page=None):
history = extract_history(user.bankaccount,
True,
DELTA * page,
- -1,
+ 0,
"+")[DELTA * (page - 1):(DELTA * page)]
pages = list(range(1, num_pages + 1))
diff --git a/talerbank/settings.py b/talerbank/settings.py
index 539843b..f3f099d 100644
--- a/talerbank/settings.py
+++ b/talerbank/settings.py
@@ -77,6 +77,7 @@ MIDDLEWARE = [
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'talerbank.app.middleware.ExceptionMiddleware',
+ 'talerbank.app.middleware.DecompressionMiddleware'
]
TEMPLATES = [
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-bank] branch stable updated (3ac4046 -> ef37242),
gnunet <=