Esempio n. 1
0
def create_users():
    """Create test users."""
    engine = get_engine('default')
    users.create_user_sync(engine, username='******', password='******')
    users.create_user_sync(engine,
                           username='******',
                           password='******')
Esempio n. 2
0
def test_create_user_sync(test_project, waf):
    """Test creating a user from engine."""
    engine = get_engine('default')
    users.create_user_sync(engine, username='******', password='******')
    with engine.connect() as con:
        query = sa.select('*').select_from(
            tables.user).where(tables.user.c.username == 'test2')
        row = [r for r in con.execute(query)][0]
        assert users.check_password('pass2', row.password)
Esempio n. 3
0
def create_admin_test_data_user(name, password='******'):
    """Create test users."""
    engine = get_engine('default')
    users.create_user_sync(engine, username=name, password=password)
    with engine.connect() as con:
        query = sa.select('*').select_from(tables.user).where(tables.user.c.username==name)
        results = con.execute(query)
        user_row = results.fetchone()
    return user_row.id, user_row.username, password
Esempio n. 4
0
def admin_login_user():
    engine = get_engine('default')
    username='******'
    password='******'
    users.create_user_sync(engine, username=username, password=password, is_staff=True, is_superuser=True)
    with engine.connect() as con:
        query = sa.select('*').select_from(tables.user).where(tables.user.c.username==username)
        results = con.execute(query)
        user_row = results.fetchone()
    return user_row.id, user_row.username, password
Esempio n. 5
0
 def handle(self, **options):
     print('Create a super user')
     Jawaf(settings.PROJECT_NAME)
     username = input('Username: '******'Email Address: ')
     engine = get_engine()
     password = None
     while (password is None):
         password = getpass.getpass()
         password2 = getpass.getpass('Password (again): ')
         if not self._validate_password(password, password2):
             password = None
     create_user_sync(engine,
                      username=username,
                      password=password,
                      email=email,
                      is_staff=True,
                      is_superuser=True)
def create_groups():
    """Create test users."""
    engine = get_engine('default')
    users.create_user_sync(engine,
                           username='******',
                           password='******')
    users.create_user_sync(engine,
                           username='******',
                           password='******')
    group_id = permissions.create_group_sync(engine,
                                             name='AdminEditors',
                                             permission_pairs=({
                                                 'name':
                                                 'get',
                                                 'target':
                                                 'test_app'
                                             }, ))
    with engine.connect() as con:
        query = sa.select('*').select_from(tables.user).where(
            tables.user.c.username == 'permission_test_admin')
        user_row = [r for r in con.execute(query)][0]
    permissions.add_user_to_group_sync(engine, user_row.id, group_id)