1
0
forked from ScoDoc/ScoDoc

Ajout de timeouts sur toutes les requêtes externes (y compris tests API)

This commit is contained in:
Emmanuel Viennet 2023-04-06 10:38:31 +02:00
parent c56ed1e5f1
commit 75ee45835a
16 changed files with 144 additions and 27 deletions

View File

@ -44,8 +44,8 @@ from app.entreprises.models import (
EntrepriseHistorique, EntrepriseHistorique,
) )
from app import email, db from app import email, db
from app.scodoc import sco_preferences
from app.scodoc import sco_excel from app.scodoc import sco_excel
from app.scodoc import sco_utils as scu
from app.models import Departement from app.models import Departement
from app.scodoc.sco_permissions import Permission from app.scodoc.sco_permissions import Permission
@ -392,7 +392,8 @@ def check_entreprise_import(entreprise_data):
else: else:
try: try:
req = requests.get( req = requests.get(
f"https://entreprise.data.gouv.fr/api/sirene/v1/siret/{siret}" f"https://entreprise.data.gouv.fr/api/sirene/v1/siret/{siret}",
timeout=scu.SCO_EXT_TIMEOUT,
) )
if req.status_code != 200: if req.status_code != 200:
return False return False

View File

@ -24,9 +24,9 @@
# #
############################################################################## ##############################################################################
from datetime import datetime
import re import re
import requests import requests
from datetime import datetime
from flask import url_for from flask import url_for
from flask_wtf import FlaskForm from flask_wtf import FlaskForm
@ -34,18 +34,17 @@ from flask_wtf.file import FileField, FileAllowed, FileRequired
from markupsafe import Markup from markupsafe import Markup
from sqlalchemy import text from sqlalchemy import text
from wtforms import ( from wtforms import (
StringField,
IntegerField,
SubmitField,
TextAreaField,
SelectField,
HiddenField,
SelectMultipleField,
DateField,
BooleanField, BooleanField,
DateField,
FieldList, FieldList,
FormField, FormField,
BooleanField, HiddenField,
IntegerField,
SelectField,
SelectMultipleField,
StringField,
SubmitField,
TextAreaField,
) )
from wtforms.validators import ( from wtforms.validators import (
ValidationError, ValidationError,
@ -64,9 +63,10 @@ from app.entreprises.models import (
EntrepriseTaxeApprentissage, EntrepriseTaxeApprentissage,
) )
from app import db from app import db
from app.models import Identite, Departement
from app.auth.models import User from app.auth.models import User
from app.entreprises import SIRET_PROVISOIRE_START from app.entreprises import SIRET_PROVISOIRE_START
from app.models import Identite, Departement
from app.scodoc import sco_utils as scu
CHAMP_REQUIS = "Ce champ est requis" CHAMP_REQUIS = "Ce champ est requis"
SUBMIT_MARGE = {"style": "margin-bottom: 10px;"} SUBMIT_MARGE = {"style": "margin-bottom: 10px;"}
@ -139,7 +139,8 @@ class EntrepriseCreationForm(FlaskForm):
else: else:
try: try:
req = requests.get( req = requests.get(
f"https://entreprise.data.gouv.fr/api/sirene/v1/siret/{siret_data}" f"https://entreprise.data.gouv.fr/api/sirene/v1/siret/{siret_data}",
timeout=scu.SCO_EXT_TIMEOUT,
) )
if req.status_code != 200: if req.status_code != 200:
self.siret.errors.append("SIRET inexistant") self.siret.errors.append("SIRET inexistant")
@ -220,7 +221,8 @@ class EntrepriseModificationForm(FlaskForm):
else: else:
try: try:
req = requests.get( req = requests.get(
f"https://entreprise.data.gouv.fr/api/sirene/v1/siret/{siret_data}" f"https://entreprise.data.gouv.fr/api/sirene/v1/siret/{siret_data}",
timeout=scu.SCO_EXT_TIMEOUT,
) )
if req.status_code != 200: if req.status_code != 200:
raise ValidationError("SIRET inexistant") raise ValidationError("SIRET inexistant")

View File

@ -181,6 +181,7 @@ def _send_db(
"dept_name": getattr(g, "scodoc_dept", "-"), "dept_name": getattr(g, "scodoc_dept", "-"),
"message": message or "", "message": message or "",
"request_url": request_url or request.url, "request_url": request_url or request.url,
"request_method": request.method,
"serial": _get_scodoc_serial(), "serial": _get_scodoc_serial(),
"sco_user": str(current_user), "sco_user": str(current_user),
"sent_by": f'"{current_user.get_nomcomplet()}" <{current_user.email}>', "sent_by": f'"{current_user.get_nomcomplet()}" <{current_user.email}>',
@ -188,8 +189,9 @@ def _send_db(
"sco_fullversion": scu.get_scodoc_version(), "sco_fullversion": scu.get_scodoc_version(),
"traceback_str": traceback_str, "traceback_str": traceback_str,
}, },
timeout=scu.SCO_ORG_TIMEOUT,
) )
except requests.exceptions.ConnectionError as exc: except (requests.exceptions.ConnectionError, requests.exceptions.Timeout) as exc:
log("ConnectionError: Impossible de joindre le serveur d'assistance") log("ConnectionError: Impossible de joindre le serveur d'assistance")
raise ScoValueError( raise ScoValueError(
""" """

View File

@ -47,8 +47,10 @@ def is_up_to_date() -> str:
return "<div>Mode développement</div>" return "<div>Mode développement</div>"
diag = "" diag = ""
try: try:
response = requests.get(scu.SCO_UP2DATE + "/" + SCOVERSION) response = requests.get(
except requests.exceptions.ConnectionError: scu.SCO_UP2DATE + "/" + SCOVERSION, timeout=scu.SCO_ORG_TIMEOUT
)
except (requests.exceptions.ConnectionError, requests.exceptions.Timeout):
current_app.logger.debug("is_up_to_date: %s", diag) current_app.logger.debug("is_up_to_date: %s", diag)
return f"""<div>Attention: installation de {SCONAME} non fonctionnelle.</div> return f"""<div>Attention: installation de {SCONAME} non fonctionnelle.</div>
<div>Détails: pas de connexion à {scu.SCO_WEBSITE}. <div>Détails: pas de connexion à {scu.SCO_WEBSITE}.

View File

@ -365,6 +365,9 @@ SCO_DEV_MAIL = "emmanuel.viennet@gmail.com" # SVP ne pas changer
# ne pas changer (ou vous perdez le support) # ne pas changer (ou vous perdez le support)
SCO_DUMP_UP_URL = "https://scodoc.org/scodoc-installmgr/upload-dump" SCO_DUMP_UP_URL = "https://scodoc.org/scodoc-installmgr/upload-dump"
SCO_UP2DATE = "https://scodoc.org/scodoc-installmgr/check_version" SCO_UP2DATE = "https://scodoc.org/scodoc-installmgr/check_version"
SCO_ORG_TIMEOUT = 180 # contacts scodoc.org
SCO_EXT_TIMEOUT = 180 # appels à des ressources extérieures (siret, ...)
SCO_TEST_API_TIMEOUT = 5 # pour tests unitaires API
CSV_FIELDSEP = ";" CSV_FIELDSEP = ";"
CSV_LINESEP = "\n" CSV_LINESEP = "\n"
CSV_MIMETYPE = "text/comma-separated-values" CSV_MIMETYPE = "text/comma-separated-values"

View File

@ -59,7 +59,9 @@ def GET(path: str, params=None, errmsg=None):
# ajoute auth # ajoute auth
params["__ac_name"] = SCODOC_USER params["__ac_name"] = SCODOC_USER
params["__ac_password"] = SCODOC_PASSWORD params["__ac_password"] = SCODOC_PASSWORD
r = requests.get(DEPT_URL + "/" + path, params=params, verify=CHECK_CERTIFICATE) r = requests.get(
DEPT_URL + "/" + path, params=params, verify=CHECK_CERTIFICATE, timeout=10
)
if r.status_code != 200: if r.status_code != 200:
raise ScoError(errmsg or "erreur !") raise ScoError(errmsg or "erreur !")
return r.json() # decode la reponse JSON return r.json() # decode la reponse JSON
@ -69,7 +71,9 @@ def POST(path: str, data: dict, errmsg=None):
"""Post""" """Post"""
data["__ac_name"] = data.get("__ac_name", SCODOC_USER) data["__ac_name"] = data.get("__ac_name", SCODOC_USER)
data["__ac_password"] = data.get("__ac_password", SCODOC_PASSWORD) data["__ac_password"] = data.get("__ac_password", SCODOC_PASSWORD)
r = requests.post(DEPT_URL + "/" + path, data=data, verify=CHECK_CERTIFICATE) r = requests.post(
DEPT_URL + "/" + path, data=data, verify=CHECK_CERTIFICATE, timeout=10
)
return r return r

View File

@ -17,6 +17,7 @@ import os
import requests import requests
from dotenv import load_dotenv from dotenv import load_dotenv
import pytest import pytest
from app.scodoc import sco_utils as scu
# --- Lecture configuration (variables d'env ou .env) # --- Lecture configuration (variables d'env ou .env)
try: try:
@ -45,7 +46,7 @@ class APIError(Exception):
def get_auth_headers(user, password) -> dict: def get_auth_headers(user, password) -> dict:
"Demande de jeton, dict à utiliser dans les en-têtes de requêtes http" "Demande de jeton, dict à utiliser dans les en-têtes de requêtes http"
ans = requests.post(API_URL + "/tokens", auth=(user, password)) ans = requests.post(API_URL + "/tokens", auth=(user, password), timeout=5)
if ans.status_code != 200: if ans.status_code != 200:
raise APIError(f"Echec demande jeton par {user}") raise APIError(f"Echec demande jeton par {user}")
token = ans.json()["token"] token = ans.json()["token"]
@ -73,7 +74,12 @@ def GET(path: str, headers: dict = None, errmsg=None, dept=None):
url = SCODOC_URL + f"/ScoDoc/{dept}/api" + path url = SCODOC_URL + f"/ScoDoc/{dept}/api" + path
else: else:
url = API_URL + path url = API_URL + path
reply = requests.get(url, headers=headers or {}, verify=CHECK_CERTIFICATE) reply = requests.get(
url,
headers=headers or {},
verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
)
if reply.status_code != 200: if reply.status_code != 200:
raise APIError( raise APIError(
errmsg or f"""erreur status={reply.status_code} !""", reply.json() errmsg or f"""erreur status={reply.status_code} !""", reply.json()
@ -105,6 +111,7 @@ def POST_JSON(path: str, data: dict = {}, headers: dict = None, errmsg=None, dep
json=data, json=data,
headers=headers or {}, headers=headers or {},
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=10,
) )
if r.status_code != 200: if r.status_code != 200:
raise APIError(errmsg or f"erreur status={r.status_code} !", r.json()) raise APIError(errmsg or f"erreur status={r.status_code} !", r.json())

View File

@ -18,6 +18,7 @@ Utilisation :
""" """
import requests import requests
from app.scodoc import sco_utils as scu
from tests.api.setup_test_api import API_URL, CHECK_CERTIFICATE, api_headers from tests.api.setup_test_api import API_URL, CHECK_CERTIFICATE, api_headers
# Etudiant pour les tests # Etudiant pour les tests
@ -42,6 +43,7 @@ def test_absences(api_headers):
f"{API_URL}/absences/etudid/{ETUDID}", f"{API_URL}/absences/etudid/{ETUDID}",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
absences = r.json() absences = r.json()
@ -72,6 +74,7 @@ def test_absences_justify(api_headers):
f"{API_URL}/absences/etudid/{ETUDID}/just", f"{API_URL}/absences/etudid/{ETUDID}/just",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
absences = r.json() absences = r.json()
@ -103,6 +106,7 @@ def test_abs_groupe_etat(api_headers):
f"{API_URL}/absences/abs_group_etat/{group_id}", f"{API_URL}/absences/abs_group_etat/{group_id}",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
@ -139,6 +143,7 @@ def test_abs_groupe_etat(api_headers):
f"{API_URL}/absences/abs_group_etat/group_id/{group_id}/date_debut/{date_debut}/date_fin/{date_fin}", f"{API_URL}/absences/abs_group_etat/group_id/{group_id}/date_debut/{date_debut}/date_fin/{date_fin}",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r1.status_code == 200 assert r1.status_code == 200
@ -187,6 +192,7 @@ def test_abs_groupe_etat(api_headers):
# f"{API_URL}/absences/etudid/{ETUDID}/list_abs/{list_abs}/reset_etud_abs", # f"{API_URL}/absences/etudid/{ETUDID}/list_abs/{list_abs}/reset_etud_abs",
# headers=api_headers, # headers=api_headers,
# verify=CHECK_CERTIFICATE, # verify=CHECK_CERTIFICATE,
# timeout=scu.SCO_TEST_API_TIMEOUT,
# ) # )
# assert r.status_code == 200 # assert r.status_code == 200
# #
@ -194,6 +200,7 @@ def test_abs_groupe_etat(api_headers):
# f"{API_URL}/absences/etudid/{ETUDID}/list_abs/{list_abs}/reset_etud_abs/only_not_just", # f"{API_URL}/absences/etudid/{ETUDID}/list_abs/{list_abs}/reset_etud_abs/only_not_just",
# headers=api_headers, # headers=api_headers,
# verify=CHECK_CERTIFICATE, # verify=CHECK_CERTIFICATE,
# timeout=scu.SCO_TEST_API_TIMEOUT,
# ) # )
# assert r.status_code == 200 # assert r.status_code == 200
# #

View File

@ -33,6 +33,7 @@ from tests.api.tools_test_api import (
FORMSEMESTRE_FIELDS, FORMSEMESTRE_FIELDS,
verify_occurences_ids_etuds, verify_occurences_ids_etuds,
) )
from app.scodoc import sco_utils as scu
def test_create_dept(api_admin_headers): def test_create_dept(api_admin_headers):
@ -72,6 +73,7 @@ def test_departements(api_headers):
API_URL + "/departements_ids", API_URL + "/departements_ids",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
departements_ids = r.json() departements_ids = r.json()
@ -94,6 +96,7 @@ def test_departements(api_headers):
f"{API_URL}/departement/id/{dept_id}", f"{API_URL}/departement/id/{dept_id}",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
dept_a = r.json() dept_a = r.json()
@ -102,6 +105,7 @@ def test_departements(api_headers):
f"{API_URL}/departement/{dept_a['acronym']}", f"{API_URL}/departement/{dept_a['acronym']}",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
dept_b = r.json() dept_b = r.json()
@ -119,6 +123,7 @@ def test_departements(api_headers):
API_URL + "/departements", API_URL + "/departements",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
@ -127,6 +132,7 @@ def test_departements(api_headers):
f"{API_URL}/departement/{dept_a['acronym']}/formsemestres_ids", f"{API_URL}/departement/{dept_a['acronym']}/formsemestres_ids",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
dept_ids_a = r.json() dept_ids_a = r.json()
@ -135,6 +141,7 @@ def test_departements(api_headers):
f"{API_URL}/departement/id/{dept_a['id']}/formsemestres_ids", f"{API_URL}/departement/id/{dept_a['id']}/formsemestres_ids",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
dept_ids_b = r.json() dept_ids_b = r.json()
@ -151,6 +158,7 @@ def test_departements(api_headers):
f"{API_URL}/departement/{id_inexistant}", f"{API_URL}/departement/{id_inexistant}",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 404 assert r.status_code == 404
@ -158,6 +166,7 @@ def test_departements(api_headers):
f"{API_URL}/departement/{id_inexistant}/formsemestres_ids", f"{API_URL}/departement/{id_inexistant}/formsemestres_ids",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 404 assert r.status_code == 404
@ -166,6 +175,7 @@ def test_departements(api_headers):
f"{API_URL}/departement/{acronym_inexistant}", f"{API_URL}/departement/{acronym_inexistant}",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 404 assert r.status_code == 404
@ -173,6 +183,7 @@ def test_departements(api_headers):
f"{API_URL}/departement/{acronym_inexistant}/formsemestres_ids", f"{API_URL}/departement/{acronym_inexistant}/formsemestres_ids",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 404 assert r.status_code == 404
@ -184,6 +195,7 @@ def test_list_etudiants(api_headers):
API_URL + "/departement/TAPI/etudiants", API_URL + "/departement/TAPI/etudiants",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
etud_a = r.json()[0] etud_a = r.json()[0]
@ -192,6 +204,7 @@ def test_list_etudiants(api_headers):
API_URL + "/departement/id/1/etudiants", API_URL + "/departement/id/1/etudiants",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
etud_b = r.json()[0] etud_b = r.json()[0]
@ -216,6 +229,7 @@ def test_list_etudiants(api_headers):
f"{API_URL}/departement/{id_inexistant}/etudiants", f"{API_URL}/departement/{id_inexistant}/etudiants",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 404 assert r.status_code == 404
@ -224,6 +238,7 @@ def test_list_etudiants(api_headers):
f"{API_URL}/departement/{acronym_inexistant}/etudiants", f"{API_URL}/departement/{acronym_inexistant}/etudiants",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 404 assert r.status_code == 404
@ -235,6 +250,7 @@ def test_semestres_courant(api_headers):
f"{API_URL}/departement/id/{dept_id}", f"{API_URL}/departement/id/{dept_id}",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
dept = r.json() dept = r.json()
@ -245,6 +261,7 @@ def test_semestres_courant(api_headers):
f"{API_URL}/departement/{dept['acronym']}/formsemestres_courants?date_courante=2022-07-01", f"{API_URL}/departement/{dept['acronym']}/formsemestres_courants?date_courante=2022-07-01",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
result_a = r.json() result_a = r.json()
@ -254,6 +271,7 @@ def test_semestres_courant(api_headers):
f"{API_URL}/departement/id/{dept['id']}/formsemestres_courants?date_courante=2022-07-01", f"{API_URL}/departement/id/{dept['id']}/formsemestres_courants?date_courante=2022-07-01",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
result_b = r.json() result_b = r.json()

View File

@ -18,6 +18,7 @@ Utilisation :
""" """
import requests import requests
from app.scodoc import sco_utils as scu
from tests.api.setup_test_api import API_URL, CHECK_CERTIFICATE, api_headers from tests.api.setup_test_api import API_URL, CHECK_CERTIFICATE, api_headers
from tests.api.tools_test_api import ( from tests.api.tools_test_api import (
@ -69,6 +70,7 @@ def test_etudiants_courant(api_headers):
API_URL + "/etudiants/courants?date_courante=2022-07-01", API_URL + "/etudiants/courants?date_courante=2022-07-01",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
etudiants = r.json() etudiants = r.json()
@ -90,6 +92,7 @@ def test_etudiants_courant(api_headers):
API_URL + "/etudiants/courants/long?date_courante=2022-07-01", API_URL + "/etudiants/courants/long?date_courante=2022-07-01",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
etudiants = r.json() etudiants = r.json()
@ -109,6 +112,7 @@ def test_etudiant(api_headers):
API_URL + "/etudiant/etudid/" + str(ETUDID), API_URL + "/etudiant/etudid/" + str(ETUDID),
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
etud = r.json() etud = r.json()
@ -123,6 +127,7 @@ def test_etudiant(api_headers):
API_URL + "/etudiant/nip/" + code_nip, API_URL + "/etudiant/nip/" + code_nip,
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
etud_nip = r.json() etud_nip = r.json()
@ -153,6 +158,7 @@ def test_etudiants(api_headers):
API_URL + "/etudiants/etudid/" + str(ETUDID), API_URL + "/etudiants/etudid/" + str(ETUDID),
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
etud = r.json() etud = r.json()
@ -170,6 +176,7 @@ def test_etudiants(api_headers):
API_URL + "/etudiants/nip/" + code_nip, API_URL + "/etudiants/nip/" + code_nip,
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
etud_nip = r.json() etud_nip = r.json()
@ -191,6 +198,7 @@ def test_etudiants(api_headers):
API_URL + "/etudiants/ine/" + code_ine, API_URL + "/etudiants/ine/" + code_ine,
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
etud_ine = r.json() etud_ine = r.json()
@ -211,6 +219,7 @@ def test_etudiants(api_headers):
API_URL + "/etudiants/etudid/", API_URL + "/etudiants/etudid/",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 404 assert r.status_code == 404
@ -226,6 +235,7 @@ def test_etudiant_formsemestres(api_headers):
API_URL + "/etudiant/etudid/" + str(ETUDID) + "/formsemestres", API_URL + "/etudiant/etudid/" + str(ETUDID) + "/formsemestres",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
list_formsemestres = r.json() list_formsemestres = r.json()
@ -272,6 +282,7 @@ def test_etudiant_formsemestres(api_headers):
API_URL + "/etudiant/nip/" + str(NIP) + "/formsemestres", API_URL + "/etudiant/nip/" + str(NIP) + "/formsemestres",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
formsemestres = r.json() formsemestres = r.json()
@ -285,6 +296,7 @@ def test_etudiant_formsemestres(api_headers):
API_URL + "/etudiant/ine/" + str(INE) + "/formsemestres", API_URL + "/etudiant/ine/" + str(INE) + "/formsemestres",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
formsemestres = r.json() formsemestres = r.json()
@ -306,6 +318,7 @@ def test_etudiant_bulletin_semestre(api_headers):
API_URL + "/etudiant/etudid/" + str(ETUDID) + "/formsemestre/1/bulletin", API_URL + "/etudiant/etudid/" + str(ETUDID) + "/formsemestre/1/bulletin",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
bulletin = r.json() bulletin = r.json()
@ -500,7 +513,7 @@ def test_etudiant_bulletin_semestre(api_headers):
assert verify_fields(bulletin_ues, BULLETIN_UES_FIELDS) is True assert verify_fields(bulletin_ues, BULLETIN_UES_FIELDS) is True
assert isinstance(bulletin_ues, dict) assert isinstance(bulletin_ues, dict)
for (key_ue, value_ue) in bulletin_ues.items(): for key_ue, value_ue in bulletin_ues.items():
assert verify_fields(value_ue, BULLETIN_UES_UE_FIELDS) is True assert verify_fields(value_ue, BULLETIN_UES_UE_FIELDS) is True
assert isinstance(value_ue["id"], int) assert isinstance(value_ue["id"], int)
assert isinstance(value_ue["titre"], str) assert isinstance(value_ue["titre"], str)
@ -636,6 +649,7 @@ def test_etudiant_bulletin_semestre(api_headers):
API_URL + "/etudiant/nip/" + str(NIP) + "/formsemestre/1/bulletin", API_URL + "/etudiant/nip/" + str(NIP) + "/formsemestre/1/bulletin",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
bul = r.json() bul = r.json()
@ -646,6 +660,7 @@ def test_etudiant_bulletin_semestre(api_headers):
API_URL + "/etudiant/ine/" + str(INE) + "/formsemestre/1/bulletin", API_URL + "/etudiant/ine/" + str(INE) + "/formsemestre/1/bulletin",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
bul = r.json() bul = r.json()
@ -659,6 +674,7 @@ def test_etudiant_bulletin_semestre(api_headers):
# API_URL + "/etudiant/etudid/" + str(ETUDID) + "/formsemestre/1/bulletin/pdf", # API_URL + "/etudiant/etudid/" + str(ETUDID) + "/formsemestre/1/bulletin/pdf",
# headers=api_headers, # headers=api_headers,
# verify=CHECK_CERTIFICATE, # verify=CHECK_CERTIFICATE,
# timeout=scu.SCO_TEST_API_TIMEOUT,
# ) # )
# assert r.status_code == 200 # assert r.status_code == 200
# #
@ -668,6 +684,7 @@ def test_etudiant_bulletin_semestre(api_headers):
# API_URL + "/etudiant/nip/" + str(NIP) + "/formsemestre/1/bulletin/pdf", # API_URL + "/etudiant/nip/" + str(NIP) + "/formsemestre/1/bulletin/pdf",
# headers=api_headers, # headers=api_headers,
# verify=CHECK_CERTIFICATE, # verify=CHECK_CERTIFICATE,
# timeout=scu.SCO_TEST_API_TIMEOUT,
# ) # )
# assert r.status_code == 200 # assert r.status_code == 200
# #
@ -676,6 +693,7 @@ def test_etudiant_bulletin_semestre(api_headers):
# API_URL + "/etudiant/ine/" + str(INE) + "/formsemestre/1/bulletin/pdf", # API_URL + "/etudiant/ine/" + str(INE) + "/formsemestre/1/bulletin/pdf",
# headers=api_headers, # headers=api_headers,
# verify=CHECK_CERTIFICATE, # verify=CHECK_CERTIFICATE,
# timeout=scu.SCO_TEST_API_TIMEOUT,
# ) # )
# assert r.status_code == 200 # assert r.status_code == 200
@ -686,6 +704,7 @@ def test_etudiant_bulletin_semestre(api_headers):
API_URL + "/etudiant/etudid/" + str(ETUDID) + "/formsemestre/1/bulletin/short", API_URL + "/etudiant/etudid/" + str(ETUDID) + "/formsemestre/1/bulletin/short",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
bul = r.json() bul = r.json()
@ -697,6 +716,7 @@ def test_etudiant_bulletin_semestre(api_headers):
API_URL + "/etudiant/nip/" + str(NIP) + "/formsemestre/1/bulletin/short", API_URL + "/etudiant/nip/" + str(NIP) + "/formsemestre/1/bulletin/short",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
bul = r.json() bul = r.json()
@ -707,6 +727,7 @@ def test_etudiant_bulletin_semestre(api_headers):
API_URL + "/etudiant/ine/" + str(INE) + "/formsemestre/1/bulletin/short", API_URL + "/etudiant/ine/" + str(INE) + "/formsemestre/1/bulletin/short",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
bul = r.json() bul = r.json()
@ -719,6 +740,7 @@ def test_etudiant_bulletin_semestre(api_headers):
# API_URL + "/etudiant/etudid/" + str(ETUDID) + "/formsemestre/1/bulletin/short/pdf", # API_URL + "/etudiant/etudid/" + str(ETUDID) + "/formsemestre/1/bulletin/short/pdf",
# headers=api_headers, # headers=api_headers,
# verify=CHECK_CERTIFICATE, # verify=CHECK_CERTIFICATE,
# timeout=scu.SCO_TEST_API_TIMEOUT,
# ) # )
# assert r.status_code == 200 # assert r.status_code == 200
# #
@ -728,6 +750,7 @@ def test_etudiant_bulletin_semestre(api_headers):
# API_URL + "/etudiant/nip/" + str(NIP) + "/formsemestre/1/bulletin/short/pdf", # API_URL + "/etudiant/nip/" + str(NIP) + "/formsemestre/1/bulletin/short/pdf",
# headers=api_headers, # headers=api_headers,
# verify=CHECK_CERTIFICATE, # verify=CHECK_CERTIFICATE,
# timeout=scu.SCO_TEST_API_TIMEOUT,
# ) # )
# assert r.status_code == 200 # assert r.status_code == 200
# #
@ -736,6 +759,7 @@ def test_etudiant_bulletin_semestre(api_headers):
# API_URL + "/etudiant/ine/" + str(INE) + "/formsemestre/1/bulletin/short/pdf", # API_URL + "/etudiant/ine/" + str(INE) + "/formsemestre/1/bulletin/short/pdf",
# headers=api_headers, # headers=api_headers,
# verify=CHECK_CERTIFICATE, # verify=CHECK_CERTIFICATE,
# timeout=scu.SCO_TEST_API_TIMEOUT,
# ) # )
# assert r.status_code == 200 # assert r.status_code == 200
@ -744,6 +768,7 @@ def test_etudiant_bulletin_semestre(api_headers):
API_URL + "/etudiant/ine/189919919119191/formsemestre/1/bulletin", API_URL + "/etudiant/ine/189919919119191/formsemestre/1/bulletin",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 404 assert r.status_code == 404
@ -771,6 +796,7 @@ def test_etudiant_groups(api_headers):
API_URL + "/etudiant/etudid/1/formsemestre/1/groups", API_URL + "/etudiant/etudid/1/formsemestre/1/groups",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
groups = r.json() groups = r.json()

View File

@ -19,6 +19,7 @@ Utilisation :
import requests import requests
from app.scodoc import sco_utils as scu
from tests.api.setup_test_api import API_URL, CHECK_CERTIFICATE, api_headers from tests.api.setup_test_api import API_URL, CHECK_CERTIFICATE, api_headers
from tests.api.tools_test_api import ( from tests.api.tools_test_api import (
verify_fields, verify_fields,
@ -39,6 +40,7 @@ def test_evaluations(api_headers):
f"{API_URL}/moduleimpl/{moduleimpl_id}/evaluations", f"{API_URL}/moduleimpl/{moduleimpl_id}/evaluations",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
list_eval = r.json() list_eval = r.json()

View File

@ -19,6 +19,7 @@ Utilisation :
import requests import requests
from app.scodoc import sco_utils as scu
from tests.api.setup_test_api import API_URL, CHECK_CERTIFICATE, api_headers from tests.api.setup_test_api import API_URL, CHECK_CERTIFICATE, api_headers
from tests.api.tools_test_api import ( from tests.api.tools_test_api import (
verify_fields, verify_fields,
@ -41,6 +42,7 @@ def test_formations_ids(api_headers):
API_URL + "/formations_ids", API_URL + "/formations_ids",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
formations_ids = r.json() formations_ids = r.json()
@ -59,6 +61,7 @@ def test_formations_by_id(api_headers):
f"{API_URL}/formation/{id_formation}", f"{API_URL}/formation/{id_formation}",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
formation = r.json() formation = r.json()
@ -86,6 +89,7 @@ def test_formations_by_id(api_headers):
f"{API_URL}/formation/{formation['formation_id']}", f"{API_URL}/formation/{formation['formation_id']}",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r1.status_code == 200 assert r1.status_code == 200
formation1 = r1.json() formation1 = r1.json()
@ -98,6 +102,7 @@ def test_formations_by_id(api_headers):
f"{API_URL}/formation/{id_formation_inexistant}", f"{API_URL}/formation/{id_formation_inexistant}",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r_error.status_code == 404 assert r_error.status_code == 404
@ -110,6 +115,7 @@ def test_formation_export(api_headers):
API_URL + "/formation/1/export", API_URL + "/formation/1/export",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
export_formation = r.json() export_formation = r.json()
@ -185,6 +191,7 @@ def test_formation_export(api_headers):
f"{API_URL}/formation/export/{id_formation_inexistant}", f"{API_URL}/formation/export/{id_formation_inexistant}",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r_error.status_code == 404 assert r_error.status_code == 404
@ -197,6 +204,7 @@ def test_formation_export_with_ids(api_headers):
API_URL + "/formation/1/export_with_ids", API_URL + "/formation/1/export_with_ids",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
export_formation = r.json() export_formation = r.json()
@ -215,6 +223,7 @@ def test_moduleimpl(api_headers):
f"{API_URL}/moduleimpl/{moduleimpl_id}", f"{API_URL}/moduleimpl/{moduleimpl_id}",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
moduleimpl = r.json() moduleimpl = r.json()
@ -257,6 +266,7 @@ def test_moduleimpl(api_headers):
f"{API_URL}/moduleimpl/{moduleimpl['moduleimpl_id']}", f"{API_URL}/moduleimpl/{moduleimpl['moduleimpl_id']}",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r1.status_code == 200 assert r1.status_code == 200
moduleimpl1 = r1.json() moduleimpl1 = r1.json()
@ -269,6 +279,7 @@ def test_moduleimpl(api_headers):
f"{API_URL}/formation/moduleimpl/{id_formation_inexistant}", f"{API_URL}/formation/moduleimpl/{id_formation_inexistant}",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r_error.status_code == 404 assert r_error.status_code == 404
@ -281,6 +292,7 @@ def test_referentiel_competences(api_headers):
f"{API_URL}/formation/1/referentiel_competences", f"{API_URL}/formation/1/referentiel_competences",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
@ -305,5 +317,6 @@ def test_referentiel_competences(api_headers):
f"{API_URL}/formation/{id_formation_inexistant}/referentiel_competences", f"{API_URL}/formation/{id_formation_inexistant}/referentiel_competences",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r_error.status_code == 404 assert r_error.status_code == 404

View File

@ -19,6 +19,8 @@ Utilisation :
import json import json
import requests import requests
from app.scodoc import sco_utils as scu
from tests.api.setup_test_api import ( from tests.api.setup_test_api import (
API_URL, API_URL,
CHECK_CERTIFICATE, CHECK_CERTIFICATE,
@ -72,6 +74,7 @@ def test_formsemestre(api_headers):
f"{API_URL}/formsemestre/{formsemestre_id}", f"{API_URL}/formsemestre/{formsemestre_id}",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
formsemestre = r.json() formsemestre = r.json()
@ -115,6 +118,7 @@ def test_formsemestre(api_headers):
f"{API_URL}/formsemestre/{formsemestre_id_inexistant}", f"{API_URL}/formsemestre/{formsemestre_id_inexistant}",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 404 assert r.status_code == 404
@ -128,6 +132,7 @@ def test_formsemestre_apo(api_headers):
f"{API_URL}/formsemestres/query?etape_apo={etape_apo}", f"{API_URL}/formsemestres/query?etape_apo={etape_apo}",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
list_formsemestre = r.json() list_formsemestre = r.json()
@ -188,6 +193,7 @@ def test_bulletins(api_headers):
f"{API_URL}/formsemestre/{formsemestre_id}/bulletins", f"{API_URL}/formsemestre/{formsemestre_id}/bulletins",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
@ -384,7 +390,7 @@ def test_bulletins(api_headers):
bulletin_ues = bul["ues"] bulletin_ues = bul["ues"]
assert isinstance(bulletin_ues, dict) assert isinstance(bulletin_ues, dict)
for (key_ue, value_ue) in bulletin_ues.items(): for key_ue, value_ue in bulletin_ues.items():
assert verify_fields(value_ue, BULLETIN_UES_UE_FIELDS) is True assert verify_fields(value_ue, BULLETIN_UES_UE_FIELDS) is True
assert isinstance(value_ue["id"], int) assert isinstance(value_ue["id"], int)
assert isinstance(value_ue["titre"], str) assert isinstance(value_ue["titre"], str)
@ -550,6 +556,7 @@ def test_formsemestre_etudiants(api_headers):
f"{API_URL}/formsemestre/{id_formsemestre_inexistant}/etudiants", f"{API_URL}/formsemestre/{id_formsemestre_inexistant}/etudiants",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r_error.status_code == 404 assert r_error.status_code == 404
@ -557,6 +564,7 @@ def test_formsemestre_etudiants(api_headers):
f"{API_URL}/formsemestre/{id_formsemestre_inexistant}/etudiants/demissionnaires", f"{API_URL}/formsemestre/{id_formsemestre_inexistant}/etudiants/demissionnaires",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r_error_demissionnaires.status_code == 404 assert r_error_demissionnaires.status_code == 404
@ -564,6 +572,7 @@ def test_formsemestre_etudiants(api_headers):
f"{API_URL}/formsemestre/{id_formsemestre_inexistant}/etudiants/defaillants", f"{API_URL}/formsemestre/{id_formsemestre_inexistant}/etudiants/defaillants",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r_error_defaillants.status_code == 404 assert r_error_defaillants.status_code == 404
@ -577,6 +586,7 @@ def test_formsemestre_programme(api_headers):
API_URL + "/formsemestre/1/programme", API_URL + "/formsemestre/1/programme",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
prog = r.json() prog = r.json()
@ -678,6 +688,7 @@ def test_etat_evals(api_headers):
f"{API_URL}/formsemestre/{invalid_id}/etat_evals", f"{API_URL}/formsemestre/{invalid_id}/etat_evals",
headers=headers, headers=headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 404 assert r.status_code == 404
@ -693,6 +704,7 @@ def test_formsemestre_resultat(api_headers):
f"{API_URL}/formsemestre/{formsemestre_id}/resultats", f"{API_URL}/formsemestre/{formsemestre_id}/resultats",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
res = r.json() res = r.json()

View File

@ -14,6 +14,9 @@ utilisation:
# Ce test a une logique très différente des autres : A UNIFIER # Ce test a une logique très différente des autres : A UNIFIER
import requests import requests
from app.scodoc import sco_utils as scu
from scodoc import app
from tests.api.setup_test_api import ( from tests.api.setup_test_api import (
API_URL, API_URL,
api_admin_headers, api_admin_headers,
@ -21,7 +24,6 @@ from tests.api.setup_test_api import (
CHECK_CERTIFICATE, CHECK_CERTIFICATE,
) )
from scodoc import app
from tests.unit.config_test_logos import ( from tests.unit.config_test_logos import (
create_super_token, create_super_token,
create_admin_token, create_admin_token,
@ -39,6 +41,7 @@ def test_super_access(api_admin_headers):
API_URL + "/logos", API_URL + "/logos",
headers=api_admin_headers, headers=api_admin_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert response.status_code == 200 assert response.status_code == 200
assert response.json() is not None assert response.json() is not None
@ -52,6 +55,7 @@ def test_lambda_access(api_headers):
API_URL + "/logos", API_URL + "/logos",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert response.status_code == 401 assert response.status_code == 401
@ -64,6 +68,7 @@ def test_global_logos(api_admin_headers):
API_URL + "/logos", API_URL + "/logos",
headers=api_admin_headers, headers=api_admin_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert response.status_code == 200 assert response.status_code == 200
assert response.json() is not None assert response.json() is not None
@ -81,6 +86,7 @@ def test_local_by_id_logos(api_admin_headers):
API_URL + "/departement/id/1/logos", API_URL + "/departement/id/1/logos",
headers=api_admin_headers, headers=api_admin_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert response.status_code == 200 assert response.status_code == 200
assert response.json() is not None assert response.json() is not None
@ -111,6 +117,7 @@ def test_local_png_by_id_logo(api_admin_headers):
API_URL + "/departement/id/1/logo/D", API_URL + "/departement/id/1/logo/D",
headers=api_admin_headers, headers=api_admin_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert response.status_code == 200 assert response.status_code == 200
assert response.headers["Content-Type"] == "image/png" assert response.headers["Content-Type"] == "image/png"
@ -126,6 +133,7 @@ def test_global_png_logo(api_admin_headers):
API_URL + "/logo/C", API_URL + "/logo/C",
headers=api_admin_headers, headers=api_admin_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert response.status_code == 200 assert response.status_code == 200
assert response.headers["Content-Type"] == "image/png" assert response.headers["Content-Type"] == "image/png"
@ -141,6 +149,7 @@ def test_global_jpg_logo(api_admin_headers):
API_URL + "/logo/B", API_URL + "/logo/B",
headers=api_admin_headers, headers=api_admin_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert response.status_code == 200 assert response.status_code == 200
assert response.headers["Content-Type"] == "image/jpg" assert response.headers["Content-Type"] == "image/jpg"
@ -156,6 +165,7 @@ def test_local_png_by_name_logo(api_admin_headers):
API_URL + "/departement/TAPI/logo/D", API_URL + "/departement/TAPI/logo/D",
headers=api_admin_headers, headers=api_admin_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert response.status_code == 200 assert response.status_code == 200
assert response.headers["Content-Type"] == "image/png" assert response.headers["Content-Type"] == "image/png"
@ -171,6 +181,7 @@ def test_local_jpg_by_id_logo(api_admin_headers):
API_URL + "/departement/id/1/logo/A", API_URL + "/departement/id/1/logo/A",
headers=api_admin_headers, headers=api_admin_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert response.status_code == 200 assert response.status_code == 200
assert response.headers["Content-Type"] == "image/jpg" assert response.headers["Content-Type"] == "image/jpg"
@ -186,6 +197,7 @@ def test_local_jpg_by_name_logo(api_admin_headers):
API_URL + "/departement/TAPI/logo/A", API_URL + "/departement/TAPI/logo/A",
headers=api_admin_headers, headers=api_admin_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert response.status_code == 200 assert response.status_code == 200
assert response.headers["Content-Type"] == "image/jpg" assert response.headers["Content-Type"] == "image/jpg"

View File

@ -16,6 +16,7 @@ import requests
from tests.api.setup_test_api import API_URL, SCODOC_URL, CHECK_CERTIFICATE, api_headers from tests.api.setup_test_api import API_URL, SCODOC_URL, CHECK_CERTIFICATE, api_headers
from app import create_app from app import create_app
from app.scodoc import sco_utils as scu
from config import RunningConfig from config import RunningConfig
@ -69,6 +70,7 @@ def test_permissions(api_headers):
SCODOC_URL + path, SCODOC_URL + path,
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 200 assert r.status_code == 200
@ -81,11 +83,12 @@ def test_permissions(api_headers):
r = requests.get( r = requests.get(
SCODOC_URL + path, SCODOC_URL + path,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 401 assert r.status_code == 401
# Demande un jeton pour "other" # Demande un jeton pour "other"
r = requests.post(API_URL + "/tokens", auth=("other", "other")) r = requests.post(API_URL + "/tokens", auth=("other", "other"), timeout=10)
assert r.status_code == 200 assert r.status_code == 200
token = r.json()["token"] token = r.json()["token"]
headers = {"Authorization": f"Bearer {token}"} headers = {"Authorization": f"Bearer {token}"}
@ -99,5 +102,6 @@ def test_permissions(api_headers):
SCODOC_URL + path, SCODOC_URL + path,
headers=headers, headers=headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
timeout=scu.SCO_TEST_API_TIMEOUT,
) )
assert r.status_code == 401 assert r.status_code == 401

View File

@ -4,7 +4,9 @@ import requests
import sco_version import sco_version
import app.scodoc.sco_utils as scu import app.scodoc.sco_utils as scu
response = requests.get(scu.SCO_UP2DATE + "/" + sco_version.SCOVERSION) response = requests.get(
scu.SCO_UP2DATE + "/" + sco_version.SCOVERSION, timeout=scu.SCO_ORG_TIMEOUT
)
print(response.status_code) print(response.status_code)
print(response.text) print(response.text)