Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added unbind_s, search_ext and result3 support; changed rename_s to work how python-ldap does #22

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
143 changes: 135 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,136 @@
.coverage
cover
dist
build
fakeldap.egg-info
*.pyc
.tox
*.swp
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
reports
results.xml

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

# Development artifacts
.python-version
.DS_Store
/*.sql
config.codekit3
sql/docker/mysql-data

# Vim
*.sw*
*.bak
tags

# Terraform
.terraform
tags
supervisord.pid
requirements.txt.new

# Ignore the config.codekit3 file -- it changes constantly
config.codekit3

# Ignore Visual Studio Code and PyCharm workspace and config
*.code-workspace
.idea
.vscode

# Local temp files
local_storage

27 changes: 17 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ taken from Peter Sagerson's excellent django-auth-ldap_ module.
Installation
============

Get and install the code::
To install from PyPI::

$ git clone git://github.com/30loops/fakeldap.git
$ pip install fakeldap

To install via ``setup.py``::

$ git clone git://github.com/zulip/fakeldap.git
$ cd fakeldap
$ python setup.py install

Expand All @@ -34,14 +38,14 @@ Usage

This code is still experimental and not very tested as of yet. So is the
documentation

The ``MockLDAP`` class replaces the ``LDAPObject`` of the python-ldap module.
The easiest way to use it, is to overwrite ``ldap.initialize`` to return
``MockLDAP`` instead of ``LDAPObject``. The example below uses Michael Foord's
``MockLDAP`` instead of ``LDAPObject``. The example below uses Python 3's
Mock_ library to achieve that::

import unittest
from mock import patch
from unittest.mock import patch
from fakeldap import MockLDAP


Expand All @@ -60,13 +64,16 @@ Mock_ library to achieve that::

The mock ldap object implements the following ldap operations:

- simple_bind_s
- search_s
- add_s
- compare_s
- modify_s
- delete_s
- add_s
- modify_s
- rename_s
- result3
- search_ext
- search_s
- simple_bind_s
- unbind_s

This is an example how to use ``MockLDAP`` with fixed return values::

Expand Down Expand Up @@ -121,7 +128,7 @@ ldap server with a directory of entries::
"userPassword": "ldaptest"
}
}
mock_ldap = MockLDAP(tree)
mock_ldap = MockLDAP(tree)

record = [
('uid', 'crito'),
Expand Down
Loading