Projekt

Obecné

Profil

« Předchozí | Další » 

Revize da0fc952

Přidáno uživatelem Stanislav Král před téměř 4 roky(ů)

Added a global error handler for CryptographyException errors.
Added a dependency ony pytest-mock library in order to be able to mock method calls in tests.
Covered the added global CryptographyException error handler in a test.

Zobrazit rozdíly:

src/controllers/certificates_controller.py
65 65
E_INVALID_EXTENSIONS = {"success": False, "data": "Error occurred while creating a certificate. "
66 66
                                                  "It may be caused by wrong format of extensions."}
67 67

  
68
E_UNHANDLED_CRYPTOGRAPHY_ERROR = {"success": False, "data": "An unknown error has happened in the cryptography library."}
69

  
68 70

  
69 71
class CertController:
70 72
    USAGE_KEY_MAP = {'CA': CA_ID, 'SSL': SSL_ID, 'digitalSignature': SIGNATURE_ID, 'authentication': AUTHENTICATION_ID}
......
768 770
                                                                                          identity_name,
769 771
                                                                                          identity_password)
770 772
                    return Response(identity_byte_array, mimetype='application/x-pkcs12')
773

  
774
    @staticmethod
775
    def handle_cryptography_error(e):
776
        Logger.error(f"An unhandled CryptographyException has been raised: {str(e)}")
777
        return E_UNHANDLED_CRYPTOGRAPHY_ERROR, C_INTERNAL_SERVER_ERROR

Také k dispozici: Unified diff