Esempio n. 1
0
def test_offline_netgroups(add_tripled_netgroup):
    res, _, netgrps = get_sssd_netgroups("tripled_netgroup")
    assert res == NssReturnCode.SUCCESS
    assert netgrps == [("host", "user", "domain")]

    subprocess.check_call(["sss_cache", "-N"])

    simulate_offline()

    res, _, netgrps = get_sssd_netgroups("tripled_netgroup")
    assert res == NssReturnCode.SUCCESS
    assert netgrps == [("host", "user", "domain")]
Esempio n. 2
0
def test_offline_netgroups(add_tripled_netgroup):
    res, _, netgrps = get_sssd_netgroups("tripled_netgroup")
    assert res == NssReturnCode.SUCCESS
    assert netgrps == [("host", "user", "domain")]

    subprocess.check_call(["sss_cache", "-N"])

    simulate_offline()

    res, _, netgrps = get_sssd_netgroups("tripled_netgroup")
    assert res == NssReturnCode.SUCCESS
    assert netgrps == [("host", "user", "domain")]
Esempio n. 3
0
def test_add_tripled_netgroup(add_tripled_netgroup):
    """
    Adding netgroup with triplet.
    """

    res, _, netgrps = sssd_netgroup.get_sssd_netgroups("tripled_netgroup")
    assert res == sssd_netgroup.NssReturnCode.SUCCESS
    assert netgrps == [("host", "user", "domain")]

    res, _, netgrps = sssd_netgroup.get_sssd_netgroups("adv_tripled_netgroup")
    assert res == sssd_netgroup.NssReturnCode.SUCCESS
    assert sorted(netgrps) == sorted([("host1", "user1", "domain1"),
                                      ("host2", "user2", "domain2")])
Esempio n. 4
0
def test_add_tripled_netgroup(add_tripled_netgroup):
    """
    Adding netgroup with triplet.
    """

    res, _, netgrps = sssd_netgroup.get_sssd_netgroups("tripled_netgroup")
    assert res == sssd_netgroup.NssReturnCode.SUCCESS
    assert netgrps == [("host", "user", "domain")]

    res, _, netgrps = sssd_netgroup.get_sssd_netgroups("adv_tripled_netgroup")
    assert res == sssd_netgroup.NssReturnCode.SUCCESS
    assert sorted(netgrps) == sorted([("host1", "user1", "domain1"),
                                      ("host2", "user2", "domain2")])
Esempio n. 5
0
def test_add_empty_netgroup(add_empty_netgroup):
    """
    Adding empty netgroup.
    """

    res, _, netgroups = get_sssd_netgroups("empty_netgroup")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == []
Esempio n. 6
0
def test_add_empty_netgroup(add_empty_netgroup):
    """
    Adding empty netgroup.
    """

    res, _, netgroups = get_sssd_netgroups("empty_netgroup")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == []
Esempio n. 7
0
def test_netgroup_show(ldap_conn, sanity_rfc2307, portable_LC_ALL,
                       add_tripled_netgroup):
    output = get_call_output(["sssctl", "netgroup-show", "tripled_netgroup"])
    assert "Name: tripled_netgroup" not in output

    res, _, netgrps = sssd_netgroup.get_sssd_netgroups("tripled_netgroup")
    assert res == sssd_netgroup.NssReturnCode.SUCCESS
    assert netgrps == [("host", "user", "domain")]

    output = get_call_output(["sssctl", "netgroup-show", "tripled_netgroup"])
    assert "Name: tripled_netgroup" in output
