Esempio n. 1
0
 def test_vendor_info(self):
     """ Test vendor information. """
     info = bonsai.get_vendor_info()
     if len(info) != 2:
         self.fail()
     self.assertIsInstance(info[0], str)
     self.assertIsInstance(info[1], int)
Esempio n. 2
0
 def test_vendor_info(self):
     """ Test vendor information. """
     info = bonsai.get_vendor_info()
     if len(info) != 2:
         self.fail()
     self.assertIsInstance(info[0], str)
     self.assertIsInstance(info[1], int)
Esempio n. 3
0
def test_vendor_info():
    """ Test vendor information. """
    info = bonsai.get_vendor_info()
    assert len(info) == 2
    assert isinstance(info[0], str)
    assert isinstance(info[1], int)
Esempio n. 4
0
    """ Test object class violation error. """
    entry = LDAPEntry("cn=async_test,%s" % basedn)
    entry["cn"] = ["async_test"]
    with pytest.raises(bonsai.errors.ObjectClassViolation):
        with gclient.connect(True) as conn:
            conn.add(entry)


def test_whoami(gclient):
    """ Test whoami. """
    with gclient.connect(True) as conn:
        cfg = get_config()
        obj = conn.whoami()
        expected_res = [
            "dn:%s" % cfg["SIMPLEAUTH"]["user"],
            cfg["SIMPLEAUTH"]["adusername"],
        ]
        assert obj in expected_res


@pytest.mark.skipif(
    get_vendor_info()[1] < 20445 or sys.platform != "linux",
    reason="No async timeout support",
)
@pytest.mark.timeout(18)
def test_connection_timeout(gclient):
    """ Test connection timeout. """
    with network_delay(6.0):
        with pytest.raises(socket.timeout):
            gclient.connect(True, timeout=5.0)
Esempio n. 5
0
    """ Test object class violation error. """
    entry = LDAPEntry("cn=async_test,%s" % basedn)
    entry["cn"] = ["async_test"]
    with pytest.raises(bonsai.errors.ObjectClassViolation):
        with gclient.connect(True) as conn:
            conn.add(entry)


def test_whoami(gclient):
    """ Test whoami. """
    with gclient.connect(True) as conn:
        cfg = get_config()
        obj = conn.whoami()
        expected_res = [
            "dn:%s" % cfg["SIMPLEAUTH"]["user"],
            cfg["SIMPLEAUTH"]["adusername"],
        ]
        assert obj in expected_res


@pytest.mark.skipif(
    get_vendor_info()[1] < 20445 or sys.platform != "linux",
    reason="No async timeout support",
)
@pytest.mark.timeout(18)
def test_connection_timeout(gclient):
    """ Test connection timeout. """
    with network_delay(6.0):
        with pytest.raises(socket.timeout):
            gclient.connect(True, timeout=5.0)