Example #1
0
def setup_package():
    # Don't run these tests if we can not access privileged OS part.
    if not ChevahTestCase.haveSuperPowers():
        raise ChevahTestCase.skipTest()
    # Initialize the testing OS.

    try:
        setup_os(users=TEST_USERS, groups=TEST_GROUPS)
    except:
        import traceback
        print traceback.format_exc()
        print "Failed to initilized the system accounts!"
        teardown_os(users=TEST_USERS, groups=TEST_GROUPS)
        raise
Example #2
0
def runDomainTest():
    """
    Return True if buildslave is a domain member.
    """
    # For now, elevated tests are executed only on the domain controller
    # buildslave.
    if '-dc-' in ChevahTestCase.getHostname():
        return True

    return False
Example #3
0
    def setUserPassword(self, user):
        """
        On Windows we can not change the password without having the
        old password.

        For not this works, but this code is not 100% valid.
        """
        # NetUserChangePassword works a little different that other
        # Net* functions. In order to work on local computer it requires
        # that the first argument be the computer name and not 'None'
        # like the rest of Net* functions.
        pdc = user.pdc
        if not pdc:
            pdc = ChevahTestCase.getHostname()

        try:
            import win32net
            win32net.NetUserChangePassword(
                pdc, user.name, user.password, user.password)
        except:
            print('Failed to set password "%s" for user "%s" on pdc "%s".' % (
                user.password, user.name, pdc))
            raise
Example #4
0
def setup_package():
    # Don't run these tests if we can not access privileged OS part.
    if not runDomainTest():
        raise ChevahTestCase.skipTest()

    # Initialize the testing OS.
    DOMAIN_USERS = {
        u'domain': TestUser(
            name=TEST_ACCOUNT_USERNAME_DOMAIN,
            password=TEST_ACCOUNT_PASSWORD_DOMAIN,
            domain=TEST_DOMAIN,
            pdc=TEST_PDC,
            create_local_profile=True,
            ),
        }

    DOMAIN_GROUPS = {
        u'domain': TestGroup(
            name=TEST_ACCOUNT_GROUP_DOMAIN,
            members=[TEST_ACCOUNT_USERNAME_DOMAIN],
            pdc=TEST_PDC,
            ),
        }

    TEST_USERS.update(DOMAIN_USERS)
    TEST_GROUPS.update(DOMAIN_GROUPS)

    try:
        setup_access_control(
            users=TEST_USERS, groups=TEST_GROUPS)
    except:
        import traceback
        print(traceback.format_exc())
        print("Failed to initialized the system accounts!")
        teardown_access_control(
            users=TEST_USERS, groups=TEST_GROUPS)
        raise