{ "info": { "author": "Adrian Gruntkowski", "author_email": "adrian.gruntkowski@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "python-ldap-test\n================\n\nTool for testing code speaking with LDAP server. Allows to easily\nconfigure and run an embedded, in-memory LDAP server. Uses UnboundID\nLDAP SDK through Py4J. Requires Java runtime on the system path to run\nthe server.\n\nInstallation\n------------\n\nWith ``pip``:\n\n::\n\n pip install python-ldap-test\n\nWhen installing from source:\n\n::\n\n git clone https://github.com/zoldar/python-ldap-test\n cd python-ldap-test\n python setup.py install # you may need root privileges if installing system-wide\n\nUsage\n-----\n\nExample library usage with Python ldap client.\n\n::\n\n import ldap3\n\n from ldap_test import LdapServer\n\n server = LdapServer()\n\n try:\n server.start()\n\n dn = server.config['bind_dn']\n pw = server.config['password']\n\n srv = ldap3.Server('localhost', port=server.config['port'])\n conn = ldap3.Connection(srv, user=dn, password=pw, auto_bind=True)\n\n base_dn = server.config['base']['dn']\n search_filter = '(objectclass=domain)'\n attrs = ['dc']\n\n conn.search(base_dn, search_filter, attributes=attrs)\n\n print conn.response\n # [{\n # 'dn': 'dc=example,dc=com',\n # 'raw_attributes': {'dc': [b'example']},\n # 'attributes': {'dc': ['example']},\n # 'type': 'searchResEntry'\n # }]\n finally:\n server.stop()\n\nAnother example with non-standard settings:\n\n::\n\n import ldap3\n\n from ldap_test import LdapServer\n\n server = LdapServer({\n 'port': 3333,\n 'bind_dn': 'cn=admin,dc=zoldar,dc=net',\n 'password': 'pass1',\n 'base': {'objectclass': ['domain'],\n 'dn': 'dc=zoldar,dc=net',\n 'attributes': {'dc': 'zoldar'}},\n 'entries': [\n {'objectclass': 'domain',\n 'dn': 'dc=users,dc=zoldar,dc=net',\n 'attributes': {'dc': 'users'}},\n {'objectclass': 'organization',\n 'dn': 'o=foocompany,dc=users,dc=zoldar,dc=net',\n 'attributes': {'o': 'foocompany'}},\n ]\n })\n\n try:\n server.start()\n\n dn = \"cn=admin,dc=zoldar,dc=net\"\n pw = \"pass1\"\n\n srv = ldap3.Server('localhost', port=3333)\n conn = ldap3.Connection(srv, user=dn, password=pw, auto_bind=True)\n\n base_dn = 'dc=zoldar,dc=net'\n search_filter = '(objectclass=organization)'\n attrs = ['o']\n\n conn.search(base_dn, search_filter, attributes=attrs)\n\n print conn.response\n # [{\n # 'dn': 'o=foocompany,dc=users,dc=zoldar,dc=net',\n # 'raw_attributes': {'o': [b'foocompany']},\n # 'attributes': {'o': ['foocompany']},\n # 'type': 'searchResEntry'\n # }]\n finally:\n server.stop()\n\nAnd, finally, an example of running multiple LDAP servers:\n\n::\n\n import ldap3\n\n from ldap_test import LdapServer\n\n servers = {}\n\n try:\n for sid in (1, 2):\n domain = 'example{0}'.format(sid)\n servers[sid] = LdapServer({\n 'port': 10389 + (sid * 1000),\n 'bind_dn': 'cn=admin,dc={0},dc=com'.format(domain),\n 'base': {\n 'objectclass': ['domain'],\n 'dn': 'dc={0},dc=com'.format(domain),\n 'attributes': {'dc': domain}\n },\n })\n servers[sid].start()\n\n search_filter = '(objectclass=domain)'\n attrs = ['dc']\n\n # server1\n dn = servers[1].config['bind_dn']\n pw = servers[1].config['password']\n base_dn = servers[1].config['base']['dn']\n port = servers[1].config['port']\n\n srv = ldap3.Server('localhost', port=port)\n conn = ldap3.Connection(srv, user=dn, password=pw, auto_bind=True)\n conn.search(base_dn, search_filter, attributes=attrs)\n\n print conn.response\n # [{\n # 'dn': 'dc=example1,dc=com',\n # 'raw_attributes': {'dc': [b'example1']},\n # 'attributes': {'dc': ['example1']},\n # 'type': 'searchResEntry'\n # }]\n\n conn.unbind()\n\n # server2\n dn = servers[2].config['bind_dn']\n pw = servers[2].config['password']\n base_dn = servers[2].config['base']['dn']\n port = servers[2].config['port']\n\n srv = ldap3.Server('localhost', port=port)\n conn = ldap3.Connection(srv, user=dn, password=pw, auto_bind=True)\n conn.search(base_dn, search_filter, attributes=attrs)\n\n print conn.response\n # [{\n # 'dn': 'dc=example2,dc=com',\n # 'raw_attributes': {'dc': [b'example2']},\n # 'attributes': {'dc': ['example2']},\n # 'type': 'searchResEntry'\n # }]\n\n conn.unbind()\n finally:\n for server in servers.values():\n server.stop()\n\nThe initial server configuration is represented by a simple dict, which\nmay contain one or more optional parameters:\n\n- ``port`` - a port on which the LDAP server will listen\n- ``bind_dn`` - bind DN entry for authentication\n- ``password`` - authentication password\n- ``base`` - base DN entry\n- ``entries`` - a list of dicts representing intially loaded entries in\n the database. ``attributes`` are optional here\n- ``ldifs`` - a list of strings representing file paths to the LDIF\n files to load on start, like\n ``..., 'ldifs': ['path/to/file1.ldif', 'path/to/file2.ldif'], ...``\n\nThe format of entry in ``entries`` as well as ``base`` is following:\n\n::\n\n {'dn': 'o=some,dc=example,dc=com', # DN identifying the entry\n 'objectclass': ['top', 'organization'], # objectclass may be either a \n # string in case of a single \n # class or a list of classes\n 'attributes': { # attributes are optional\n 'o': 'some' # every attribute may have either a single value\n # or multiple values in a list like\n # 'ou': ['Value1', 'Value2', ...]\n }\n }\n\nMacOS\n-----\n\nFor some reason, while running on MacOS, you can experience problems if\nthe JVM doesn't start quickly enough for the py4j gateway to connect,\nand it goes into an infinite hang.\n\nIf you're experiencing this problem, you can set an interval between the\nJVM startup and the py4j gateway by passing 'java\\_delay=n' to\nLdapServer() where 'n' is the number of seconds to wait. Typically a\nwait of even 1 second is enough for java to spin up and be ready for the\ngateway.\n\nTo be clear, the following:\n\n::\n\n server = LdapServer(config={...}, java_delay=1)\n\nwill cause a 1 second delay between starting the JVM and creating the\npy4j gateway, and all should be well.\n\nIn tests, a delay of even 0.5 seconds can be enough, though 0.1 seconds\nis not. The exact cause of this problem is unknown. More information on\nthis 'feature' while running on a Mac is welcome.\n\nRunning Java gateway and proxy on non-standard ports\n----------------------------------------------------\n\nWhen there's a necessity to run proxy and gateway on ports different\nfrom the default ones (25333 for Java gateway and 25334 for proxy), the\n``LdapServer`` may be instantiated with custom ones, passed explicitly\nto the constructor:\n\n::\n\n server = LdapServer({...}, java_gateway_port=26333, python_proxy_port=26334)\n\nThis can be useful when several test runs are done in parallel on a\nsingle system.\n\nReporting issues\n----------------\n\nAny issues (be it bugs, feature requests or anything else) can be\nreported through project's `GitHub issues\npage `__.\n\nContributors\n------------\n\n- John Kristensen (https://github.com/jerrykan)\n- Kevin Rasmussen (https://github.com/krasmussen)\n- Pedro Algarvio (https://github.com/s0undt3ch)\n- Nik Ogura (https://github.com/nikogura)\n\nLicense\n-------\n\nCopyright \u00a9 2016 Adrian Gruntkowski\n\nDistributed under the MIT License.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/zoldar/python-ldap-test/", "keywords": "testing,tests,test,ldap", "license": "LICENSE.txt", "maintainer": null, "maintainer_email": null, "name": "python-ldap-test", "package_url": "https://pypi.org/project/python-ldap-test/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/python-ldap-test/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/zoldar/python-ldap-test/" }, "release_url": "https://pypi.org/project/python-ldap-test/0.3.1/", "requires_dist": null, "requires_python": null, "summary": "Tool for testing code speaking with LDAP server. Allows to easily configure and run an embedded, in-memory LDAP server. Uses UnboundID LDAP SDK through Py4J.", "version": "0.3.1" }, "last_serial": 2921725, "releases": { "0.0.7": [ { "comment_text": "", "digests": { "md5": "b5dff9ad1209c19ff8e37878d0aef12c", "sha256": "9cc4db0eacde957a9e77c42e3254ce29e4e627299f3773a47c9ef3791757ceb0" }, "downloads": -1, "filename": "python-ldap-test-0.0.7.tar.gz", "has_sig": false, "md5_digest": "b5dff9ad1209c19ff8e37878d0aef12c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1481891, "upload_time": "2013-07-05T12:28:42", "url": "https://files.pythonhosted.org/packages/75/98/a0bd90d80dfc8450a7a321db4c35a0106576048588528741005d0f5c75c2/python-ldap-test-0.0.7.tar.gz" } ], "0.0.8": [ { "comment_text": "", "digests": { "md5": "a1f02efaec9898872a3406e9fb80bead", "sha256": "3059cb7a52817fd0a6643c7ed19c9f94d817858fc892070159ad9e1afe6c1099" }, "downloads": -1, "filename": "python-ldap-test-0.0.8.tar.gz", "has_sig": false, "md5_digest": "a1f02efaec9898872a3406e9fb80bead", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1483951, "upload_time": "2013-09-20T12:45:53", "url": "https://files.pythonhosted.org/packages/31/61/133eca3fd623fb66b43d0083ca023d9c6ec95bcba6c0473f69fc2d364e63/python-ldap-test-0.0.8.tar.gz" } ], "0.0.9": [ { "comment_text": "", "digests": { "md5": "4f6c5cb611b4f2d1ba922f5873ecb499", "sha256": "878cfc5cdfe7beaf2c31696cb66d051f5539f0834e0e106ab78f53323430b5c6" }, "downloads": -1, "filename": "python-ldap-test-0.0.9.tar.gz", "has_sig": false, "md5_digest": "4f6c5cb611b4f2d1ba922f5873ecb499", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1483623, "upload_time": "2014-09-19T12:49:21", "url": "https://files.pythonhosted.org/packages/85/22/0a2afb0d380e1c8ac08cd1e6be4ae6b8fc1964849d53b0072dbb65685f1f/python-ldap-test-0.0.9.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "5e6e5d420023ae21fde92c6e698b5d1c", "sha256": "b6eaf27dcbb8125b7f7987525cc154b7a9ce8f273cb9f2b35b9657d4b01159f2" }, "downloads": -1, "filename": "python-ldap-test-0.1.0.tar.gz", "has_sig": false, "md5_digest": "5e6e5d420023ae21fde92c6e698b5d1c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1484107, "upload_time": "2014-09-19T12:51:44", "url": "https://files.pythonhosted.org/packages/74/03/630ae44006bf264726a7b565a54dd7251f83a1b2028a4911e27b76e5590c/python-ldap-test-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "bd492a3d4c957d3eacee601761e7d558", "sha256": "aac5eedea155ce6f2addda3962c846825d06bb2c73b328da2211d89324681f79" }, "downloads": -1, "filename": "python-ldap-test-0.1.1.tar.gz", "has_sig": false, "md5_digest": "bd492a3d4c957d3eacee601761e7d558", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1484360, "upload_time": "2014-09-19T13:51:11", "url": "https://files.pythonhosted.org/packages/68/04/d7167942a1e11848723719b5bfab15375d6b0dcc3999863018770dd456ec/python-ldap-test-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "1ede4fcc6a3360584fc143ddcc4f7412", "sha256": "eed9e26ff509628eb34306e826ecc64252bf525e2cfe593f883c922fd2832ddc" }, "downloads": -1, "filename": "python-ldap-test-0.2.0.tar.gz", "has_sig": false, "md5_digest": "1ede4fcc6a3360584fc143ddcc4f7412", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1487729, "upload_time": "2014-09-23T20:22:10", "url": "https://files.pythonhosted.org/packages/1d/58/61d56c7735b640d7fe9b499e3f8b3e38907c5e94a3a3429dbb11297f2169/python-ldap-test-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "50945d4f560bf83a92ce0e176fbfee6a", "sha256": "ad5c3af7e3eb3fec64d2895c573b270437f2746c401df3770375aa478fd724a6" }, "downloads": -1, "filename": "python-ldap-test-0.2.1.tar.gz", "has_sig": false, "md5_digest": "50945d4f560bf83a92ce0e176fbfee6a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1487386, "upload_time": "2016-05-31T21:40:08", "url": "https://files.pythonhosted.org/packages/29/91/cfaf787229eced4a84eed16d29fb740cd1006f4859341ba79314878b20b4/python-ldap-test-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "d1536f1994091c0e429e2c1a5bbbae83", "sha256": "8728132bf96a8033f0f8ee61e9c61f9b16f32455e39eb8c93bb3b399718aaa14" }, "downloads": -1, "filename": "python-ldap-test-0.2.2.tar.gz", "has_sig": false, "md5_digest": "d1536f1994091c0e429e2c1a5bbbae83", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1487511, "upload_time": "2016-07-27T21:40:49", "url": "https://files.pythonhosted.org/packages/da/84/c4ac0830496ea54e2d30ccd0f827dfd615572a8fbb440d2d784d9aa6abf1/python-ldap-test-0.2.2.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "e92fb34f1de89d53ecabe4f701231408", "sha256": "a8e6b691d351f54c3f2e5bd78caccd6c370844d85c16f68b769934e2eb724c6e" }, "downloads": -1, "filename": "python-ldap-test-0.3.0.tar.gz", "has_sig": false, "md5_digest": "e92fb34f1de89d53ecabe4f701231408", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1535207, "upload_time": "2016-09-11T00:36:39", "url": "https://files.pythonhosted.org/packages/d7/00/12275d254b014abcf9ff3cb3a753f65ee85dcef34b0190f6a90df5451cef/python-ldap-test-0.3.0.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "cf34624422487c6684aa7e09a518830b", "sha256": "8e676ff33f7a755c56bf262f85feba484316bd5af83e970eb78d2a66e9e809e2" }, "downloads": -1, "filename": "python-ldap-test-0.3.1.tar.gz", "has_sig": false, "md5_digest": "cf34624422487c6684aa7e09a518830b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1533647, "upload_time": "2017-06-02T23:40:50", "url": "https://files.pythonhosted.org/packages/29/2e/1ff9000907fd1379bca985cc76d254b453cb53c817ef8197983fe3fdedfb/python-ldap-test-0.3.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "cf34624422487c6684aa7e09a518830b", "sha256": "8e676ff33f7a755c56bf262f85feba484316bd5af83e970eb78d2a66e9e809e2" }, "downloads": -1, "filename": "python-ldap-test-0.3.1.tar.gz", "has_sig": false, "md5_digest": "cf34624422487c6684aa7e09a518830b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1533647, "upload_time": "2017-06-02T23:40:50", "url": "https://files.pythonhosted.org/packages/29/2e/1ff9000907fd1379bca985cc76d254b453cb53c817ef8197983fe3fdedfb/python-ldap-test-0.3.1.tar.gz" } ] }