Пример #1
0
 def setUpTestUser(cls):
     """
     Set-up OS user for file system testing.
     """
     user = mk.makeTestUser(home_group=TEST_ACCOUNT_GROUP)
     os_administration.addUser(user)
     return user
Пример #2
0
def setup_access_control(users, groups):
    """
    Create testing environment access control.

    Add users, groups, create temporary folders and other things required
    by the testing system.
    """
    for group in groups.values():
        os_administration.addGroup(group)

    for user in users.values():
        os_administration.addUser(user)

    for group in groups.values():
        os_administration.addUsersToGroup(group, group.members)
Пример #3
0
    def test_getHomeFolder_nt_good(self):
        """
        If a valid token is provided the home folder path can be retrieved
        for it's corresponding account, as long as the process has the
        required capabilities.
        """
        test_user = TestUser(
            name=mk.string(),
            password=mk.string(),
            create_local_profile=True,
            )
        os_administration.addUser(test_user)

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

        self.assertContains(
            test_user.name.lower(), home_folder.lower())
        self.assertIsInstance(text_type, home_folder)
        self.addCleanup(os_administration.deleteUser, test_user)
Пример #4
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)
Пример #5
0
 def setUpTestUser(cls):
     """
     Add `CREATE_TEST_USER` to local OS.
     """
     os_administration.addUser(cls.CREATE_TEST_USER)
     return cls.CREATE_TEST_USER