Esempio n. 1
0
def setUp():
    cleanUp()

    user_admin = dict(**USER_BASE, email='*****@*****.**')
    user_admin_info = UsersBusiness.create(user_admin, admin=True)
    user = dict(**USER_BASE, email='*****@*****.**')
    user_info = UsersBusiness.create(user, admin=False)
    return user_admin_info, user_info
Esempio n. 2
0
    def post(self):
        """
        create new user
        """
        data, status = validate(request.json,
                                'user_create',
                                validate_password=True)
        if status is False:
            raise BadRequest(json.dumps(data))

        admin = data.get('admin', False)

        # Only admin users can create.
        if admin:
            user_id, grants, _ = get_userinfo_by_token()

            if 'admin' not in grants:
                raise Forbidden('You need to be an administrator!')

        user = UsersBusiness.create(data, admin=admin)

        if not user:
            raise InternalServerError('Error creating user!')

        return marshal(user, get_user_serializer()), 200
Esempio n. 3
0
def setUp():
    cleanUp()

    user_admin = dict(
        **USER_BASE,
        email='*****@*****.**'
    )
    user_admin_info = UsersBusiness.create(user_admin, admin=True)
    user = dict(
        **USER_BASE,
        email='*****@*****.**'
    )
    user_info = UsersBusiness.create(user, admin=False)

    app_1_info = dict(
        client_name='test',
        client_uri='http://localhost:8080/test',
        redirect_uri='http://localhost:8080/test/test',
        type_secret='string',
        client_secret='abc',
        user_id=[user_admin_info['_id']],
        created_at=datetime.now(),
        expired_at=None,
        _id=ObjectId('5e59557579da4ec3ff04a682')
    )
    app_2_info = dict(
        client_name='registry',
        client_uri='http://localhost:8080/registry',
        redirect_uri='http://localhost:8080/registry/test',
        type_secret='file',
        client_secret='/data/home/key',
        user_id=[user_info['_id']],
        created_at=datetime.now(),
        expired_at=None,
        _id=ObjectId('5e59557579da4ec3ff04a683')
    )
    mongo.db.clients.insert_many([app_1_info, app_2_info])
    return user_admin_info, user_info