Ejemplo n.º 1
0
 def tearDown(self):
     with self.app.app_context():
         legacy.drop_all()
         users.drop_all()
     try:
         os.remove(self.db)
     except FileNotFoundError:
         pass
Ejemplo n.º 2
0
def stop_container(container):
    subprocess.run(f"docker rm -f {container}",
                   stdout=subprocess.PIPE,
                   stderr=subprocess.PIPE,
                   shell=True)
    from accounts.services import legacy, users
    legacy.drop_all()
    users.drop_all()
Ejemplo n.º 3
0
    def setUp(self):
        self.app = create_web_app()
        self.app.config['CLASSIC_COOKIE_NAME'] = 'foo_tapir_session'
        self.app.config['AUTH_SESSION_COOKIE_NAME'] = 'baz_session'
        self.app.config['AUTH_SESSION_COOKIE_SECURE'] = '0'
        self.app.config['SESSION_DURATION'] = self.expiry
        self.app.config['JWT_SECRET'] = self.secret
        self.app.config['CLASSIC_DATABASE_URI'] = f'sqlite:///{self.db}'
        self.app.config['SQLALCHEMY_DATABASE_URI'] = f'sqlite:///{self.db}'
        self.app.config['REDIS_HOST'] = 'localhost'
        self.app.config['REDIS_PORT'] = '7000'
        self.app.config['REDIS_CLUSTER'] = '1'

        with self.app.app_context():
            legacy.drop_all()
            users.drop_all()
            legacy.create_all()
            users.create_all()

            with users.transaction() as session:
                # We have a good old-fashioned user.
                db_user = users.models.DBUser(
                    user_id=1,
                    first_name='first',
                    last_name='last',
                    suffix_name='iv',
                    email='*****@*****.**',
                    policy_class=2,
                    flag_edit_users=1,
                    flag_email_verified=1,
                    flag_edit_system=0,
                    flag_approved=1,
                    flag_deleted=0,
                    flag_banned=0,
                    tracking_cookie='foocookie',
                )
                db_nick = users.models.DBUserNickname(nick_id=1,
                                                      nickname='foouser',
                                                      user_id=1,
                                                      user_seq=1,
                                                      flag_valid=1,
                                                      role=0,
                                                      policy=0,
                                                      flag_primary=1)
                salt = b'fdoo'
                password = b'thepassword'
                hashed = hashlib.sha1(salt + b'-' + password).digest()
                encrypted = b64encode(salt + hashed)
                db_password = users.models.DBUserPassword(
                    user_id=1, password_storage=2, password_enc=encrypted)
                session.add(db_user)
                session.add(db_password)
                session.add(db_nick)