# Path: drift/core/extensions/jwt.py
# JWT_ALGORITHM = 'RS256'
# 
# def register_auth_provider(app, provider, handler):
#     if not hasattr(app, "jwt_auth_providers"):
#         app.jwt_auth_providers = {}
#     app.jwt_auth_providers[provider] = handler
# 
# Path: drift/flaskfactory.py
# def drift_app(app=None):
#     try:
#         return _drift_app(app=app)
#     except Exception:
#         log.exception("Flask app creation failed.")


import os
import sys
import uuid
import copy
import unittest
import responses
import requests
import re
import jwt
import driftconfig.testhelpers
import logging
from six.moves import http_client
from driftconfig.util import set_sticky_config, get_default_drift_config
from drift.core.extensions.jwt import JWT_ALGORITHM, register_auth_provider
from .flaskfactory import drift_app
    from drift.flaskfactory import load_flask_config, set_sticky_app_config
        from drift.flaskfactory import set_sticky_app_config
    def put(self, *args, **kw):
        return self._do_request("put", *args, **kw)

    def post(self, *args, **kw):
        return self._do_request("post", *args, **kw)

    def delete(self, *args, **kw):
        return self._do_request("delete", *args, **kw)

    def patch(self, *args, **kw):
        return self._do_request("patch", *args, **kw)

    def setUp(self):
        pass

    def auth(self, username=None, player_name=None):
        """
        Do an auth call against the current app's /auth endpoint and fetch the
        root document which includes all user endpoints.
        """
        username = username or "systest"
        payload = {
            "provider": self.auth_provider,
            "username": username,
            "password": local_password,
        }
        resp = self.post("/auth", data=payload)

        self.token = resp.json()["token"]
        self.jti = resp.json()["jti"]

# Path: drift/core/extensions/jwt.py
# JWT_ALGORITHM = 'RS256'
# 
# def register_auth_provider(app, provider, handler):
#     if not hasattr(app, "jwt_auth_providers"):
#         app.jwt_auth_providers = {}
#     app.jwt_auth_providers[provider] = handler
# 
# Path: drift/flaskfactory.py
# def drift_app(app=None):
#     try:
#         return _drift_app(app=app)
#     except Exception:
#         log.exception("Flask app creation failed.")


# Path: drift/systesthelper.py
import os
import sys
import uuid
import copy
import unittest
import responses
import requests
import re
import jwt
import driftconfig.testhelpers
import logging
from six.moves import http_client
from driftconfig.util import set_sticky_config, get_default_drift_config
from drift.core.extensions.jwt import JWT_ALGORITHM, register_auth_provider
from .flaskfactory import drift_app
    from drift.flaskfactory import load_flask_config, set_sticky_app_config
        from drift.flaskfactory import set_sticky_app_config

    def put(self, *args, **kw):
        return self._do_request("put", *args, **kw)

    def post(self, *args, **kw):
        return self._do_request("post", *args, **kw)

    def delete(self, *args, **kw):
        return self._do_request("delete", *args, **kw)

    def patch(self, *args, **kw):
        return self._do_request("patch", *args, **kw)

    def setUp(self):
        pass

    def auth(self, username=None, player_name=None):
        """
        Do an auth call against the current app's /auth endpoint and fetch the
        root document which includes all user endpoints.
        """
        username = username or "systest"
        payload = {
            "provider": self.auth_provider,
            "username": username,
            "password": local_password,
        }
        resp = self.post("/auth", data=payload)

        self.token = resp.json()["token"]
        self.jti = resp.json()["jti"]

        self.current_user = jwt.decode(self.token, options={"verify_signature":False}, algorithms=[JWT_ALGORITHM])