def test_user_compare(topology):
    """
    Testing compare function
    1. Testing comparison of two different users.
    2. Testing comparison of 'str' object with itself, should raise 'ValueError'.
    3. Testing comparison of user with similar user (different object id).
    4. Testing comparison of user with group.
    """
    if DEBUGGING:
        # Add debugging steps(if any)...
        pass

    users = UserAccounts(topology.standalone, DEFAULT_SUFFIX)
    groups = Groups(topology.standalone, DEFAULT_SUFFIX)
    # Create 1st user
    user1_properties = {
        'uid': 'testuser1',
        'cn': 'testuser1',
        'sn': 'user',
        'uidNumber': '1000',
        'gidNumber': '2000',
        'homeDirectory': '/home/testuser1'
    }

    users.create(properties=user1_properties)
    testuser1 = users.get('testuser1')
    # Create 2nd user
    user2_properties = {
        'uid': 'testuser2',
        'cn': 'testuser2',
        'sn': 'user',
        'uidNumber': '1001',
        'gidNumber': '2002',
        'homeDirectory': '/home/testuser2'
    }

    users.create(properties=user2_properties)
    testuser2 = users.get('testuser2')
    # create group
    group_properties = {'cn': 'group1', 'description': 'testgroup'}

    testuser1_copy = users.get("testuser1")
    group = groups.create(properties=group_properties)

    assert (UserAccount.compare(testuser1, testuser2) == False)

    with pytest.raises(ValueError):
        UserAccount.compare("test_str_object", "test_str_object")

    assert (UserAccount.compare(testuser1, testuser1_copy) == True)
    assert (UserAccount.compare(testuser1, group) == False)

    log.info("Test PASSED")
def test_user_compare_i2(topology_i2):
    """
    Compare test between users of two different Directory Server intances.
    
    """
    if DEBUGGING:
        # Add debugging steps(if any)...
        pass
        
    st1_users = UserAccounts(topology_i2.ins.get('standalone1'), DEFAULT_SUFFIX)
    st2_users = UserAccounts(topology_i2.ins.get('standalone2'), DEFAULT_SUFFIX)

    # Create user
    user_properties = {
        'uid': 'testuser',
        'cn': 'testuser',
        'sn': 'user',
        'uidNumber': '1000',
        'gidNumber': '2000',
        'homeDirectory': '/home/testuser'
    }

    st1_users.create(properties=user_properties)
    st1_testuser = st1_users.get('testuser')

    st2_users.create(properties=user_properties)
    st2_testuser = st2_users.get('testuser')

    assert(UserAccount.compare(st1_testuser, st2_testuser) == True)

    log.info("Test PASSED")
Exemple #3
0
def test_user_compare_m2Repl(topology_m2):
    """
    User compare test between users of master to master replicaton topology.
    """
    if DEBUGGING:
        # Add debugging steps(if any)...
        pass

    m1 = topology_m2.ms.get('master1')
    m2 = topology_m2.ms.get('master2')

    m1_m2_agmtdn = m1.agreement.list(suffix=DEFAULT_SUFFIX)[0].dn

    m1_users = UserAccounts(m1, DEFAULT_SUFFIX)
    m2_users = UserAccounts(m2, DEFAULT_SUFFIX)

    # Create 1st user
    user1_properties = {
        'uid': 'testuser',
        'cn': 'testuser',
        'sn': 'user',
        'uidNumber': '1000',
        'gidNumber': '2000',
        'homeDirectory': '/home/testuser'
    }

    m1_users.create(properties=user1_properties)
    m1_testuser = m1_users.get('testuser')

    log.info("Waiting for completion of replicaation.....")
    # wait for replication to complete
    m1.startReplication(m1_m2_agmtdn)

    m1_ruv = m1.replica.ruv(DEFAULT_SUFFIX)
    m2_ruv = m2.replica.ruv(DEFAULT_SUFFIX)

    log.debug("m1 ruv : " + str(m1_ruv))
    log.debug("m2 ruv : " + str(m2_ruv))
    log.debug("RUV diffs: " + str(m1_ruv.getdiffs(m2_ruv)))

    # ruv comparison, if replication is complete then ruv's should be same
    assert (m1_ruv == m2_ruv)
    log.info("Replication completed")
    m2_testuser = m2_users.get('testuser')

    assert (UserAccount.compare(m1_testuser, m2_testuser) == True)
    log.info("Test PASSED")
