from flask import Flask, session
from flask_sqlalchemy import SQLAlchemy
import os
import uuid
import datetime


class FlaskOIDCMock(Flask):

    def _before_request(self):
        session["user"] = {
            "sub": "939ac645-66f9-4b11-9573-140a2ec55e42",
            "preferred_username": "joost@idm.localhost",
            "name": "Joost",
        }

    def __init__(self, *args, **kwargs):
        super(FlaskOIDCMock, self).__init__(*args, **kwargs)
        self.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///sessions.db"
        self.config["SECRET_KEY"] = os.environ["SECRET_KEY"]
        self.db = SQLAlchemy(self)
        self.before_request(self._before_request)
