# 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
        self.player_id = self.current_user["player_id"]
        self.user_id = self.current_user["user_id"]
        self.headers = {"Authorization": "JWT " + token, }
        self.player_name = service_username

        r = self.get("/")
        self.endpoints = r.json()["endpoints"]

    @classmethod
    def _authenticate_with_provider(cls, auth_info):
        user_name = auth_info['username'] or 'systest'
        user_id = abs(hash(user_name) & 0x7FFFFF)
        identity = {
            'user_name': auth_info['username'] or 'systest_user_name',
            'user_id': user_id,
            'identity_id': user_id + 1,
            'player_id': user_id + 2,
            'player_name': auth_info['username'] or 'systest_player_name',
            'roles': ['service'] if user_name == service_username else [],
        }
        return identity

    @classmethod
    def setUpClass(cls):
        ts = setup_tenant()
        cls.host = "http://localhost"
        app = drift_app()
        cls.app = app.test_client()

        # Add a 'unit_test' authentication provider

# 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

        self.player_id = self.current_user["player_id"]
        self.user_id = self.current_user["user_id"]
        self.headers = {"Authorization": "JWT " + token, }
        self.player_name = service_username

        r = self.get("/")
        self.endpoints = r.json()["endpoints"]

    @classmethod
    def _authenticate_with_provider(cls, auth_info):
        user_name = auth_info['username'] or 'systest'
        user_id = abs(hash(user_name) & 0x7FFFFF)
        identity = {
            'user_name': auth_info['username'] or 'systest_user_name',
            'user_id': user_id,
            'identity_id': user_id + 1,
            'player_id': user_id + 2,
            'player_name': auth_info['username'] or 'systest_player_name',
            'roles': ['service'] if user_name == service_username else [],
        }
        return identity

    @classmethod
    def setUpClass(cls):
        ts = setup_tenant()
        cls.host = "http://localhost"
        app = drift_app()
        cls.app = app.test_client()

        # Add a 'unit_test' authentication provider

        register_auth_provider(app, AUTH_TEST_PROVIDER, cls._authenticate_with_provider)