Exemple #4
0
def test_user_compare_m2Repl(topology_m2):
    """
    User compare test between users of master to master replicaton topology.

    :id: 7c243bea-4075-4304-864d-5b789d364871

    :setup: 2 master MMR

    :steps: 1. Add a user to m1
            2. Wait for replication
            3. Compare if the user is the same

    :expectedresults: 1. User is added
                      2. Replication success
                      3. The user is the same
    """
    rm = ReplicationManager(DEFAULT_SUFFIX)
    m1 = topology_m2.ms.get('master1')
    m2 = topology_m2.ms.get('master2')

    m1_users = UserAccounts(m1, DEFAULT_SUFFIX)
    m2_users = UserAccounts(m2, DEFAULT_SUFFIX)

    # Create 1st user
    user1_properties = {
        'uid': 'testuser',
        'cn': 'testuser',
        'sn': 'user',
        'uidNumber': '1000',
        'gidNumber': '2000',
        'homeDirectory': '/home/testuser'
    }

    m1_users.create(properties=user1_properties)
    m1_testuser = m1_users.get('testuser')

    rm.wait_for_replication(m1, m2)

    m2_testuser = m2_users.get('testuser')

    assert UserAccount.compare(m1_testuser, m2_testuser)
Exemple #5
0
def test_user_compare_i2(topology_i2):
    """
    Compare test between users of two different Directory Server intances.

    :id: f0ffaf59-e2c2-41ec-9f26-e9b1ef287463

    :setup: two isolated directory servers

    :steps: 1. Add an identical user to each server
            2. Compare if the users are "the same"

    :expectedresults: 1. Users are added
                      2. The users are reported as the same
    """
    st1_users = UserAccounts(topology_i2.ins.get('standalone1'),
                             DEFAULT_SUFFIX)
    st2_users = UserAccounts(topology_i2.ins.get('standalone2'),
                             DEFAULT_SUFFIX)

    # Create user
    user_properties = {
        'uid': 'testuser',
        'cn': 'testuser',
        'sn': 'user',
        'uidNumber': '1000',
        'gidNumber': '2000',
        'homeDirectory': '/home/testuser'
    }

    st1_users.create(properties=user_properties)
    st1_testuser = st1_users.get('testuser')

    st2_users.create(properties=user_properties)
    st2_testuser = st2_users.get('testuser')

    st1_testuser._compare_exclude.append('entryuuid')
    st2_testuser._compare_exclude.append('entryuuid')

    assert UserAccount.compare(st1_testuser, st2_testuser)
def test_user_compare(topology):
    """
    Testing compare function

    :id: 26f2dea9-be1e-48ca-bcea-79592823390c

    :setup: Standalone instance

    :steps:
        1. Testing comparison of two different users.
        2. Testing comparison of 'str' object with itself.
        3. Testing comparison of user with similar user (different object id).
        4. Testing comparison of user with group.

    :expectedresults:
        1. Should fail to compare
        2. Should raise value error
        3. Should be the same despite uuid difference
        4. Should fail to compare
    """
    users = UserAccounts(topology.standalone, DEFAULT_SUFFIX)
    groups = Groups(topology.standalone, DEFAULT_SUFFIX)
    # Create 1st user
    user1_properties = {
        'uid': 'testuser1',
        'cn': 'testuser1',
        'sn': 'user',
        'uidNumber': '1000',
        'gidNumber': '2000',
        'homeDirectory': '/home/testuser1'
    }

    users.create(properties=user1_properties)
    testuser1 = users.get('testuser1')
    # Create 2nd user
    user2_properties = {
        'uid': 'testuser2',
        'cn': 'testuser2',
        'sn': 'user',
        'uidNumber': '1001',
        'gidNumber': '2002',
        'homeDirectory': '/home/testuser2'
    }

    users.create(properties=user2_properties)
    testuser2 = users.get('testuser2')
    # create group
    group_properties = {
        'cn' : 'group1',
        'description' : 'testgroup'
    }

    testuser1_copy = users.get("testuser1")
    group = groups.create(properties=group_properties)

    assert UserAccount.compare(testuser1, testuser2) is False

    with pytest.raises(ValueError):
        UserAccount.compare("test_str_object","test_str_object")

    assert UserAccount.compare(testuser1, testuser1_copy)
    assert UserAccount.compare(testuser1, group) is False