Beispiel #1
0
def teardown_access_control(users, groups):
    """
    Revert changes from setup_access_control.

    It aggregates all teardown errors and report them at exit.
    """
    # First remove the accounts as groups can not be removed first
    # since they are blocked by accounts.
    errors = []
    for user in users.values():
        try:
            os_administration.deleteUser(user)
        except Exception as error:
            errors.append(error)

    for group in groups.values():
        try:
            os_administration.deleteGroup(group)
        except Exception as error:
            errors.append(error)

    if errors:
        raise AssertionError(errors)
Beispiel #2
0
    def test_getHomeFolder_nt_no_existing_profile(self):
        """
        On Windows, if user has no local home folder it will be created
        automatically when getting the home folder path.

        This test creates a temporary account and in the end it deletes
        the account and it's home folder.
        """
        test_user = TestUser(
            name=u'no-home',
            password=mk.string(),
            create_local_profile=False,
            )
        # Unfortunately there is no API to get default base home path for
        # users, we need to rely on an existing pattern.
        home_base = os.path.dirname(os.getenv('USERPROFILE'))
        expected_home_path = os.path.join(home_base, test_user.name)
        expected_home_segments = mk.fs.getSegmentsFromRealPath(
            expected_home_path)

        try:
            os_administration.addUser(test_user)
            # Home folder path is not created on successful login.
            token = test_user.token
            self.assertFalse(mk.fs.isFolder(expected_home_segments))

            self.home_folder = system_users.getHomeFolder(
                username=test_user.name, token=token)

            self.assertContains(
                test_user.name.lower(), self.home_folder.lower())
            self.assertIsInstance(text_type, self.home_folder)
            self.assertTrue(mk.fs.isFolder(expected_home_segments))
        finally:
            os_administration.deleteUser(test_user)
            os_administration.deleteHomeFolder(test_user)
Beispiel #3
0
    def tearDownClass(cls):
        if not cls.os_user.windows_create_local_profile:
            os_administration.deleteHomeFolder(cls.os_user)
        os_administration.deleteUser(cls.os_user)

        super(FileSystemTestCase, cls).tearDownClass()