Example #1
0
    def test_create_with_attr(self, stageduser2, user, user_activated):
        """ Tests creating a user with various valid attributes listed
        in 'options_ok' list"""
        # create staged user with specified parameters
        user.ensure_exists()  # necessary for manager test
        stageduser2.ensure_missing()
        command = stageduser2.make_create_command()
        result = command()
        stageduser2.track_create()
        stageduser2.check_create(result)

        # activate user, verify that specified values were preserved
        # after activation
        user_activated.ensure_missing()
        user_activated = UserTracker(stageduser2.uid, stageduser2.givenname,
                                     stageduser2.sn, **stageduser2.kwargs)
        user_activated.create_from_staged(stageduser2)
        command = stageduser2.make_activate_command()
        result = command()
        user_activated.check_activate(result)

        # verify the staged user does not exist after activation
        command = stageduser2.make_retrieve_command()
        with raises_exact(
                errors.NotFound(reason=u'%s: stage user not found' %
                                stageduser2.uid)):
            command()

        user_activated.delete()
Example #2
0
    def test_create_with_attr(self, stageduser2, user, user_activated):
        """ Tests creating a user with various valid attributes listed
        in 'options_ok' list"""
        # create staged user with specified parameters
        user.ensure_exists()  # necessary for manager test
        stageduser2.ensure_missing()
        command = stageduser2.make_create_command()
        result = command()
        stageduser2.track_create()
        stageduser2.check_create(result)

        # activate user, verify that specified values were preserved
        # after activation
        user_activated.ensure_missing()
        user_activated = UserTracker(
            stageduser2.uid, stageduser2.givenname,
            stageduser2.sn, **stageduser2.kwargs)
        user_activated.create_from_staged(stageduser2)
        command = stageduser2.make_activate_command()
        result = command()
        user_activated.check_activate(result)

        # verify the staged user does not exist after activation
        command = stageduser2.make_retrieve_command()
        with raises_exact(errors.NotFound(
                reason=u'%s: stage user not found' % stageduser2.uid)):
            command()

        user_activated.delete()
Example #3
0
    def test_activate(self, stageduser3, user2):
        stageduser3.ensure_exists()
        user2.ensure_missing()
        user2 = UserTracker(
            stageduser3.uid, stageduser3.givenname, stageduser3.sn)
        user2.create_from_staged(stageduser3)
        command = stageduser3.make_activate_command()
        result = command()
        user2.check_activate(result)

        command = stageduser3.make_retrieve_command()
        with raises_exact(errors.NotFound(
                reason=u'%s: stage user not found' % stageduser3.uid)):
            command()
        user2.delete()
Example #4
0
    def test_activate(self, stageduser3, user2):
        stageduser3.ensure_exists()
        user2.ensure_missing()
        user2 = UserTracker(
            stageduser3.uid, stageduser3.givenname, stageduser3.sn)
        user2.create_from_staged(stageduser3)
        command = stageduser3.make_activate_command()
        result = command()
        user2.check_activate(result)

        command = stageduser3.make_retrieve_command()
        with raises_exact(errors.NotFound(
                reason=u'%s: stage user not found' % stageduser3.uid)):
            command()
        user2.delete()
    def test_stageduser_customattr(self, stageduser_customattr):
        # Create a staged user with attributes not accessible
        # through the options
        # --setattr is needed here
        command = stageduser_customattr.make_create_command()
        result = command()
        stageduser_customattr.check_create(result, [u'businesscategory'])

        # Activate the staged user
        user_customattr = UserTracker(stageduser_customattr.uid,
                                      stageduser_customattr.givenname,
                                      stageduser_customattr.sn)
        user_customattr.create_from_staged(stageduser_customattr)
        user_customattr.attrs[u'businesscategory'] = [u'BusinessCat']

        command = stageduser_customattr.make_activate_command()
        result = command()
        user_customattr.check_activate(result)

        # Check that the user contains businesscategory
        command = user_customattr.make_retrieve_command(all=True)
        result = command()
        assert 'BusinessCat' in result['result'][u'businesscategory']

        # delete the user with --preserve
        user_customattr.track_delete(preserve=True)
        command = user_customattr.make_delete_command(no_preserve=False,
                                                      preserve=True)
        result = command()
        user_customattr.check_delete(result)

        # Check that the preserved user contains businesscategory
        command = user_customattr.make_retrieve_command(all=True)
        result = command()
        assert 'BusinessCat' in result['result'][u'businesscategory']

        # Move the user from preserved to stage
        command = user_customattr.make_stage_command()
        result = command()
        stageduser_customattr.check_restore_preserved(result)

        # Check that the stage user contains businesscategory
        command = stageduser_customattr.make_retrieve_command(all=True)
        result = command()
        assert 'BusinessCat' in result['result'][u'businesscategory']