Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
eduGAIN Connectivity Check
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
edugain
eduGAIN Connectivity Check
Commits
901f38d6
Commit
901f38d6
authored
5 years ago
by
Marco Malavolti
Browse files
Options
Downloads
Patches
Plain Diff
Fixed ECCS2 python-selenium script
parent
999903ea
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
eccs2.py
+32
-43
32 additions, 43 deletions
eccs2.py
extractFederation.py
+0
-38
0 additions, 38 deletions
extractFederation.py
input/.gitignore
+4
-0
4 additions, 0 deletions
input/.gitignore
selenium-logs/.gitignore
+4
-0
4 additions, 0 deletions
selenium-logs/.gitignore
with
40 additions
and
81 deletions
eccs2.py
+
32
−
43
View file @
901f38d6
...
@@ -13,14 +13,10 @@ from eccs2properties import ECCS2LOGSDIR, ECCS2RESULTSLOG, ECCS2CHECKSLOG, ECCS2
...
@@ -13,14 +13,10 @@ from eccs2properties import ECCS2LOGSDIR, ECCS2RESULTSLOG, ECCS2CHECKSLOG, ECCS2
from
selenium
import
webdriver
from
selenium
import
webdriver
from
selenium.webdriver.common.by
import
By
from
selenium.webdriver.common.by
import
By
from
selenium.webdriver.common.keys
import
Keys
from
selenium.webdriver.common.keys
import
Keys
from
selenium.webdriver.support.ui
import
Select
from
selenium.webdriver.support.ui
import
Select
,
WebDriverWait
from
selenium.webdriver.support.ui
import
WebDriverWait
from
selenium.webdriver.support
import
expected_conditions
as
EC
from
selenium.webdriver.support
import
expected_conditions
as
EC
from
selenium.webdriver.remote.remote_connection
import
LOGGER
from
selenium.webdriver.remote.remote_connection
import
LOGGER
from
selenium.common.exceptions
import
NoSuchElementException
from
selenium.common.exceptions
import
NoSuchElementException
,
TimeoutException
,
WebDriverException
,
UnexpectedAlertPresentException
from
selenium.common.exceptions
import
TimeoutException
from
selenium.common.exceptions
import
WebDriverException
from
selenium.common.exceptions
import
UnexpectedAlertPresentException
from
urllib3.exceptions
import
MaxRetryError
from
urllib3.exceptions
import
MaxRetryError
from
urllib3.util
import
parse_url
from
urllib3.util
import
parse_url
...
@@ -31,7 +27,28 @@ from urllib3.util import parse_url
...
@@ -31,7 +27,28 @@ from urllib3.util import parse_url
The check will be passed when both SPs will return the authentication page of the IdP checked.
The check will be passed when both SPs will return the authentication page of the IdP checked.
"""
"""
def
checkIdP
(
sp
,
idp
,
logger
,
driver
):
#def checkIdP(sp,idp,logger,driver):
def
checkIdP
(
sp
,
idp
,
logger
):
# Chromedriver MUST be instanced here to avoid problems with SESSION
# Disable SSL requests warning messages
requests
.
packages
.
urllib3
.
disable_warnings
()
# Configure Web-driver
chrome_options
=
webdriver
.
ChromeOptions
()
chrome_options
.
add_argument
(
'
--headless
'
)
chrome_options
.
add_argument
(
'
--no-sandbox
'
)
chrome_options
.
add_argument
(
'
--disable-dev-shm-usage
'
)
chrome_options
.
add_argument
(
'
--ignore-certificate-errors
'
)
driver
=
webdriver
.
Chrome
(
'
chromedriver
'
,
options
=
chrome_options
)
# For DEBUG only (By default ChromeDriver logs only warnings/errors to stderr. When debugging issues, it is helpful to enable more verbose logging.)
#driver = webdriver.Chrome('chromedriver', options=chrome_options, service_args=['--verbose', '--log-path=%s/%s.log' % (ECCS2SELENIUMLOGDIR, parse_url(idp['entityID'])[2])])
# Configure timeouts
driver
.
set_page_load_timeout
(
"
%d
"
%
ECCS2SELENIUMPAGELOADTIMEOUT
)
driver
.
set_script_timeout
(
"
%d
"
%
ECCS2SELENIUMSCRIPTTIMEOUT
)
# Configure Blacklists
# Configure Blacklists
federation_blacklist
=
FEDS_BLACKLIST
federation_blacklist
=
FEDS_BLACKLIST
...
@@ -52,6 +69,7 @@ def checkIdP(sp,idp,logger,driver):
...
@@ -52,6 +69,7 @@ def checkIdP(sp,idp,logger,driver):
element
.
send_keys
(
idp
[
'
entityID
'
]
+
Keys
.
ENTER
)
element
.
send_keys
(
idp
[
'
entityID
'
]
+
Keys
.
ENTER
)
page_source
=
driver
.
page_source
page_source
=
driver
.
page_source
status_code
=
requests
.
get
(
driver
.
current_url
,
verify
=
False
).
status_code
status_code
=
requests
.
get
(
driver
.
current_url
,
verify
=
False
).
status_code
driver
.
quit
()
except
TimeoutException
as
e
:
except
TimeoutException
as
e
:
logger
.
info
(
"
%s;%s;999;Timeout
"
%
(
idp
[
'
entityID
'
],
sp
))
logger
.
info
(
"
%s;%s;999;Timeout
"
%
(
idp
[
'
entityID
'
],
sp
))
...
@@ -71,6 +89,7 @@ def checkIdP(sp,idp,logger,driver):
...
@@ -71,6 +89,7 @@ def checkIdP(sp,idp,logger,driver):
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__
())
return
None
return
None
except
requests
.
exceptions
.
ConnectionError
as
e
:
except
requests
.
exceptions
.
ConnectionError
as
e
:
...
@@ -91,6 +110,9 @@ def checkIdP(sp,idp,logger,driver):
...
@@ -91,6 +110,9 @@ def checkIdP(sp,idp,logger,driver):
print
(
e
.
__str__
())
print
(
e
.
__str__
())
return
None
return
None
finally
:
driver
.
quit
()
pattern_metadata
=
"
Unable.to.locate(\sissuer.in|).metadata(\sfor|)|no.metadata.found|profile.is.not.configured.for.relying.party|Cannot.locate.entity|fail.to.load.unknown.provider|does.not.recognise.the.service|unable.to.load.provider|Nous.n
'
avons.pas.pu.(charg|charger).le.fournisseur.de service|Metadata.not.found|application.you.have.accessed.is.not.registered.for.use.with.this.service|Message.did.not.meet.security.requirements
"
pattern_metadata
=
"
Unable.to.locate(\sissuer.in|).metadata(\sfor|)|no.metadata.found|profile.is.not.configured.for.relying.party|Cannot.locate.entity|fail.to.load.unknown.provider|does.not.recognise.the.service|unable.to.load.provider|Nous.n
'
avons.pas.pu.(charg|charger).le.fournisseur.de service|Metadata.not.found|application.you.have.accessed.is.not.registered.for.use.with.this.service|Message.did.not.meet.security.requirements
"
pattern_username
=
'
<input[\s]+[^>]*((type=\s*[
\'
"
](text|email)[
\'
"
]|user)|(name=\s*[
\'
"
](name)[
\'
"
]))[^>]*>
'
;
pattern_username
=
'
<input[\s]+[^>]*((type=\s*[
\'
"
](text|email)[
\'
"
]|user)|(name=\s*[
\'
"
](name)[
\'
"
]))[^>]*>
'
;
...
@@ -101,15 +123,12 @@ def checkIdP(sp,idp,logger,driver):
...
@@ -101,15 +123,12 @@ def checkIdP(sp,idp,logger,driver):
password_found
=
re
.
search
(
pattern_password
,
page_source
,
re
.
I
)
password_found
=
re
.
search
(
pattern_password
,
page_source
,
re
.
I
)
if
(
metadata_not_found
):
if
(
metadata_not_found
):
#print("MD-NOT-FOUND - driver.current_url: %s" % (driver.current_url))
logger
.
info
(
"
%s;%s;%s;No-eduGAIN-Metadata
"
%
(
idp
[
'
entityID
'
],
sp
,
status_code
))
logger
.
info
(
"
%s;%s;%s;No-eduGAIN-Metadata
"
%
(
idp
[
'
entityID
'
],
sp
,
status_code
))
return
"
No-eduGAIN-Metadata
"
return
"
No-eduGAIN-Metadata
"
elif
not
username_found
or
not
password_found
:
elif
not
username_found
or
not
password_found
:
#print("INVALID-FORM - entityID: %s, sp: %s, driver.current_url: %s" % (idp['entityID'],sp,driver.current_url))
logger
.
info
(
"
%s;%s;%s;Invalid-Form
"
%
(
idp
[
'
entityID
'
],
sp
,
status_code
))
logger
.
info
(
"
%s;%s;%s;Invalid-Form
"
%
(
idp
[
'
entityID
'
],
sp
,
status_code
))
return
"
Invalid-Form
"
return
"
Invalid-Form
"
else
:
else
:
#print("MD-FOUND - driver.current_url: %s" % (driver.current_url))
logger
.
info
(
"
%s;%s;%s;OK
"
%
(
idp
[
'
entityID
'
],
sp
,
status_code
))
logger
.
info
(
"
%s;%s;%s;OK
"
%
(
idp
[
'
entityID
'
],
sp
,
status_code
))
return
"
OK
"
return
"
OK
"
...
@@ -160,10 +179,10 @@ def getIdPContacts(idp,contactType):
...
@@ -160,10 +179,10 @@ def getIdPContacts(idp,contactType):
return
ctcList
return
ctcList
def
checkIdp
(
idp
,
sps
,
eccs2log
,
eccs2checksLog
,
driver
):
def
checkIdp
(
idp
,
sps
,
eccs2log
,
eccs2checksLog
):
result
=
[]
result
=
[]
for
sp
in
sps
:
for
sp
in
sps
:
resultCheck
=
checkIdP
(
sp
,
idp
,
eccs2checksLog
,
driver
)
resultCheck
=
checkIdP
(
sp
,
idp
,
eccs2checksLog
)
result
.
append
(
resultCheck
)
result
.
append
(
resultCheck
)
listTechContacts
=
getIdPContacts
(
idp
,
'
technical
'
)
listTechContacts
=
getIdPContacts
(
idp
,
'
technical
'
)
...
@@ -229,34 +248,4 @@ if __name__=="__main__":
...
@@ -229,34 +248,4 @@ if __name__=="__main__":
idp
=
json
.
loads
(
args
.
idpJson
[
0
])
idp
=
json
.
loads
(
args
.
idpJson
[
0
])
# Disable SSL requests warning messages
checkIdp
(
idp
,
sps
,
eccs2log
,
eccs2checksLog
)
requests
.
packages
.
urllib3
.
disable_warnings
()
# Configure Web-driver
chrome_options
=
webdriver
.
ChromeOptions
()
chrome_options
.
add_argument
(
'
--headless
'
)
chrome_options
.
add_argument
(
'
--no-sandbox
'
)
chrome_options
.
add_argument
(
'
--disable-dev-shm-usage
'
)
chrome_options
.
add_argument
(
'
--ignore-certificate-errors
'
)
chrome_options
.
add_argument
(
'
--start-maximized
'
)
chrome_options
.
add_argument
(
'
--disable-extensions
'
)
#driver = webdriver.Chrome('chromedriver', options=chrome_options)
# For DEBUG only (By default ChromeDriver logs only warnings/errors to stderr. When debugging issues, it is helpful to enable more verbose logging.)
#driver = webdriver.Chrome('chromedriver', options=chrome_options, service_args=['--log-path=%s/%s.log' % (ECCS2SELENIUMLOGDIR, parse_url(idp['entityID'])[2])])
driver
=
webdriver
.
Chrome
(
'
chromedriver
'
,
options
=
chrome_options
,
service_args
=
[
'
--verbose
'
,
'
--log-path=%s/%s.log
'
%
(
ECCS2SELENIUMLOGDIR
,
parse_url
(
idp
[
'
entityID
'
])[
2
])])
# Configure timeouts
driver
.
set_page_load_timeout
(
"
%d
"
%
ECCS2SELENIUMPAGELOADTIMEOUT
)
driver
.
set_script_timeout
(
"
%d
"
%
ECCS2SELENIUMSCRIPTTIMEOUT
)
checkIdp
(
idp
,
sps
,
eccs2log
,
eccs2checksLog
,
driver
)
#driver.delete_all_cookies()
driver
.
close
()
# I need to use "close()" or the driver's process remains active
driver
.
quit
()
# Kill process to release resources and to avoid zombies - this reaise an issue
#pid = os.getpid()
#os.kill(pid, signal.SIGTERM)
This diff is collapsed.
Click to expand it.
extractFederation.py
deleted
100755 → 0
+
0
−
38
View file @
999903ea
#!/usr/bin/env python3
def
getIdPs
():
import
certifi
import
urllib3
import
json
manager
=
urllib3
.
PoolManager
(
cert_reqs
=
'
CERT_REQUIRED
'
,
ca_certs
=
certifi
.
where
()
)
url
=
"
https://technical.edugain.org/api.php?action=list_eccs_idps
"
idp_json
=
manager
.
request
(
'
GET
'
,
url
)
idp_dict
=
json
.
loads
(
idp_json
.
data
.
decode
(
'
utf-8
'
))
idp_list
=
[]
#federation = input("Insert the registrationAuthority: ")
federation
=
"
http://www.idem.garr.it/
"
for
idp
in
idp_dict
:
if
(
idp
[
'
registrationAuthority
'
]
==
federation
):
idp_list
.
append
(
idp
)
return
json
.
dumps
(
idp_list
)
# MAIN
if
__name__
==
"
__main__
"
:
data
=
getIdPs
()
f
=
open
(
'
federation_idps.txt
'
,
'
w
'
)
f
.
write
(
data
)
f
.
close
()
This diff is collapsed.
Click to expand it.
input/.gitignore
0 → 100644
+
4
−
0
View file @
901f38d6
# Ignore everything in this directory
*
# Except this file
!.gitignore
This diff is collapsed.
Click to expand it.
selenium-logs/.gitignore
0 → 100644
+
4
−
0
View file @
901f38d6
# Ignore everything in this directory
*
# Except this file
!.gitignore
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment