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
c8a42e03
Commit
c8a42e03
authored
5 years ago
by
Marco Malavolti
Browse files
Options
Downloads
Patches
Plain Diff
Used logging to separate results
parent
0fa338dd
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
eccs2.py
+38
-12
38 additions, 12 deletions
eccs2.py
logs/.gitignore
+4
-0
4 additions, 0 deletions
logs/.gitignore
with
42 additions
and
12 deletions
eccs2.py
+
38
−
12
View file @
c8a42e03
...
...
@@ -47,7 +47,7 @@ def getIdPs():
return
idp_list
def
checkIdP
(
driver
,
sp
,
idp
):
def
checkIdP
(
driver
,
sp
,
idp
,
logger
):
import
re
# Apro la URL contenente il Discovery Service, inserisco l'idp e vado alla pagina di login
...
...
@@ -61,7 +61,7 @@ def checkIdP(driver,sp,idp):
except
NoSuchElementException
as
e
:
pass
except
TimeoutException
as
e
:
logg
ing
.
info
(
"
%s;%s;TIMEOUT
"
%
(
idp
,
sp
))
logg
er
.
info
(
"
%s;%s;TIMEOUT
"
%
(
idp
,
sp
))
return
"
TIMEOUT
"
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
"
...
...
@@ -74,13 +74,13 @@ def checkIdP(driver,sp,idp):
password_found
=
re
.
search
(
pattern_password
,
driver
.
page_source
,
re
.
I
)
if
(
metadata_not_found
):
logg
ing
.
info
(
"
%s;%s;No-eduGAIN-Metadata
"
%
(
idp
,
sp
))
logg
er
.
info
(
"
%s;%s;No-eduGAIN-Metadata
"
%
(
idp
,
sp
))
return
"
No-eduGAIN-Metadata
"
elif
not
username_found
and
not
password_found
:
logg
ing
.
info
(
"
%s;%s;Invalid-Form
"
%
(
idp
,
sp
))
logg
er
.
info
(
"
%s;%s;Invalid-Form
"
%
(
idp
,
sp
))
return
"
Invalid Form
"
else
:
logg
ing
.
info
(
"
%s;%s;OK
"
%
(
idp
,
sp
))
logg
er
.
info
(
"
%s;%s;OK
"
%
(
idp
,
sp
))
return
"
OK
"
def
setup
():
...
...
@@ -97,13 +97,39 @@ def setup():
return
driver
# Use logger to produce files consumed by ECCS-2
def
getLogger
(
filename
,
log_level
=
"
DEBUG
"
,
path
=
"
./
"
):
if
__name__
==
"
__main__
"
:
logger
=
logging
.
getLogger
(
filename
)
ch
=
logging
.
FileHandler
(
path
+
filename
,
'
w
'
,
'
utf-8
'
)
if
(
log_level
==
"
DEBUG
"
):
logger
.
setLevel
(
logging
.
DEBUG
)
ch
.
setLevel
(
logging
.
DEBUG
)
elif
(
log_level
==
"
INFO
"
):
logger
.
setLevel
(
logging
.
INFO
)
ch
.
setLevel
(
logging
.
INFO
)
elif
(
log_level
==
"
WARN
"
):
logger
.
setLevel
(
logging
.
WARN
)
ch
.
setLevel
(
logging
.
WARN
)
elif
(
log_level
==
"
ERROR
"
):
logger
.
setLevel
(
logging
.
ERROR
)
ch
.
setLevel
(
logging
.
ERROR
)
elif
(
log_level
==
"
CRITICAL
"
):
logger
.
setLevel
(
logging
.
CRITICAL
)
ch
.
setLevel
(
logging
.
CRITICAL
)
formatter
=
logging
.
Formatter
(
'
%(message)s
'
)
ch
.
setFormatter
(
formatter
)
logger
.
addHandler
(
ch
)
import
os
os
.
remove
(
"
eccs2.log
"
)
return
logger
if
__name__
==
"
__main__
"
:
logging
.
basicConfig
(
format
=
'
%(message)s
'
,
filename
=
'
eccs2.log
'
,
level
=
logging
.
INFO
)
eccs2log
=
getLogger
(
"
logs/eccs2.log
"
,
"
INFO
"
)
eccs2checks
=
getLogger
(
"
logs/eccs2checks.log
"
,
"
INFO
"
)
driver
=
setup
()
...
...
@@ -122,12 +148,12 @@ if __name__=="__main__":
for
idp
in
listIdPs
:
result
=
[]
for
sp
in
sps
:
result
.
append
(
checkIdP
(
driver
,
sp
,
idp
))
result
.
append
(
checkIdP
(
driver
,
sp
,
idp
,
eccs2checks
))
# se tutti e 2 i check sono andati bene, allora l'IdP è OK, altrimenti no.
if
(
result
[
0
]
==
result
[
1
]
==
"
OK
"
):
print
(
"
IdP
'
%s
'
results into: OK
"
%
(
idp
))
eccs2log
.
info
(
"
IdP
'
%s
'
results into: OK
"
%
(
idp
))
else
:
print
(
"
IdP
'
%s
'
results into: NOT OK
"
%
(
idp
))
eccs2log
.
info
(
"
IdP
'
%s
'
results into: NOT OK
"
%
(
idp
))
driver
.
close
()
This diff is collapsed.
Click to expand it.
logs/.gitignore
0 → 100644
+
4
−
0
View file @
c8a42e03
# 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