From c685a0bd367859fd9afd9abb070ed8696ca17e40 Mon Sep 17 00:00:00 2001 From: PengfeiLi0218 Date: Fri, 11 Jan 2019 20:19:38 +0800 Subject: [PATCH 1/4] bugs: Mismatch between validRedirectURL and requestedRedirectURL --- README.md | 3 ++- apitester/apitester/urls.py | 31 ++++++++++++++++++++++++++++++- apitester/obp/urls.py | 30 +----------------------------- 3 files changed, 33 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index db60fb4..076b7b2 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,8 @@ import os BASE_DIR = './' # Used internally by Django, can be anything of your choice SECRET_KEY = '' -# API hostname, e.g. https://api.openbankproject.com +# API hostname, e.g. https://api.openbankproject.com +# API OBP URL API_HOST = 'http://127.0.0.1:8080' # Consumer key + secret to authenticate the _app_ against the API OAUTH_CONSUMER_KEY = '' diff --git a/apitester/apitester/urls.py b/apitester/apitester/urls.py index 35e0664..dccc91b 100644 --- a/apitester/apitester/urls.py +++ b/apitester/apitester/urls.py @@ -7,8 +7,37 @@ from base.views import HomeView +from obp.views import OAuthInitiateView, OAuthAuthorizeView, DirectLoginView, GatewayLoginView, LogoutView + +from django.conf import settings +import logging + +LOGGER = logging.getLogger(__name__) + +def LogAtStart(): + LOGGER.log(logging.INFO, 'OAUTH_BASE_URL: {}'.format( + settings.OAUTH_BASE_URL)) + + LOGGER.log(logging.INFO, 'API_HOST: {}'.format( + settings.API_HOST)) + + LOGGER.log(logging.INFO, 'API_ROOT: {}'.format( + settings.API_ROOT)) + +LogAtStart() + urlpatterns = [ url(r'^$', HomeView.as_view(), name="home"), - url(r'^obp/', include('obp.urls')), + url(r'^oauth/initiate$', + OAuthInitiateView.as_view(), name='oauth-initiate'), + url(r'^oauth/authorize$', + OAuthAuthorizeView.as_view(), name='oauth-authorize'), + url(r'^directlogin$', + DirectLoginView.as_view(), name='directlogin'), + url(r'^gatewaylogin$', + GatewayLoginView.as_view(), name='gatewaylogin'), + url(r'^logout$', + LogoutView.as_view(), name='oauth-logout'), + #url(r'^obp/', include('obp.urls')), url(r'^runtests/', include('runtests.urls')), ] diff --git a/apitester/obp/urls.py b/apitester/obp/urls.py index c36d1b4..d9a6401 100644 --- a/apitester/obp/urls.py +++ b/apitester/obp/urls.py @@ -12,32 +12,4 @@ LogoutView, ) -from django.conf import settings -import logging - -LOGGER = logging.getLogger(__name__) - -def LogAtStart(): - LOGGER.log(logging.INFO, 'OAUTH_BASE_URL: {}'.format( - settings.OAUTH_BASE_URL)) - - LOGGER.log(logging.INFO, 'API_HOST: {}'.format( - settings.API_HOST)) - - LOGGER.log(logging.INFO, 'API_ROOT: {}'.format( - settings.API_ROOT)) - -LogAtStart() - -urlpatterns = [ - url(r'^oauth/initiate$', - OAuthInitiateView.as_view(), name='oauth-initiate'), - url(r'^oauth/authorize$', - OAuthAuthorizeView.as_view(), name='oauth-authorize'), - url(r'^directlogin$', - DirectLoginView.as_view(), name='directlogin'), - url(r'^gatewaylogin$', - GatewayLoginView.as_view(), name='gatewaylogin'), - url(r'^logout$', - LogoutView.as_view(), name='oauth-logout'), -] +urlpatterns = [] From f881a9abec7cdb7db5a54206cafc4d3ec94482fa Mon Sep 17 00:00:00 2001 From: PengfeiLi0218 Date: Fri, 11 Jan 2019 22:38:22 +0800 Subject: [PATCH 2/4] bug if you copy an operation first --- apitester/runtests/views.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apitester/runtests/views.py b/apitester/runtests/views.py index a5f9624..848c0f0 100644 --- a/apitester/runtests/views.py +++ b/apitester/runtests/views.py @@ -245,20 +245,20 @@ def get_config(self, testmethod, testpath, testconfig_pk, operation_id): status_code = 204 try: - obj = ProfileOperation.objects.get( - profile_id=testconfig_pk, + objs = ProfileOperation.objects.filter( + profile_id=int(testconfig_pk), operation_id=operation_id, is_deleted=0 ) except ProfileOperation.DoesNotExist: - obj = None + objs = None config = { 'found': True, 'method': testmethod, 'status_code': status_code, 'summary': 'Unknown', - 'urlpath': urlpath if obj is None else obj.urlpath, + 'urlpath': urlpath if objs is None else objs[0].urlpath, 'operation_id': operation_id, 'profile_id': testconfig_pk, 'payload': self.request.POST.get('json_body') From ed28bda7f533b5aa02b601bea07cc620172185bd Mon Sep 17 00:00:00 2001 From: PengfeiLi0218 Date: Fri, 11 Jan 2019 23:12:18 +0800 Subject: [PATCH 3/4] #47 continued: keep obp/oauth/ path --- apitester/apitester/urls.py | 2 +- apitester/obp/urls.py | 13 ++++++++++++- apitester/runtests/views.py | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/apitester/apitester/urls.py b/apitester/apitester/urls.py index dccc91b..8358329 100644 --- a/apitester/apitester/urls.py +++ b/apitester/apitester/urls.py @@ -38,6 +38,6 @@ def LogAtStart(): GatewayLoginView.as_view(), name='gatewaylogin'), url(r'^logout$', LogoutView.as_view(), name='oauth-logout'), - #url(r'^obp/', include('obp.urls')), + url(r'^obp/', include('obp.urls')), url(r'^runtests/', include('runtests.urls')), ] diff --git a/apitester/obp/urls.py b/apitester/obp/urls.py index d9a6401..bae79cc 100644 --- a/apitester/obp/urls.py +++ b/apitester/obp/urls.py @@ -12,4 +12,15 @@ LogoutView, ) -urlpatterns = [] +urlpatterns = [ + url(r'^oauth/initiate$', + OAuthInitiateView.as_view(), name='obp-oauth-initiate'), + url(r'^oauth/authorize$', + OAuthAuthorizeView.as_view(), name='obp-oauth-authorize'), + url(r'^directlogin$', + DirectLoginView.as_view(), name='obp-directlogin'), + url(r'^gatewaylogin$', + GatewayLoginView.as_view(), name='obp-gatewaylogin'), + url(r'^logout$', + LogoutView.as_view(), name='obp-oauth-logout'), +] diff --git a/apitester/runtests/views.py b/apitester/runtests/views.py index 848c0f0..6e71c61 100644 --- a/apitester/runtests/views.py +++ b/apitester/runtests/views.py @@ -258,7 +258,7 @@ def get_config(self, testmethod, testpath, testconfig_pk, operation_id): 'method': testmethod, 'status_code': status_code, 'summary': 'Unknown', - 'urlpath': urlpath if objs is None else objs[0].urlpath, + 'urlpath': urlpath if objs is None or len(objs)==0 else objs[0].urlpath, 'operation_id': operation_id, 'profile_id': testconfig_pk, 'payload': self.request.POST.get('json_body') From 61bbeefc4ca07151ca1a4606323e83d50eb5b40c Mon Sep 17 00:00:00 2001 From: PengfeiLi0218 Date: Fri, 11 Jan 2019 23:46:20 +0800 Subject: [PATCH 4/4] bug if you copy an operation first continued --- apitester/runtests/static/runtests/js/runtests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apitester/runtests/static/runtests/js/runtests.js b/apitester/runtests/static/runtests/js/runtests.js index c5de5bb..14e25d7 100644 --- a/apitester/runtests/static/runtests/js/runtests.js +++ b/apitester/runtests/static/runtests/js/runtests.js @@ -100,7 +100,7 @@ $(function() { 'remark':remark, 'csrfmiddlewaretoken': window.CSRF }, function (response) { - $(item_list).clone().appendTo($(item_list)); + $(item_list).clone(true).insertAfter($(item_list)); }); });