Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 9c704fb1

Přidáno uživatelem Jan Pašek před asi 4 roky(ů)

Re #8571 - RestAPI testing

Zobrazit rozdíly:

src/controllers/certificates_controller.py
12 12
from src.exceptions.database_exception import DatabaseException
13 13
from src.model.subject import Subject
14 14
from src.services.certificate_service import CertificateService, RevocationReasonInvalidException, \
15
    CertificateStatusInvalidException
15
    CertificateStatusInvalidException, CertificateNotFoundException
16 16
#  responsibility.
17 17
from src.services.key_service import KeyService
18 18

  
......
31 31
CA = "CA"
32 32
STATUS = "status"
33 33
REASON = "reason"
34
REASON_UNDEFINED = "undefined"
34
REASON_UNDEFINED = "unspecified"
35 35

  
36 36
E_NO_ISSUER_FOUND = {"success": False, "data": "No certificate authority with such unique ID exists."}
37 37
E_NO_CERTIFICATES_FOUND = {"success": False, "data": "No such certificate found."}
......
339 339
            reason = request_body.get(REASON, REASON_UNDEFINED)
340 340
            try:
341 341
                # set certificate status using certificate_service
342
                self.certificate_service.set_certificate_revocation_status(status, reason)
343
            except (RevocationReasonInvalidException, CertificateStatusInvalidException):
342
                self.certificate_service.set_certificate_revocation_status(identifier, status, reason)
343
            except (RevocationReasonInvalidException, CertificateStatusInvalidException, CertificateNotFoundException):
344 344
                # these exceptions are thrown in case invalid status or revocation reason is passed to the controller
345 345
                return E_WRONG_PARAMETERS, C_BAD_REQUEST
346
            except DatabaseException:
347
                return E_WRONG_PARAMETERS, C_BAD_REQUEST
348 346
            return {"success": True,
349
                    "data": "Certificate status updated successfully."}, C_CREATED_SUCCESSFULLY
347
                    "data": "Certificate status updated successfully."}, C_SUCCESS
350 348
        # throw an error in case the request does not contain a json body
351 349
        else:
352 350
            return E_NOT_JSON_FORMAT, C_BAD_REQUEST

Také k dispozici: Unified diff