Esempio n. 1
0
    def test_refresh_token_not_exists(self):

        with patch("app.src.common.auth.config.redis",
                   new=self.mock_redis) as mock_redis:
            exists = Auth.refresh_token_exists("refresh_id", "not")

        self.assertFalse(exists)
Esempio n. 2
0
        def wrapper(*args, **kwars):

            token = request.headers.get("REFRESH_TOKEN")

            try:
                if not token or token.split(" ")[0] != "Bearer":
                    raise InvalidTokenError(token,
                                            "Token must be a bearer token",
                                            "Invalid token")

                exists = Auth.refresh_token_exists(token.split(" ")[1], role)

                if not exists:
                    raise InvalidTokenError(token, "Invalid refresh token",
                                            "Invalid token")

            except InvalidTokenError as e:
                return Utils.response(status=e.status,
                                      message="Invalid token",
                                      data=e.errors)

            return f(*args, **kwars)