Esempio n. 8
0
def test_add_mixed_netgroup(add_mixed_netgroup):
    """
    Adding many netgroups of different type.
    """

    res, _, netgroups = get_sssd_netgroups("mixed_netgroup1")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == []

    res, _, netgroups = get_sssd_netgroups("mixed_netgroup2")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == []

    res, _, netgroups = get_sssd_netgroups("mixed_netgroup3")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == [("host1", "user1", "domain1")]

    res, _, netgroups = get_sssd_netgroups("mixed_netgroup4")
    assert res == NssReturnCode.SUCCESS
    assert sorted(netgroups) == sorted([("host2", "user2", "domain2"),
                                        ("host3", "user3", "domain3")])

    res, _, netgroups = get_sssd_netgroups("mixed_netgroup5")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == [("host4", "user4", "domain4")]

    res, _, netgroups = get_sssd_netgroups("mixed_netgroup6")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == [("host5", "user5", "domain5")]

    res, _, netgroups = get_sssd_netgroups("mixed_netgroup7")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == [("host1", "user1", "domain1")]

    res, _, netgroups = get_sssd_netgroups("mixed_netgroup8")
    assert res == NssReturnCode.SUCCESS
    assert sorted(netgroups) == sorted([("host1", "user1", "domain1"),
                                        ("host2", "user2", "domain2"),
                                        ("host3", "user3", "domain3")])

    res, _, netgroups = get_sssd_netgroups("mixed_netgroup9")
    assert res == NssReturnCode.SUCCESS
    assert sorted(netgroups) == sorted([("host1", "user1", "domain1"),
                                        ("host2", "user2", "domain2"),
                                        ("host3", "user3", "domain3"),
                                        ("host6", "user6", "domain6")])
Esempio n. 9
0
def test_add_mixed_netgroup(add_mixed_netgroup):
    """
    Adding many netgroups of different type.
    """

    res, _, netgroups = get_sssd_netgroups("mixed_netgroup1")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == []

    res, _, netgroups = get_sssd_netgroups("mixed_netgroup2")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == []

    res, _, netgroups = get_sssd_netgroups("mixed_netgroup3")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == [("host1", "user1", "domain1")]

    res, _, netgroups = get_sssd_netgroups("mixed_netgroup4")
    assert res == NssReturnCode.SUCCESS
    assert sorted(netgroups) == sorted([("host2", "user2", "domain2"),
                                        ("host3", "user3", "domain3")])

    res, _, netgroups = get_sssd_netgroups("mixed_netgroup5")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == [("host4", "user4", "domain4")]

    res, _, netgroups = get_sssd_netgroups("mixed_netgroup6")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == [("host5", "user5", "domain5")]

    res, _, netgroups = get_sssd_netgroups("mixed_netgroup7")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == [("host1", "user1", "domain1")]

    res, _, netgroups = get_sssd_netgroups("mixed_netgroup8")
    assert res == NssReturnCode.SUCCESS
    assert sorted(netgroups) == sorted([("host1", "user1", "domain1"),
                                        ("host2", "user2", "domain2"),
                                        ("host3", "user3", "domain3")])

    res, _, netgroups = get_sssd_netgroups("mixed_netgroup9")
    assert res == NssReturnCode.SUCCESS
    assert sorted(netgroups) == sorted([("host1", "user1", "domain1"),
                                        ("host2", "user2", "domain2"),
                                        ("host3", "user3", "domain3"),
                                        ("host6", "user6", "domain6")])
Esempio n. 10
0
def test_netgroup_show(ldap_conn,
                       sanity_rfc2307,
                       portable_LC_ALL,
                       add_tripled_netgroup):
    output = get_call_output(["sssctl", "netgroup-show", "tripled_netgroup"])
    assert "Name: tripled_netgroup" not in output

    res, _, netgrps = sssd_netgroup.get_sssd_netgroups("tripled_netgroup")
    assert res == sssd_netgroup.NssReturnCode.SUCCESS
    assert netgrps == [("host", "user", "domain")]

    output = get_call_output(["sssctl", "netgroup-show", "tripled_netgroup"])
    assert "Name: tripled_netgroup" in output
