from resources.common_imports import * #les variables globales minimum from resources.config import * class Test(Resource): def __init__(self): toto="toto" #self.mattermost_team_resource=Mattermost_team() #global mattermost_url, sympa_url, webmail_url, mdp_url, site_url, nc_url #******************************************************************************************** @jwt_required() def get(self): """ Pour tester des conneries: # test lançement de cmde ssh sur des serveurs distants: --- tags: - Test security: - Bearer: [] parameters: [] responses: 201: description: OK 401: description: KO """ #******************************************************************************************** # test lançcement de cmde ssh sur des serveurs distants: # il faut au préalable que la clé publique de root du conteneur apikaz soit dans authorized key du user fabricer de la machine 163.172.94.54 # clé à créer dans le Dockerfile # risque sécu ? cmd="ssh -p 2201 fabricer@163.172.94.54 mkdir -p /tmp/toto" try: output = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT) return "ok",200 except subprocess.CalledProcessError as e: return e.output.decode("utf-8"), 400 #******************************************************************************************** # #***** test suppression de toutes les équipes de MM sauf KAZ # res,status=self.mattermost_team_resource=Mattermost_team().get() # for equipe in res: # if equipe!="kaz": res,status=self.mattermost_team_resource=Mattermost_team().delete(equipe) # return "fin" #******************************************************************************************** #**** test messagerie # NOM="toto" # EMAIL_SOUHAITE='f@kaz.bzh' # PASSWORD="toto" # QUOTA="1" # ADMIN_ORGA="0" # # context = { # 'ADMIN_ORGA': ADMIN_ORGA, # 'NOM': NOM, # 'EMAIL_SOUHAITE': EMAIL_SOUHAITE, # 'PASSWORD': PASSWORD, # 'QUOTA': QUOTA, # 'URL_WEBMAIL': webmail_url, # 'URL_AGORA': mattermost_url, # 'URL_MDP': mdp_url, # 'URL_LISTE': sympa_url, # 'URL_SITE': site_url, # 'URL_CLOUD': cloud_url # } # # subject = "KAZ: confirmation d'inscription !" # sender=app.config['MAIL_USERNAME'] # reply_to = app.config['MAIL_REPLY_TO'] # # msg = Message(subject=subject, sender=sender, reply_to=reply_to, recipients=[EMAIL_SOUHAITE]) # msg.html = render_template('email_inscription.html', **context) # # # Parsez le contenu HTML avec BeautifulSoup # soup = BeautifulSoup(msg.html, 'html.parser') # msg.body = soup.get_text() # # mail.send(msg) # return "Message envoyé!" #******************************************************************************************** # #**** test ms erreur # email_secours="toto" # # msg=f"classe: {__class__.__name__} : ERREUR 8 : email_secours : {email_secours} " +", on arrête tout" # #return __class__.__name__ # return msg #******************************************************************************************** #**** test vérou # prefixe="toto_" # if glob(f"{tempfile.gettempdir()}/{prefixe}*"): # return "ERREUR : api déjà en cours d'utilisation !", 400 # else: # lock_file = tempfile.NamedTemporaryFile(prefix=prefixe,delete=True) # # sleep(20) # return str(lock_file), 201