From 146ea4c3c4770d74890fc6049658b4b8477e460c Mon Sep 17 00:00:00 2001 From: itmat0 <52215326+itmat0@users.noreply.github.com> Date: Tue, 25 Jun 2019 22:12:27 +0200 Subject: [PATCH 01/10] Add files via upload --- fladgejt/webui/test_aisikl.py | 130 ++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 fladgejt/webui/test_aisikl.py diff --git a/fladgejt/webui/test_aisikl.py b/fladgejt/webui/test_aisikl.py new file mode 100644 index 0000000..5c1a95d --- /dev/null +++ b/fladgejt/webui/test_aisikl.py @@ -0,0 +1,130 @@ +import aisikl +from aisikl.app import Application + + +class WebuiTestAisiklMixin: + + _testing_started = set() + + # aby tlacidla, ktore zatvaraju dialog, boli stlacene ako posledne + def _sort_buttons(self, buts): + if 'enterButton' in buts: + buts.remove('enterButton') + buts.append('enterButton') + if 'closeButton' in buts: + buts.remove('closeButton') + buts.append('closeButton') + elif 'exitButton' in buts: + buts.remove('exitButton') + buts.append('exitButton') + + # ci uz otvarana aplikacia zacala byt niekedy testovana + def _check_testing_started(self, app, ops): + if (ops[0].method == 'openMainDialog' or ops[0].method == 'openDialog') and len(ops[0].args[0]['code']) > 0: + if ops[0].args[0]['code'] in _testing_started: + return True + else: + _testing_started.add(ops[0].args[0]['code']) + return False + + def _test_inside_app(self, app, o): + if len(o) == 2: # kvoli AS042 -> stavy prispevku; predpokladame, ze viac ako 2 operacie tu nedostaneme + t1 = _test_inside_app(app, o[:1]) + t2 = _test_inside_app(app, o[1:]) + if t1 == 'serverCloseApplication' or t2 == 'serverCloseApplication': # toto je len pre uplnost, asi to nenastane + return 'serverCloseApplication' + if t1 == 'closeDialog' or t2 == 'closeDialog': + return 'closeDialog' + return t1 + if o[0].method == 'openDialog': + app.awaited_open_dialog(o) + name = o[0].args[0]['id'] + o.pop() + buttons = [cname for cname in app.d.components if type(app.d.components[cname]) == aisikl.components.button.Button] + _sort_buttons(buttons) + print(buttons) + for b in buttons: + app.d.components[b].click() + print(o) + if len(o) > 0: + if _check_testing_started(app, o): + continue + t = _test_inside_app(app, o) + if t == 'closeDialog': + break + if t == 'serverCloseApplication': + return 'serverCloseApplication' + if buttons == []: # kvoli situacii pri prihlasovani sa na skusky -> dialog podrobne info + app.close_dialog(name) + return 'openDialog' + if o[0].method == 'confirmBox': + app.confirm_box(-2) # DEFAULT + o.pop() + return 'confirmBox' + if o[0].method == 'closeDialog': + app.awaited_close_dialog(o) + o.pop() + return 'closeDialog' + if o[0].method == 'abortBox': + app.awaited_abort_box(o) + o.pop() + return 'abortBox' + if o[0].method == 'startApp': + a, ops = app.awaited_start_app(o) + if not _check_testing_started(app, ops): + _test_app(a, ops) + o.pop() + return 'startApp' + if o[0].method == 'messageBox': + o.pop() + return 'messageBox' + if o[0].method == 'refreshDialog': + app.awaited_refresh_dialog(o) + o.pop() + return 'refreshDialog' + if o[0].method == 'serverCloseApplication': + app.close_all_dialogs() + return 'serverCloseApplication' + if o[0].method == 'shellExec': + o.pop() + return 'shellExec' + + def _test_app(self, app, ops): + print(ops) + if len(ops) == 3: # kvoli aplikacii VSUB051 + app.close_all_dialogs() + return + if len(ops) == 2: # obcas vyskocia hned 2 okna; predpokladame, ze viac nie + app.awaited_open_main_dialog(ops[:1]) + with app.collect_operations() as o: + o.append(ops[1]) + _test_inside_app(app, o) + else: + app.awaited_open_main_dialog(ops) + buttons = [cname for cname in app.d.components if type(app.d.components[cname]) == aisikl.components.button.Button] + _sort_buttons(buttons) + print(buttons) + for b in buttons: + with app.collect_operations() as ops: + try: # tento blok je tu kvoli refreshom v aplikacii VSES333 + app.d.components[b].click() + except KeyError: + continue + print(ops) + if len(ops) > 0: + if ops[0].method == 'serverCloseApplication': + app.close_all_dialogs() + break + if _check_testing_started(app, ops): + continue + if _test_inside_app(app, ops) == 'serverCloseApplication': + break + + def test(self): + apps = aisikl.portal.get_apps(self.context) + del apps['SSSP031'] # pri otvarani vyhodi AISParseError + for a in apps: + app, ops = Application.open(self.context, apps[a].url) + if not _check_testing_started(app, ops): + _test_app(app, ops) + self.context.log('benchmark', 'Test successfully finished') From 43ebfdfc0c973bc4dec30add0097b63892f18f0e Mon Sep 17 00:00:00 2001 From: itmat0 <52215326+itmat0@users.noreply.github.com> Date: Tue, 25 Jun 2019 22:19:01 +0200 Subject: [PATCH 02/10] Update test_aisikl.py --- fladgejt/webui/test_aisikl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fladgejt/webui/test_aisikl.py b/fladgejt/webui/test_aisikl.py index 5c1a95d..d4952db 100644 --- a/fladgejt/webui/test_aisikl.py +++ b/fladgejt/webui/test_aisikl.py @@ -58,7 +58,7 @@ def _test_inside_app(self, app, o): app.close_dialog(name) return 'openDialog' if o[0].method == 'confirmBox': - app.confirm_box(-2) # DEFAULT + app.confirm_box(2) # vsetko odsuhlasime o.pop() return 'confirmBox' if o[0].method == 'closeDialog': @@ -94,7 +94,7 @@ def _test_app(self, app, ops): if len(ops) == 3: # kvoli aplikacii VSUB051 app.close_all_dialogs() return - if len(ops) == 2: # obcas vyskocia hned 2 okna; predpokladame, ze viac nie + if len(ops) == 2: # obcas vyskocia hned 2 okna app.awaited_open_main_dialog(ops[:1]) with app.collect_operations() as o: o.append(ops[1]) From 71198411bbd2fd2e15a00a3cc16faba10693a8bd Mon Sep 17 00:00:00 2001 From: itmat0 <52215326+itmat0@users.noreply.github.com> Date: Tue, 25 Jun 2019 22:23:08 +0200 Subject: [PATCH 03/10] Update __init__.py --- fladgejt/webui/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fladgejt/webui/__init__.py b/fladgejt/webui/__init__.py index 834a45c..4f9b1e8 100644 --- a/fladgejt/webui/__init__.py +++ b/fladgejt/webui/__init__.py @@ -8,11 +8,12 @@ from .studium import WebuiStudiumMixin from .terminy import WebuiTerminyMixin from .zapis import WebuiZapisMixin +from .test_aisikl import WebuiTestAisiklMixin class WebuiClient(WebuiCommonUIMixin, WebuiHodnoteniaMixin, WebuiObdobiaMixin, WebuiOsobyMixin, WebuiPredmetyMixin, WebuiStudiumMixin, - WebuiTerminyMixin, WebuiZapisMixin): + WebuiTerminyMixin, WebuiZapisMixin, WebuiTestAisiklMixin): def __init__(self, context): self.context = context From 82ca342fc4017ed7ed7a18ebbef5cce93b2c3921 Mon Sep 17 00:00:00 2001 From: itmat0 <52215326+itmat0@users.noreply.github.com> Date: Wed, 26 Jun 2019 01:45:15 +0200 Subject: [PATCH 04/10] Update login.py --- fladgejt/login.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/fladgejt/login.py b/fladgejt/login.py index e17c020..2379612 100644 --- a/fladgejt/login.py +++ b/fladgejt/login.py @@ -61,6 +61,22 @@ def get_cosign_cookies(server, params, logger): if key in server: result[server[key]] = session.cookies[server[key]] + # - namiesto ma byt konkretne jsessionid, ako ho dostanem? Zda sa, ze to nie je + # to iste ako na ais2-beta.uniba.sk; + # - takto sa to sprava pri prvom pokuse, ale pri druhom, tretom atd. je to trochu ine, ako to riesit? + if params['type'] == 'samlpassword': + url = 'idp.uniba.sk/idp/profile/SAML2/Redirect/SSO;jsessionid=""?execution=e1s1' + + session, send_request = get_login_session(logger) + send_request('POST', url) + + form_submit_url = 'ais2-beta.uniba.sk/ais/login.do' + send_request('POST', form_submit_url, data=dict( + login=params['username'], params=['password'], ref=url) + + if 'ais_cookie' in server: + result[server['ais_cookie']] = session.cookies[server['ais_cookie']] + if params['type'] == 'cosignproxy': # http://webapps.itcs.umich.edu/cosign/index.php/Using_Proxy_Cookies name, value = params['cosign_service'] From a06355c528996f44da0b764f594722094195bb3f Mon Sep 17 00:00:00 2001 From: itmat0 <52215326+itmat0@users.noreply.github.com> Date: Wed, 26 Jun 2019 01:47:37 +0200 Subject: [PATCH 05/10] Update login.py --- fladgejt/login.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fladgejt/login.py b/fladgejt/login.py index 2379612..aaad799 100644 --- a/fladgejt/login.py +++ b/fladgejt/login.py @@ -72,7 +72,7 @@ def get_cosign_cookies(server, params, logger): form_submit_url = 'ais2-beta.uniba.sk/ais/login.do' send_request('POST', form_submit_url, data=dict( - login=params['username'], params=['password'], ref=url) + login=params['username'], password=params['password'], ref=url) if 'ais_cookie' in server: result[server['ais_cookie']] = session.cookies[server['ais_cookie']] From f8a2b7c2bb219a704bc3d31f8197ecbeae6eba01 Mon Sep 17 00:00:00 2001 From: itmat0 <52215326+itmat0@users.noreply.github.com> Date: Wed, 26 Jun 2019 01:48:39 +0200 Subject: [PATCH 06/10] Update login.py --- fladgejt/login.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fladgejt/login.py b/fladgejt/login.py index aaad799..17b0f4f 100644 --- a/fladgejt/login.py +++ b/fladgejt/login.py @@ -72,7 +72,7 @@ def get_cosign_cookies(server, params, logger): form_submit_url = 'ais2-beta.uniba.sk/ais/login.do' send_request('POST', form_submit_url, data=dict( - login=params['username'], password=params['password'], ref=url) + login=params['username'], password=params['password'], ref=url)) if 'ais_cookie' in server: result[server['ais_cookie']] = session.cookies[server['ais_cookie']] From c77e5fc9644e1a5c8dc041ea7d688621213c95c2 Mon Sep 17 00:00:00 2001 From: itmat0 <52215326+itmat0@users.noreply.github.com> Date: Wed, 26 Jun 2019 01:52:05 +0200 Subject: [PATCH 07/10] Update LoginPage.js --- votrfront/js/LoginPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/votrfront/js/LoginPage.js b/votrfront/js/LoginPage.js index 36b33ab..27bb71f 100644 --- a/votrfront/js/LoginPage.js +++ b/votrfront/js/LoginPage.js @@ -89,7 +89,7 @@ export class LoginForm extends React.Component { } - {(currentType == 'cosignpassword' || currentType == 'plainpassword') && + {(currentType == 'cosignpassword' || currentType == 'plainpassword' || currentType == 'samlpassword') &&