Esempio n. 11
0
def test_remove_step_by_step(remove_step_by_step, ldap_conn):
    """
    Removing netgroups step by step.
    """

    ent_list = remove_step_by_step

    res, _, netgroups = get_sssd_netgroups("rm_empty_netgroup1")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == [('host1', 'user1', 'domain1')]

    res, _, netgroups = get_sssd_netgroups("rm_empty_netgroup2")
    assert res == NssReturnCode.SUCCESS
    assert sorted(netgroups) == sorted([('host1', 'user1', 'domain1'),
                                        ('host2', 'user2', 'domain2')])

    # removing of rm_empty_netgroup1
    ldap_conn.delete_s(ent_list[0][0])
    ent_list.remove(ent_list[0])

    if subprocess.call(["sss_cache", "-N"]) != 0:
        raise Exception("sssd_cache failed")

    res, _, netgroups = get_sssd_netgroups("rm_empty_netgroup1")
    assert res == NssReturnCode.NOTFOUND
    assert netgroups == []

    res, _, netgroups = get_sssd_netgroups("rm_empty_netgroup2")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == [('host2', 'user2', 'domain2')]

    # removing of rm_empty_netgroup2
    ldap_conn.delete_s(ent_list[0][0])
    ent_list.remove(ent_list[0])

    if subprocess.call(["sss_cache", "-N"]) != 0:
        raise Exception("sssd_cache failed")

    res, _, netgroups = get_sssd_netgroups("rm_empty_netgroup1")
    assert res == NssReturnCode.NOTFOUND
    assert netgroups == []

    res, _, netgroups = get_sssd_netgroups("rm_empty_netgroup2")
    assert res == NssReturnCode.NOTFOUND
    assert netgroups == []
Esempio n. 12
0
def test_remove_step_by_step(remove_step_by_step, ldap_conn):
    """
    Removing netgroups step by step.
    """

    ent_list = remove_step_by_step

    res, _, netgroups = get_sssd_netgroups("rm_empty_netgroup1")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == [('host1', 'user1', 'domain1')]

    res, _, netgroups = get_sssd_netgroups("rm_empty_netgroup2")
    assert res == NssReturnCode.SUCCESS
    assert sorted(netgroups) == sorted([('host1', 'user1', 'domain1'),
                                        ('host2', 'user2', 'domain2')])

    # removing of rm_empty_netgroup1
    ldap_conn.delete_s(ent_list[0][0])
    ent_list.remove(ent_list[0])

    if subprocess.call(["sss_cache", "-N"]) != 0:
        raise Exception("sssd_cache failed")

    res, _, netgroups = get_sssd_netgroups("rm_empty_netgroup1")
    assert res == NssReturnCode.NOTFOUND
    assert netgroups == []

    res, _, netgroups = get_sssd_netgroups("rm_empty_netgroup2")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == [('host2', 'user2', 'domain2')]

    # removing of rm_empty_netgroup2
    ldap_conn.delete_s(ent_list[0][0])
    ent_list.remove(ent_list[0])

    if subprocess.call(["sss_cache", "-N"]) != 0:
        raise Exception("sssd_cache failed")

    res, _, netgroups = get_sssd_netgroups("rm_empty_netgroup1")
    assert res == NssReturnCode.NOTFOUND
    assert netgroups == []

    res, _, netgroups = get_sssd_netgroups("rm_empty_netgroup2")
    assert res == NssReturnCode.NOTFOUND
    assert netgroups == []
