Exemplo n.º 1
0
    def test_authentication_jwt_not_encrypted_fail(self):
        """Authenticate request using JWT without encryption"""

        data = {"RU": "12345678910", "survey": "BRS"}

        with self.assertRaises(BadRequest):
            res = check_jwt(encode(data))
Exemplo n.º 2
0
def update_encrypted_jwt():
    encrypter = Encrypter(
        _private_key=settings.SM_USER_AUTHENTICATION_PRIVATE_KEY,
        _private_key_password=settings.
        SM_USER_AUTHENTICATION_PRIVATE_KEY_PASSWORD,
        _public_key=settings.SM_USER_AUTHENTICATION_PUBLIC_KEY)
    signed_jwt = encode(token_data)
    return encrypter.encrypt_token(signed_jwt)
Exemplo n.º 3
0
 def test_authentication_jwt_pass(self):
     """Authenticate request using correct JWT"""
     expected_res = {'status': "ok"}
     data = {"RU": "12345678910", "survey": "BRS", "CC": "URN"}
     encrypter = Encrypter(
         _private_key=settings.SM_USER_AUTHENTICATION_PRIVATE_KEY,
         _private_key_password=settings.
         SM_USER_AUTHENTICATION_PRIVATE_KEY_PASSWORD,
         _public_key=settings.SM_USER_AUTHENTICATION_PUBLIC_KEY)
     signed_jwt = encode(data)
     encrypted_jwt = encrypter.encrypt_token(signed_jwt)
     res = check_jwt(encrypted_jwt)
     self.assertEqual(res, expected_res)
Exemplo n.º 4
0
 def test_authentication_jwt_survey_invalid_fail(self):
     """Authenticate request using invalid survey claim"""
     expected_res = Response(
         response="Survey required to access this Microservice Resource",
         status=400,
         mimetype="text/html")
     data = {"RU": "12345678910", "survey": "", "CC": "URN"}
     encrypter = Encrypter(
         _private_key=settings.SM_USER_AUTHENTICATION_PRIVATE_KEY,
         _private_key_password=settings.
         SM_USER_AUTHENTICATION_PRIVATE_KEY_PASSWORD,
         _public_key=settings.SM_USER_AUTHENTICATION_PUBLIC_KEY)
     signed_jwt = encode(data)
     encrypted_jwt = encrypter.encrypt_token(signed_jwt)
     res = check_jwt(encrypted_jwt)
     self.assertEqual(res.response, expected_res.response)