From 4a55d040f9a64f5632d73606d2d50f4060f2f9a1 Mon Sep 17 00:00:00 2001 From: kakwa Date: Fri, 3 Jul 2015 20:26:02 +0200 Subject: [PATCH] adding unit test for ppolicy --- tests/cfg/ldapcherry.ini | 10 ++++++++++ tests/test_LdapCherry.py | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/tests/cfg/ldapcherry.ini b/tests/cfg/ldapcherry.ini index b04dbd7..0be7a75 100644 --- a/tests/cfg/ldapcherry.ini +++ b/tests/cfg/ldapcherry.ini @@ -99,6 +99,16 @@ auth.mode = 'or' # custom auth module to load #auth.module = 'ldapcherry.auth.modNone' +[ppolicy] + +# password policy module +ppolicy.module = 'ldapcherry.ppolicy.simple' + +# parameters of the module +min_length = 8 +min_upper = 1 +min_digit = 1 + # resources parameters [resources] # templates directory diff --git a/tests/test_LdapCherry.py b/tests/test_LdapCherry.py index 67d18df..5249b9c 100644 --- a/tests/test_LdapCherry.py +++ b/tests/test_LdapCherry.py @@ -87,6 +87,13 @@ class TestError(object): app._set_access_log(cfg, logging.DEBUG) app._set_error_log(cfg, logging.DEBUG) + def testPPolicy(self): + app = LdapCherry() + loadconf('./tests/cfg/ldapcherry.ini', app) + wrong = app._checkppolicy('password')['match'] + good = app._checkppolicy('Passw0rd.')['match'] + assert wrong == False and good == True + def testMissingBackend(self): app = LdapCherry() loadconf('./tests/cfg/ldapcherry.ini', app)