예제 #1
0
파일: test_user.py 프로젝트: ocni-dtu/maas
    def test_update_as_admin_event_log(self):
        admin_user = factory.make_admin()
        handler = UserHandler(admin_user, {}, None)
        user = factory.make_User()
        params = make_user_attribute_params(user)
        params.update({
            "id":
            user.id,
            "last_name":
            factory.make_name("Newname"),
            "email":
            "new-{}@example.com".format(factory.make_string()),
            "is_superuser":
            True,
            "username":
            factory.make_name("newname"),
        })

        handler.update(params)

        event = Event.objects.get(type__level=AUDIT)
        self.assertIsNotNone(event)
        self.assertEqual(
            event.description,
            ("Updated user profile (username: {username}, "
             "full name: {last_name}, "
             "email: {email}, administrator: True)").format(**params),
        )
예제 #2
0
파일: test_user.py 프로젝트: ocni-dtu/maas
    def test_update_self_as_unprivileged(self):
        user = factory.make_User()
        handler = UserHandler(user, {}, None)
        params = make_user_attribute_params(user)
        params.update({
            "id":
            user.id,
            "last_name":
            factory.make_name("Newname"),
            "email":
            "new-{}@example.com".format(factory.make_string()),
            "is_superuser":
            True,
            "username":
            factory.make_name("newname"),
        })

        handler.update(params)
        self.assertAttributes(reload_object(user),
                              subset_dict(params, user_attributes))
예제 #3
0
    def test_update_self_as_unprivileged(self):
        user = factory.make_User()
        handler = UserHandler(user, {}, None)
        params = make_user_attribute_params(user)
        params.update({
            'id':
            user.id,
            'last_name':
            factory.make_name('Newname'),
            'email':
            'new-{}@example.com'.format(factory.make_string()),
            'is_superuser':
            True,
            'username':
            factory.make_name('newname'),
        })

        handler.update(params)
        self.assertAttributes(reload_object(user),
                              subset_dict(params, user_attributes))
예제 #4
0
파일: test_user.py 프로젝트: ocni-dtu/maas
    def test_update_other_as_unprivileged(self):
        unpriv_user = factory.make_User()
        handler = UserHandler(unpriv_user, {}, None)
        user = factory.make_User()
        params = make_user_attribute_params(user)
        params.update({
            "id":
            user.id,
            "last_name":
            factory.make_name("Newname"),
            "email":
            "new-{}@example.com".format(factory.make_string()),
            "is_superuser":
            True,
            "username":
            factory.make_name("newname"),
        })

        with self.assertRaises(HandlerPermissionError):
            handler.update(params)
예제 #5
0
    def test_update_other_as_unprivileged(self):
        unpriv_user = factory.make_User()
        handler = UserHandler(unpriv_user, {}, None)
        user = factory.make_User()
        params = make_user_attribute_params(user)
        params.update({
            'id':
            user.id,
            'last_name':
            factory.make_name('Newname'),
            'email':
            'new-{}@example.com'.format(factory.make_string()),
            'is_superuser':
            True,
            'username':
            factory.make_name('newname'),
        })

        with self.assertRaises(HandlerPermissionError):
            handler.update(params)