Esempio n. 13
0
def test_removing_nested_netgroups(removing_nested_netgroups, ldap_conn):
    """
    Regression test for ticket 2841.
    https://fedorahosted.org/sssd/ticket/2841
    """

    netgrp_dn = 'cn=t2841_netgroup3,ou=Netgroups,' + ldap_conn.ds_inst.base_dn

    res, _, netgroups = get_sssd_netgroups("t2841_netgroup1")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == [('host1', 'user1', 'domain1')]

    res, _, netgroups = get_sssd_netgroups("t2841_netgroup2")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == [('host2', 'user2', 'domain2')]

    res, _, netgroups = get_sssd_netgroups("t2841_netgroup3")
    assert res == NssReturnCode.SUCCESS
    assert sorted(netgroups) == sorted([('host1', 'user1', 'domain1'),
                                        ('host2', 'user2', 'domain2')])

    # removing of t2841_netgroup1 from t2841_netgroup3
    old = {'memberNisNetgroup': [b"t2841_netgroup1", b"t2841_netgroup2"]}
    new = {'memberNisNetgroup': [b"t2841_netgroup2"]}

    ldif = ldap.modlist.modifyModlist(old, new)
    ldap_conn.modify_s(netgrp_dn, ldif)

    if subprocess.call(["sss_cache", "-N"]) != 0:
        raise Exception("sssd_cache failed")

    res, _, netgroups = get_sssd_netgroups("t2841_netgroup1")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == [('host1', 'user1', 'domain1')]

    res, _, netgroups = get_sssd_netgroups("t2841_netgroup2")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == [('host2', 'user2', 'domain2')]

    res, _, netgroups = get_sssd_netgroups("t2841_netgroup3")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == [('host2', 'user2', 'domain2')]

    # removing of t2841_netgroup2 from t2841_netgroup3
    old = {'memberNisNetgroup': [b"t2841_netgroup2"]}
    new = {'memberNisNetgroup': []}

    ldif = ldap.modlist.modifyModlist(old, new)
    ldap_conn.modify_s(netgrp_dn, ldif)

    if subprocess.call(["sss_cache", "-N"]) != 0:
        raise Exception("sssd_cache failed")

    res, _, netgroups = get_sssd_netgroups("t2841_netgroup1")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == [('host1', 'user1', 'domain1')]

    res, _, netgroups = get_sssd_netgroups("t2841_netgroup2")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == [('host2', 'user2', 'domain2')]

    res, _, netgroups = get_sssd_netgroups("t2841_netgroup3")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == []
Esempio n. 14
0
def test_removing_nested_netgroups(removing_nested_netgroups, ldap_conn):
    """
    Regression test for ticket 2841.
    https://fedorahosted.org/sssd/ticket/2841
    """

    netgrp_dn = 'cn=t2841_netgroup3,ou=Netgroups,' + ldap_conn.ds_inst.base_dn

    res, _, netgroups = get_sssd_netgroups("t2841_netgroup1")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == [('host1', 'user1', 'domain1')]

    res, _, netgroups = get_sssd_netgroups("t2841_netgroup2")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == [('host2', 'user2', 'domain2')]

    res, _, netgroups = get_sssd_netgroups("t2841_netgroup3")
    assert res == NssReturnCode.SUCCESS
    assert sorted(netgroups) == sorted([('host1', 'user1', 'domain1'),
                                        ('host2', 'user2', 'domain2')])

    # removing of t2841_netgroup1 from t2841_netgroup3
    old = {'memberNisNetgroup': [b"t2841_netgroup1", b"t2841_netgroup2"]}
    new = {'memberNisNetgroup': [b"t2841_netgroup2"]}

    ldif = ldap.modlist.modifyModlist(old, new)
    ldap_conn.modify_s(netgrp_dn, ldif)

    if subprocess.call(["sss_cache", "-N"]) != 0:
        raise Exception("sssd_cache failed")

    res, _, netgroups = get_sssd_netgroups("t2841_netgroup1")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == [('host1', 'user1', 'domain1')]

    res, _, netgroups = get_sssd_netgroups("t2841_netgroup2")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == [('host2', 'user2', 'domain2')]

    res, _, netgroups = get_sssd_netgroups("t2841_netgroup3")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == [('host2', 'user2', 'domain2')]

    # removing of t2841_netgroup2 from t2841_netgroup3
    old = {'memberNisNetgroup': [b"t2841_netgroup2"]}
    new = {'memberNisNetgroup': []}

    ldif = ldap.modlist.modifyModlist(old, new)
    ldap_conn.modify_s(netgrp_dn, ldif)

    if subprocess.call(["sss_cache", "-N"]) != 0:
        raise Exception("sssd_cache failed")

    res, _, netgroups = get_sssd_netgroups("t2841_netgroup1")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == [('host1', 'user1', 'domain1')]

    res, _, netgroups = get_sssd_netgroups("t2841_netgroup2")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == [('host2', 'user2', 'domain2')]

    res, _, netgroups = get_sssd_netgroups("t2841_netgroup3")
    assert res == NssReturnCode.SUCCESS
    assert netgroups == []