Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
simonredfern committed Feb 1, 2019
2 parents cc482c0 + 7212ec3 commit faa2a67
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 49 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ API_HOST = '<hostname>'

# 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 = '<key>'
OAUTH_CONSUMER_SECRET = '<secret>'

Expand Down
7 changes: 5 additions & 2 deletions apitester/apitester/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
'obp': {
'handlers': ['console'],
'level': 'INFO',
},
}
},
}

Expand Down Expand Up @@ -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
Expand All @@ -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'

#OAUTH_BASE_URL='https://apisandbox.openbankproject.com'
69 changes: 43 additions & 26 deletions apitester/runtests/static/runtests/js/runtests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
});

Expand Down Expand Up @@ -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() {
Expand All @@ -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) {
Expand Down
5 changes: 4 additions & 1 deletion apitester/runtests/templates/runtests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,11 @@ <h2>{{ config.name }}</h2>
<div class="col-xs-12 col-sm-2">
<button class="btn btn-default form-control" id="checkAll" />Check all</button>
</div>
<div class="col-xs-12 col-sm-2">
<button class="btn btn-default form-control" id="removeUncheck" />Remove uncheck</button>
</div>
<div class="col-xs-2">
<label>runs num: </label><input type="text" name="numRun" size="1" value=1 />
<label>runs num: </label><input type="text" id="numRun" size="1" value=1 />
</div>
</div>
</div>
Expand Down
40 changes: 21 additions & 19 deletions apitester/runtests/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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})

Expand Down

0 comments on commit faa2a67

Please sign in to comment.