@@ -968,29 +968,21 @@ def admin_file_download(id, uuid):
968968 return send_from_directory (receipt_dir , file , as_attachment = True )
969969
970970
971- def get_cosign_cookies ():
972- name = request .environ ['COSIGN_SERVICE' ]
973- value = request .cookies [name ]
974- filename = name + '=' + value .partition ('/' )[0 ]
975- result = {}
976- with open (os .path .join (app .config ['COSIGN_PROXY_DIR' ],
977- filename )) as f :
978- for line in f :
979- # Remove starting "x" and everything after the space.
980- name , _ , value = line [1 :].split ()[0 ].partition ('=' )
981- result [name ] = value
982- return result
971+ def create_votr_context (* , beta ):
972+ from .ais_utils import create_context
973+ return create_context (
974+ my_entity_id = app .config ['MY_ENTITY_ID' ],
975+ andrvotr_api_key = app .config ['ANDRVOTR_API_KEY' ],
976+ andrvotr_authority_token = request .environ ['ANDRVOTR_AUTHORITY_TOKEN' ],
977+ beta = beta ,
978+ )
983979
984980
985981@app .route ('/admin/ais_test' )
986982@require_remote_user
987983def admin_ais_test ():
988- from .ais_utils import (create_context , test_ais )
989- cosign_cookies = get_cosign_cookies ()
990- ctx = create_context (cosign_cookies ,
991- origin = 'ais2.uniba.sk' )
992- # Do log in
993- ctx .request_html ('/ais/loginCosign.do' , method = 'POST' )
984+ from .ais_utils import test_ais
985+ ctx = create_votr_context (beta = False )
994986 test_ais (ctx )
995987 return redirect (url_for ('admin_list' ))
996988
@@ -1140,17 +1132,9 @@ def admin_process_special(id, process_type):
11401132
11411133
11421134def send_application_to_ais2 (id , application , form , process_type , beta = False ):
1143- from .ais_utils import ( create_context , save_application_form )
1135+ from .ais_utils import save_application_form
11441136 if form .validate_on_submit ():
1145- origin = 'ais2.uniba.sk'
1146- if beta :
1147- origin = 'ais2-beta.uniba.sk'
1148-
1149- cosign_cookies = get_cosign_cookies ()
1150- ctx = create_context (cosign_cookies ,
1151- origin = origin )
1152- # Do log in
1153- ctx .request_html ('/ais/loginCosign.do' , method = 'POST' )
1137+ ctx = create_votr_context (beta = beta )
11541138
11551139 ais2_output = None
11561140 error_output = None
0 commit comments