Ejemplo n.º 1
0
def new_user(username=None, password=None, superuser=False):
    user = User(
            username=username or fake.user_name(),
            password=password or fake.password(),
            superuser=superuser
    )
    user.save()
    return user
Ejemplo n.º 2
0
 def run(self):
     from ulakbus.models import AbstractRole, User, Role, Permission
     if User.objects.filter(username=self.manager.args.username).count():
         return "User already exists!"
     abs_role, new = AbstractRole.objects.get_or_create(name=self.manager.args.abstract_role)
     user = User(username=self.manager.args.username, superuser=self.manager.args.super)
     user.set_password(self.manager.args.password)
     user.save()
     role = Role(user=user, abstract_role=abs_role).save()
     perm_list = []
     for perm in Permission.objects.raw(self.manager.args.permission_query):
         role.Permissions(permission=perm)
         perm_list.append(perm.name)
     role.save()
     user_type = 'super user' if self.manager.args.super else 'user'
     return "New %s created with these permissions: \n\n%s" % (user_type, "\n".join(perm_list))
Ejemplo n.º 3
0
def test_add_user_then_login():
    User.objects._clear_bucket()
    sleep(1)
    u = User(username='user')
    u.set_password('123')
    u.save()
    sleep(1)
    wfc = workflow_connector()
    session = MockSessionStore()
    req = make_request(session)
    resp = DotDict()
    wfc.on_post(req, resp=resp, wf_name='simple_login')
    assert req['context']['result']['forms'] == LoginForm(types={"password": "password"}).serialize()
    req = make_request(session, cmd='do',
                       login_crd={'username': 'user', 'password': '123'})
    wfc.on_post(req, resp=DotDict(), wf_name='simple_login')
    assert session['user_id'] == u.key
    assert req['context']['result']['screen'] == 'dashboard'
Ejemplo n.º 4
0
def new_user(username=None, password=None, superuser=False):
    """
    Rastgele verileri ve parametre olarak verilen verileri
    kullanarak yeni değerlendirme notu kaydı oluşturup kaydeder.

    Args:
        username (str): Kullanıcı adı
        password (str): Şifre
        superuser (bool): Süper kullanıcı

    Returns:
        Kullanıcı kaydı

    """
    
    user = User(
        username=username or fake.user_name(),
        password=password or fake.password(),
        superuser=superuser
    )
    user.save()
    return user