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

Add 'check_result' parameter to API

parent ce7e223c
Branches
Tags
No related merge requests found
...@@ -21,7 +21,7 @@ def buildEmailAddress(listContacts): ...@@ -21,7 +21,7 @@ def buildEmailAddress(listContacts):
hrefList = [] hrefList = []
for email in listCtcs: for email in listCtcs:
hrefList.append("<a href='%s'>%s</a>" % (email,email.replace('mailto:', ''))) hrefList.append(f"<a href='{email}'>{email.replace('mailto:', '')}</a>")
return hrefList return hrefList
...@@ -34,7 +34,7 @@ def existsInFile(file_path, value, research_item, eccsDataTable, date): ...@@ -34,7 +34,7 @@ def existsInFile(file_path, value, research_item, eccsDataTable, date):
if (eccsDataTable): if (eccsDataTable):
return '' return ''
else: else:
return jsonify(error='FileNotFound: ECCS2 script has not been executed on %s yet' % date) return jsonify(error=f'FileNotFound: ECCS2 script has not been executed on {date} yet')
for line in lines: for line in lines:
aux = json.loads(line) aux = json.loads(line)
...@@ -70,19 +70,20 @@ class Test(Resource): ...@@ -70,19 +70,20 @@ class Test(Resource):
class EccsResults(Resource): class EccsResults(Resource):
def get(self): def get(self):
file_path = "%s/eccs2_%s.log" % (ECCS2OUTPUTDIR,DAY) file_path = f"{ECCS2OUTPUTDIR}/eccs2_{DAY}.log"
date = DAY date = DAY
status = None status = None
idp = None idp = None
reg_auth = None reg_auth = None
eccsDataTable = False eccsDataTable = False
simple = False simple = False
check_result = None
if 'eccsdt' in request.args: if 'eccsdt' in request.args:
eccsDataTable = True eccsDataTable = True
if 'date' in request.args: if 'date' in request.args:
date = request.args['date'] date = request.args['date']
file_path = "%s/eccs2_%s.log" % (ECCS2OUTPUTDIR,date) file_path = f"{ECCS2OUTPUTDIR}/eccs2_{date}.log"
if 'status' in request.args: if 'status' in request.args:
status = request.args['status'].upper() status = request.args['status'].upper()
if (status not in ['OK','DISABLED','ERROR']): if (status not in ['OK','DISABLED','ERROR']):
...@@ -90,14 +91,18 @@ class EccsResults(Resource): ...@@ -90,14 +91,18 @@ class EccsResults(Resource):
if 'idp' in request.args: if 'idp' in request.args:
idp = request.args['idp'] idp = request.args['idp']
if (not existsInFile(file_path, idp, "entityID", eccsDataTable, date)): if (not existsInFile(file_path, idp, "entityID", eccsDataTable, date)):
return jsonify(error="Identity Provider not found with the entityID: %s" % idp) return jsonify(error=f"Identity Provider not found with the entityID: {idp}")
if 'reg_auth' in request.args: if 'reg_auth' in request.args:
reg_auth = request.args['reg_auth'] reg_auth = request.args['reg_auth']
if (not existsInFile(file_path, reg_auth, "registrationAuthority", eccsDataTable, date)): if (not existsInFile(file_path, reg_auth, "registrationAuthority", eccsDataTable, date)):
return jsonify(error="Identity Providers not found with the Registration Authority: %s" % reg_auth) return jsonify(error=f"Identity Providers not found with the Registration Authority: {reg_auth}")
if 'format' in request.args: if 'format' in request.args:
if 'simple' == request.args['format']: if 'simple' == request.args['format']:
simple = True simple = True
if 'check_result' in request.args:
check_result = request.args['check_result']
if (check_result not in ['OK','Timeout','Invalid-Form','Connection-Error','No-eduGAIN-Metadata','SSL-Error','DISABLED']):
return jsonify(error="Incorrect check_result value provided. It can be 'OK','Timeout','Invalid-Form','Connection-Error','No-eduGAIN-Metadata','SSL-Error' ok 'DISABLED'")
lines = [] lines = []
results = [] results = []
...@@ -109,7 +114,7 @@ class EccsResults(Resource): ...@@ -109,7 +114,7 @@ class EccsResults(Resource):
if (eccsDataTable): if (eccsDataTable):
return '' return ''
else: else:
return jsonify(error='FileNotFound: ECCS2 script has not been executed on %s' % date) return jsonify(error=f'FileNotFound: ECCS2 script has not been executed on {date}')
for line in lines: for line in lines:
# Strip the line feed and carriage return characters # Strip the line feed and carriage return characters
...@@ -163,9 +168,17 @@ class EccsResults(Resource): ...@@ -163,9 +168,17 @@ class EccsResults(Resource):
results.append(auxSimple) results.append(auxSimple)
else: else:
results.append(aux) results.append(aux)
elif (check_result):
if (check_result == aux['sp1']['checkResult'] or check_result == aux['sp2']['checkResult']):
if (simple):
auxSimple = getSimpleDict(aux)
results.append(auxSimple)
else:
results.append(aux)
elif (simple): elif (simple):
auxSimple = getSimpleDict(aux) auxSimple = getSimpleDict(aux)
results.append(auxSimple) results.append(auxSimple)
else: else:
results.append(aux) results.append(aux)
...@@ -178,14 +191,14 @@ class FedStats(Resource): ...@@ -178,14 +191,14 @@ class FedStats(Resource):
list_feds = get_list_feds(ECCS2LISTFEDSURL, ECCS2LISTFEDSFILE) list_feds = get_list_feds(ECCS2LISTFEDSURL, ECCS2LISTFEDSFILE)
regAuthDict = get_reg_auth_dict(list_feds) regAuthDict = get_reg_auth_dict(list_feds)
file_path = "%s/eccs2_%s.log" % (ECCS2OUTPUTDIR,DAY) file_path = f"{ECCS2OUTPUTDIR}/eccs2_{DAY}.log"
date = DAY date = DAY
reg_auth = None reg_auth = None
eccsDataTable = False eccsDataTable = False
if ('date' in request.args): if ('date' in request.args):
date = request.args['date'] date = request.args['date']
file_path = "%s/eccs2_%s.log" % (ECCS2OUTPUTDIR,date) file_path = f"{ECCS2OUTPUTDIR}/eccs2_{date}.log"
if ('reg_auth' in request.args): if ('reg_auth' in request.args):
reg_auth = request.args['reg_auth'] reg_auth = request.args['reg_auth']
if (not existsInFile(file_path, reg_auth, "registrationAuthority", eccsDataTable, date)): if (not existsInFile(file_path, reg_auth, "registrationAuthority", eccsDataTable, date)):
...@@ -201,7 +214,7 @@ class FedStats(Resource): ...@@ -201,7 +214,7 @@ class FedStats(Resource):
if (eccsDataTable): if (eccsDataTable):
return '' return ''
else: else:
return jsonify(error='FileNotFound: ECCS2 script has not been executed on %s yet' % date) return jsonify(error=f'FileNotFound: ECCS2 script has not been executed on {date} yet')
if (reg_auth): if (reg_auth):
resultDict = {'date': date, 'registrationAuthority': reg_auth, 'OK': 0, 'ERROR': 0, 'DISABLED': 0} resultDict = {'date': date, 'registrationAuthority': reg_auth, 'OK': 0, 'ERROR': 0, 'DISABLED': 0}
......
...@@ -147,6 +147,7 @@ function SHA1(msg) { ...@@ -147,6 +147,7 @@ function SHA1(msg) {
// date (date time of the check) // date (date time of the check)
// reg_auth (the IdP RegistrationAuthority) // reg_auth (the IdP RegistrationAuthority)
// status (the ECCS2 IdP Status) // status (the ECCS2 IdP Status)
// check_result (the ECCS2 check result)
if (date) { if (date) {
url = url.concat("&date=" + date); url = url.concat("&date=" + date);
} }
...@@ -159,7 +160,9 @@ if (idp) { ...@@ -159,7 +160,9 @@ if (idp) {
if (status) { if (status) {
url = url.concat("&status=" + status); url = url.concat("&status=" + status);
} }
if (check_result) {
url = url.concat("&check_result=" + check_result);
}
function getPastResults() { function getPastResults() {
var checkDate = $.datepicker.formatDate("yy-mm-dd", $('#datepicker').datepicker().datepicker('getDate')); var checkDate = $.datepicker.formatDate("yy-mm-dd", $('#datepicker').datepicker().datepicker('getDate'));
......
...@@ -17,6 +17,7 @@ $data['idp'] = htmlspecialchars($_GET["idp"]); ...@@ -17,6 +17,7 @@ $data['idp'] = htmlspecialchars($_GET["idp"]);
$data['reg_auth'] = htmlspecialchars($_GET["reg_auth"]); $data['reg_auth'] = htmlspecialchars($_GET["reg_auth"]);
$data['date'] = (htmlspecialchars($_GET["date"]) ? htmlspecialchars($_GET["date"] : $lastDate); $data['date'] = (htmlspecialchars($_GET["date"]) ? htmlspecialchars($_GET["date"] : $lastDate);
$data['status'] = htmlspecialchars($_GET["status"]); $data['status'] = htmlspecialchars($_GET["status"]);
$data['check_result'] = htmlspecialchars($_GET["check_result"]);
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
...@@ -83,6 +84,7 @@ $data['status'] = htmlspecialchars($_GET["status"]); ...@@ -83,6 +84,7 @@ $data['status'] = htmlspecialchars($_GET["status"]);
var reg_auth = "<?php echo $data['reg_auth'] ?>"; var reg_auth = "<?php echo $data['reg_auth'] ?>";
var idp = "<?php echo $data['idp'] ?>"; var idp = "<?php echo $data['idp'] ?>";
var status = "<?php echo $data['status'] ?>"; var status = "<?php echo $data['status'] ?>";
var check_result = "<?php echo $data['check_result'] ?>";
</script> </script>
<script type="text/javascript" src="eccs2.js" /></script> <script type="text/javascript" src="eccs2.js" /></script>
</body> </body>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment