Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test aisiklu a prihlasovanie sa na AIS betu #146

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions fladgejt/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,22 @@ def get_cosign_cookies(server, params, logger):
if key in server:
result[server[key]] = session.cookies[server[key]]

# - namiesto <hodnota> 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="<hodnota>"?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'], password=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']
Expand Down
3 changes: 2 additions & 1 deletion fladgejt/webui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
136 changes: 136 additions & 0 deletions fladgejt/webui/test_aisikl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import aisikl
from aisikl.app import Application


class WebuiTestAisiklMixin:

_testing_started = set()
_seen_types = 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

# zaznamenavanie typov
def _process(self, app):
for dialog in app.dialog_stack:
for c in dialog.components.values():
if c.component_type not in seen_types:
_seen_types.add(c.component_type)
self.context.log('benchmark', "Saw " + str(c.component_type) + " '" + str(repr(c.id)) + "'")

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()
_process(app)
buttons = [cname for cname in app.d.components if type(app.d.components[cname]) == aisikl.components.button.Button]
_sort_buttons(buttons)
for b in buttons:
app.d.components[b].click()
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) # vsetko odsuhlasime
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):
if len(ops) == 3: # kvoli aplikacii VSUB051
app.close_all_dialogs()
return
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])
_test_inside_app(app, o)
else:
app.awaited_open_main_dialog(ops)
_process(app)
buttons = [cname for cname in app.d.components if type(app.d.components[cname]) == aisikl.components.button.Button]
_sort_buttons(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
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')
4 changes: 2 additions & 2 deletions votrfront/default_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
),
dict(
title='ais2-beta.uniba.sk',
login_types=('cosignpassword', 'cosigncookie'),
login_types=('samlpassword'),
ais_cookie='JSESSIONID',
ais_url='https://ais2-beta.uniba.sk/',
),
Expand All @@ -57,7 +57,7 @@
),
dict(
title='ais2-test.uniba.sk',
login_types=('cosignpassword', 'cosigncookie'),
login_types=('samlpassword'),
ais_cookie='JSESSIONID',
ais_url='https://ais2-test.uniba.sk/',
),
Expand Down
2 changes: 1 addition & 1 deletion votrfront/js/LoginPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class LoginForm extends React.Component {
<input type="hidden" name="type" value={currentType} />
}

{(currentType == 'cosignpassword' || currentType == 'plainpassword') &&
{(currentType == 'cosignpassword' || currentType == 'plainpassword' || currentType == 'samlpassword') &&
<React.Fragment>
<p>
<label>
Expand Down