diff --git a/README.md b/README.md index 4dc3256..9d72de9 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ API_HOST = '' # Consumer key + secret to authenticate the _app_ against the API # When the app is created on the API, the redirect URL should point to this -# host + /obp, e.g. `http://localhost:8000/obp` +# host + /obp, e.g. `http://localhost:8000` OAUTH_CONSUMER_KEY = '' OAUTH_CONSUMER_SECRET = '' diff --git a/apitester/apitester/settings.py b/apitester/apitester/settings.py index 764cb03..09c764d 100644 --- a/apitester/apitester/settings.py +++ b/apitester/apitester/settings.py @@ -156,7 +156,7 @@ 'obp': { 'handlers': ['console'], 'level': 'INFO', - }, + } }, } @@ -186,9 +186,11 @@ GATEWAYLOGIN_HAS_CBS = False API_HOST = 'http://127.0.0.1:8080' +#API_HOST = 'https://apisandbox.openbankproject.com' API_BASE_PATH = '/obp/v' API_VERSION = '3.0.0' +OAUTH_BASE_URL='http://127.0.0.1:9090' # Always save session SESSION_SAVE_EVERY_REQUEST = True @@ -210,4 +212,5 @@ # Settings here might use parts overwritten in local settings API_ROOT = API_HOST + API_BASE_PATH + API_VERSION -OAUTH_BASE_URL='http://127.0.0.1:8000' \ No newline at end of file + +#OAUTH_BASE_URL='https://apisandbox.openbankproject.com' \ No newline at end of file diff --git a/apitester/runtests/static/runtests/js/runtests.js b/apitester/runtests/static/runtests/js/runtests.js index 14e25d7..44ea8dd 100644 --- a/apitester/runtests/static/runtests/js/runtests.js +++ b/apitester/runtests/static/runtests/js/runtests.js @@ -38,14 +38,40 @@ $(function() { }); } + function deleteTest(runner){ + var item_list = $(runner).parent(); + jsonBody = $(runner).find('textarea[name="params"]').val(); + operationId = $(runner).find('input[type="hidden"]').val(); + order = $(runner).find('input[name="order"]').val(); + urlpath = $(runner).find('input[name="urlpath"]').val(); + replica_id = $(runner).find('input[name="replica_id"]').val(); + remark = $(runner).find('textarea[name="remark"]').val(); + + $.post('/runtests/delete/json_body', { + 'json_body': jsonBody, + 'operation_id': operationId, + 'profile_id' : window.CURRENT_PROFILE_ID, + 'order': order, + 'urlpath': urlpath, + 'replica_id':replica_id, + 'remark':remark, + 'csrfmiddlewaretoken': window.CSRF + }, function (response) { + $(item_list).remove(); + }); + } + $('#run').click(function() { $('.result').empty(); var runners = $('.runner'); - for (var i=0; i < runners.length; i++) { - var runner = $(runners[i]); - if (runner.find('input').is(':checked')) { - runTest(runner); - } + var runNum =$('#numRun'); + for(var j=0; j < $(runNum).val(); j++){ + for (var i=0; i < runners.length; i++) { + var runner = $(runners[i]); + if (runner.find('input').is(':checked')) { + runTest(runner); + } + } } }); @@ -105,28 +131,8 @@ $(function() { }); $('.runner button.forDelete').click(function() { - var t = $(this) var runner = $(this).parent().parent().parent(); - var item_list = $(runner).parent(); - jsonBody = $(runner).find('textarea[name="params"]').val(); - operationId = $(runner).find('input[type="hidden"]').val(); - order = $(runner).find('input[name="order"]').val(); - urlpath = $(runner).find('input[name="urlpath"]').val(); - replica_id = $(runner).find('input[name="replica_id"]').val(); - remark = $(runner).find('textarea[name="remark"]').val(); - - $.post('/runtests/delete/json_body', { - 'json_body': jsonBody, - 'operation_id': operationId, - 'profile_id' : window.CURRENT_PROFILE_ID, - 'order': order, - 'urlpath': urlpath, - 'replica_id':replica_id, - 'remark':remark, - 'csrfmiddlewaretoken': window.CSRF - }, function (response) { - $(item_list).remove(); - }); + deleteTest(runner) }); $('#checkNone').click(function() { @@ -137,6 +143,17 @@ $(function() { $('.runner').find('input').prop('checked', true); }); + $('#removeUncheck').click(function() { + var runners = $('.runner'); + + for (var i=0; i < runners.length; i++) { + var runner = $(runners[i]); + if (!runner.find('input').is(':checked')) { + deleteTest(runner) + } + } + }); + $('#select-testconfig').change(function() { var configPk = $(this).val(); if (configPk) { diff --git a/apitester/runtests/templates/runtests/index.html b/apitester/runtests/templates/runtests/index.html index 3c2173e..4c54a25 100644 --- a/apitester/runtests/templates/runtests/index.html +++ b/apitester/runtests/templates/runtests/index.html @@ -129,8 +129,11 @@

{{ config.name }}

+
+ +
- +
diff --git a/apitester/runtests/views.py b/apitester/runtests/views.py index 6e71c61..e1b5440 100644 --- a/apitester/runtests/views.py +++ b/apitester/runtests/views.py @@ -73,32 +73,33 @@ def get_post_or_update(self, method, testconfigs, testconfig_pk, path, data, swa try: objs = ProfileOperation.objects.filter( profile_id=testconfig_pk, - operation_id=data[method]['operationId'], - is_deleted=0 + operation_id=data[method]['operationId'] ) except ProfileOperation.DoesNotExist: objs = None request_body = {} urlpath = self.get_urlpath(testconfigs["selected"], path) + if objs is not None and len(objs)>0: objs_list = [] for obj in objs: - params = obj.json_body - order = obj.order - urlpath = obj.urlpath - replica_id = obj.replica_id - remark = obj.remark if obj.remark is not None else data[method]['summary'] - objs_list.append({ - 'urlpath': urlpath, - 'method': method, - 'order': order, - 'params': params, - 'summary': remark, - 'operationId': data[method]['operationId'], - 'replica_id':replica_id, - 'responseCode': 200, - }) + if obj.is_deleted==0: + params = obj.json_body + order = obj.order + urlpath = obj.urlpath + replica_id = obj.replica_id + remark = obj.remark if obj.remark is not None else data[method]['summary'] + objs_list.append({ + 'urlpath': urlpath, + 'method': method, + 'order': order, + 'params': params, + 'summary': remark, + 'operationId': data[method]['operationId'], + 'replica_id':replica_id, + 'responseCode': 200, + }) return objs_list elif method == 'post' or method == 'put': @@ -418,7 +419,8 @@ def saveJsonBody(request): 'profile_id': profile_id, 'order': order, 'urlpath': urlpath, - 'remark':remark + 'remark':remark, + 'is_deleted':0 } profile_list = ProfileOperation.objects.update_or_create( @@ -451,7 +453,7 @@ def copyJsonBody(request): replica_id = max([profile.replica_id for profile in profile_list])+1 - ProfileOperation.objects.create(profile_id = profile_id, operation_id = operation_id, json_body = json_body, order = order, urlpath = urlpath, remark=remark, replica_id = replica_id) + ProfileOperation.objects.create(profile_id = profile_id, operation_id = operation_id, json_body = json_body, order = order, urlpath = urlpath, remark=remark, replica_id = replica_id, is_deleted=0) return JsonResponse({'state': True})