Skip to content
Snippets Groups Projects
Commit 31656d98 authored by Marco Malavolti's avatar Marco Malavolti
Browse files

Fixed IdP DisplayName

parent 04ef7b93
Branches
Tags
No related merge requests found
...@@ -20,20 +20,22 @@ from utils import getLogger, getIdPContacts, getDriver ...@@ -20,20 +20,22 @@ from utils import getLogger, getIdPContacts, getDriver
""" """
This script use Selenium and Chromium to select the IdP to check from a Shibboleth SP with the Shibboleth Embedded Discovery Service installed and configured to answer to all eduGAIN IdPs. The script works with 2 SPs that using Shibboleth Embedded Discovery Service to allow IdP selection on their login page.
The SPs used to check an IdP will be SP24(IDEM) and Attribute Viewer (SWITCH). The script has been written to simulate an user that inserts the IdP's entityID into the EDS search box and press "Enter" to load its Login Page. The Login Page MUST presents the fields "username" and "password" to pass the check on each SP involved into the test.
The check will be passed when both SPs will return the authentication page of the IdP checked. If the IdP Login page presente the fields for both selected SP the test is passed, otherwise it is failed.
""" """
# The function check that the IdP recognized the SP by presenting its Login page.
# If the IdP Login page contains "username" and "password" fields, than the test is passed.
def checkIdP(sp,idp): def checkIdP(sp,idp):
# Chromedriver MUST be instanced here to avoid problems with SESSION # Chromedriver MUST be instanced here to avoid problems with SESSION
# Disable SSL requests warning messages # Disable SSL requests warning messages
requests.packages.urllib3.disable_warnings() requests.packages.urllib3.disable_warnings()
debugSelenium = ECCS2SELENIUMDEBUG debug_selenium = ECCS2SELENIUMDEBUG
fqdn_idp = parse_url(idp['entityID'])[2] fqdn_idp = parse_url(idp['entityID'])[2]
driver = getDriver(fqdn_idp,debugSelenium) driver = getDriver(fqdn_idp,debug_selenium)
# Exception of WebDriver raises # Exception of WebDriver raises
if (driver == None): if (driver == None):
...@@ -60,7 +62,7 @@ def checkIdP(sp,idp): ...@@ -60,7 +62,7 @@ def checkIdP(sp,idp):
page_source = driver.page_source page_source = driver.page_source
samlrequest_url = driver.current_url samlrequest_url = driver.current_url
# Put the code of the page into an HTML file # Put the page_source into its HTML file
Path("%s/%s" % (ECCS2HTMLDIR,DAY)).mkdir(parents=True, exist_ok=True) Path("%s/%s" % (ECCS2HTMLDIR,DAY)).mkdir(parents=True, exist_ok=True)
fqdn_idp = parse_url(idp['entityID'])[2] fqdn_idp = parse_url(idp['entityID'])[2]
fqdn_sp = parse_url(sp)[2] fqdn_sp = parse_url(sp)[2]
...@@ -68,7 +70,7 @@ def checkIdP(sp,idp): ...@@ -68,7 +70,7 @@ def checkIdP(sp,idp):
html.write(page_source) html.write(page_source)
except TimeoutException as e: except TimeoutException as e:
return (idp['entityID'],sp,check_time,"999","Timeout") return (idp['entityID'],sp,check_time,"(failed)","Timeout")
except NoSuchElementException as e: except NoSuchElementException as e:
# The input of the bootstrap tables are provided by "eccs2" and "eccs2checks" log. # The input of the bootstrap tables are provided by "eccs2" and "eccs2checks" log.
...@@ -78,14 +80,14 @@ def checkIdP(sp,idp): ...@@ -78,14 +80,14 @@ def checkIdP(sp,idp):
print("!!! NO SUCH ELEMENT EXCEPTION - RUN AGAIN THE COMMAND !!!") print("!!! NO SUCH ELEMENT EXCEPTION - RUN AGAIN THE COMMAND !!!")
return None return None
except UnexpectedAlertPresentException as e: #except UnexpectedAlertPresentException as e:
return (idp['entityID'],sp,check_time,"888","ERROR") # return (idp['entityID'],sp,check_time,"888","ERROR")
except WebDriverException as e: #except WebDriverException as e:
print("!!! WEB DRIVER EXCEPTION - RUN AGAIN THE COMMAND!!!") # print("!!! WEB DRIVER EXCEPTION - RUN AGAIN THE COMMAND!!!")
print (e.__str__()) # print (e.__str__())
print ("IdP: %s\nSP: %s" % (idp['entityID'],sp)) # print ("IdP: %s\nSP: %s" % (idp['entityID'],sp))
return None # return None
except Exception as e: except Exception as e:
print ("!!! EXCEPTION !!!") print ("!!! EXCEPTION !!!")
...@@ -113,7 +115,7 @@ def checkIdP(sp,idp): ...@@ -113,7 +115,7 @@ def checkIdP(sp,idp):
#print("!!! REQUESTS STATUS CODE CONNECTION ERROR EXCEPTION !!!") #print("!!! REQUESTS STATUS CODE CONNECTION ERROR EXCEPTION !!!")
#print (e.__str__()) #print (e.__str__())
#print ("IdP: %s\nSP: %s" % (idp['entityID'],sp)) #print ("IdP: %s\nSP: %s" % (idp['entityID'],sp))
status_code = "000" status_code = "(failed)"
except requests.exceptions.Timeout as e: except requests.exceptions.Timeout as e:
#print("!!! REQUESTS STATUS CODE TIMEOUT EXCEPTION !!!") #print("!!! REQUESTS STATUS CODE TIMEOUT EXCEPTION !!!")
...@@ -147,58 +149,71 @@ def checkIdP(sp,idp): ...@@ -147,58 +149,71 @@ def checkIdP(sp,idp):
return (idp['entityID'],sp,check_time,status_code,"OK") return (idp['entityID'],sp,check_time,status_code,"OK")
def storeECCS2result(idp,results,idp_status): def getDisplayName(display_name):
display_name_equal_splitted = display_name.split('==')
for elem in display_name_equal_splitted:
if "en" in elem:
if "'" in elem:
elem = elem.replace("'","'")
if "'" in elem:
elem = elem.replace("'","'")
return elem.split(';')[1]
# Append the result of the check on a file
def storeECCS2result(idp,check_results,idp_status):
# Build the contacts lists: technical/support # Build the contacts lists: technical/support
listTechContacts = getIdPContacts(idp,'technical') list_technical_contacts = getIdPContacts(idp,'technical')
listSuppContacts = getIdPContacts(idp,'support') list_support_contacts = getIdPContacts(idp,'support')
strTechContacts = ','.join(listTechContacts) str_technical_contacts = ','.join(list_technical_contacts)
strSuppContacts = ','.join(listSuppContacts) str_support_contacts = ','.join(list_support_contacts)
# IdP-DisplayName;IdP-entityID;IdP-RegAuth;IdP-tech-ctc-1,IdP-tech-ctc-2;IdP-supp-ctc-1,IdP-supp-ctc-2;Status;SP-entityID-1;SP-check-time-1;SP-status-code-1;SP-result-1;SP-entityID-2;SP-check-time-2;SP-status-code-2;SP-result-2 # IdP-DisplayName;IdP-entityID;IdP-RegAuth;IdP-tech-ctc-1,IdP-tech-ctc-2;IdP-supp-ctc-1,IdP-supp-ctc-2;Status;SP-entityID-1;SP-check-time-1;SP-status-code-1;SP-result-1;SP-entityID-2;SP-check-time-2;SP-status-code-2;SP-result-2
with open("%s/%s" % (ECCS2OUTPUTDIR,ECCS2RESULTSLOG), 'a') as f: with open("%s/%s" % (ECCS2OUTPUTDIR,ECCS2RESULTSLOG), 'a') as f:
f.write("%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s\n" % ( f.write("%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s\n" % (
idp['displayname'].replace("'","'").replace("'","'").split(';')[1].split('==')[0], # IdP-DisplayName getDisplayName(idp['displayname']), # IdP-DisplayName
idp['entityID'], # IdP-entityID idp['entityID'], # IdP-entityID
idp['registrationAuthority'], # IdP-RegAuth idp['registrationAuthority'], # IdP-RegAuth
strTechContacts, # IdP-TechCtcsList str_technical_contacts, # IdP-TechCtcsList
strSuppContacts, # IdP-SuppCtcsList str_support_contacts, # IdP-SuppCtcsList
idp_status, # IdP-ECCS-Status idp_status, # IdP-ECCS-Status
results[0][1], # SP-entityID-1 check_results[0][1], # SP-entityID-1
results[0][2], # SP-check-time-1 check_results[0][2], # SP-check-time-1
results[0][3], # SP-status-code-1 check_results[0][3], # SP-status-code-1
results[0][4], # SP-result-1 check_results[0][4], # SP-result-1
results[1][1], # SP-entityID-2 check_results[1][1], # SP-entityID-2
results[1][2], # SP-check-time-2 check_results[1][2], # SP-check-time-2
results[1][3], # SP-status-code-2 check_results[1][3], # SP-status-code-2
results[1][4])) # SP-result-2 check_results[1][4])) # SP-result-2
# Check an IdP with 2 SPs.
def check(idp,sps): def check(idp,sps):
results = [] check_results = []
for sp in sps: for sp in sps:
resultCheck = checkIdP(sp,idp) result = checkIdP(sp,idp)
# Se il checkIdP ha successo, aggiungo alla lista dei check # Se il checkIdP ha successo, aggiungo alla lista dei check
# altrimenti no. # altrimenti no.
if resultCheck is not None: if result is not None:
results.append(resultCheck) check_results.append(result)
if len(results) == 2: if len(check_results) == 2:
with open("%s/%s" % (ECCS2OUTPUTDIR,ECCS2CHECKSLOG), 'a') as f: with open("%s/%s" % (ECCS2OUTPUTDIR,ECCS2CHECKSLOG), 'a') as f:
for elem in results: for elem in check_results:
f.write(";".join(elem)) f.write(";".join(elem))
f.write("\n") f.write("\n")
# If all checks are 'OK', than the IdP consuming correctly eduGAIN Metadata. # If all checks are 'OK', than the IdP consuming correctly eduGAIN Metadata.
if (results[0][4] == results[1][4] == "OK"): if (check_results[0][4] == check_results[1][4] == "OK"):
storeECCS2result(idp,results,'OK') storeECCS2result(idp,check_results,'OK')
elif (results[0][4] == results[1][4] == "DISABLED"): elif (check_results[0][4] == check_results[1][4] == "DISABLED"):
storeECCS2result(idp,results,'DISABLED') storeECCS2result(idp,check_results,'DISABLED')
else: else:
storeECCS2result(idp,results,'ERROR') storeECCS2result(idp,check_results,'ERROR')
# MAIN # MAIN
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment