Exemplo n.º 1
0
    def run(self, args):
        settings = get_appsettings(self.config_uri)
        engine = engine_from_config(settings, "sqlalchemy.")
        session = sessionmaker(bind=engine)()

        bcrypt_rounds = settings.get("paildocket.password.bcrypt_rounds")
        pwctx = create_password_context(bcrypt__default_rounds=bcrypt_rounds)

        username = input("Enter username: "******"Enter email: ")
        password = getpass.getpass()
        session.add(User(username=username, email=email, password_hash=pwctx.encrypt(password)))
        logger.info("Creating user {0} with email {1}".format(username, email))
        session.commit()
Exemplo n.º 2
0
import os.path
import uuid

import pytest

from paildocket.security import create_password_context


TESTS_DIR = os.path.dirname(os.path.abspath(__file__))
TESTS_INI = os.path.join(TESTS_DIR, 'unittests.ini')


UUID_USERID = uuid.UUID('ccd6a2d7-a22a-4487-97a4-9afef9d77718')
ENCODED_USERID = 'zNai16IqRIeXpJr--dd3GA'

insecure_but_fast_password_context = create_password_context(
    bcrypt__default_rounds=4)
insecure_hash_password = insecure_but_fast_password_context.encrypt


class DummyObject(object):
    pass


class DummyCallable(object):
    def __init__(self, returnval):
        self.args = None
        self.kwargs = None
        self.returnval = returnval

    def __call__(self, *args, **kwargs):
        self.args = args