當前位置: 首頁>>代碼示例>>Python>>正文


Python ldapcherry.LdapCherry類代碼示例

本文整理匯總了Python中ldapcherry.LdapCherry的典型用法代碼示例。如果您正苦於以下問題:Python LdapCherry類的具體用法?Python LdapCherry怎麽用?Python LdapCherry使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了LdapCherry類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testSearch

 def testSearch(self):
     app = LdapCherry()
     loadconf('./tests/cfg/ldapcherry_test.ini', app)
     expected = {
         u'ssmith': {
             'password': u'passwordsmith',
             'cn': u'Sheri Smith',
             'name': u'smith',
             'uid': u'ssmith',
             'email': [u'[email protected]',
                       u'[email protected]',
                       u'[email protected]'
                  ],
             },
         u'jsmith': {
             'password': u'passwordsmith',
             'cn': u'John Smith',
             'name': u'Smith',
             'uid': u'jsmith',
             'email': [
                 '[email protected]',
                 '[email protected]',
                 '[email protected]'
                 ],
             }
         }
     ret = app._search('smith')
     assert expected == ret
開發者ID:kakwa,項目名稱:ldapcherry,代碼行數:28,代碼來源:test_LdapCherry.py

示例2: testMissingParameters

 def testMissingParameters(self):
     app = LdapCherry()
     try:
         app.reload({})
     except SystemExit:
         return
     else:
         raise AssertionError("expected an exception")
開發者ID:kakwa,項目名稱:ldapcherry,代碼行數:8,代碼來源:test_LdapCherry.py

示例3: testLog

 def testLog(self):
     app = LdapCherry()
     cfg = { 'global' : {}}
     for t in ['none', 'file', 'syslog', 'stdout']:
         cfg['global']['log.access_handler']=t
         cfg['global']['log.error_handler']=t
         app._set_access_log(cfg, logging.DEBUG)
         app._set_error_log(cfg, logging.DEBUG)
開發者ID:kakwa,項目名稱:ldapcherry,代碼行數:8,代碼來源:test_LdapCherry.py

示例4: testAddUserOneBackend

 def testAddUserOneBackend(self):
     app = LdapCherry()
     loadconf('./tests/cfg/ldapcherry_adldap.cfg', app)
     inv = ldapcherry.backend.backendAD.Backend(adcfg, cherrypy.log, u'test☭', adattr, 'sAMAccountName')
     inv.add_user(addefault_user.copy())
     form = {'groups': {}, 'attrs': {'password1': u'password☭P455', 'password2': u'password☭P455', 'cn': u'Test ☭ Test', 'name': u'Test ☭', 'uidNumber': u'1000', 'gidNumber': u'1000', 'home': u'/home/test', 'first-name': u'Test ☭', 'email': u'[email protected]', 'uid': u'☭default_user'}, 'roles': {'admin-lv3': u'on', 'admin-lv2': u'on', 'users': u'on'}}
     app._adduser(form)
     app._deleteuser(u'☭default_user')
開發者ID:kakwa,項目名稱:ldapcherry,代碼行數:8,代碼來源:test_LdapCherry.py

示例5: testAuth

 def testAuth(self):
     app = LdapCherry()
     loadconf('./tests/cfg/ldapcherry_test.ini', app)
     app.auth_mode = 'and'
     ret1 = app._auth('jsmith', 'passwordsmith')
     app.auth_mode = 'or'
     ret2 = app._auth('jsmith', 'passwordsmith')
     assert ret2 == {'connected': True, 'isadmin': False} and \
         ret1 == {'connected': True, 'isadmin': False}
開發者ID:kakwa,項目名稱:ldapcherry,代碼行數:9,代碼來源:test_LdapCherry.py

示例6: testMissingBackend

 def testMissingBackend(self):
     app = LdapCherry()
     loadconf('./tests/cfg/ldapcherry.ini', app)
     del app.backends_params['ad']
     try:
         app._check_backends()
     except MissingBackend:
         return
     else:
         raise AssertionError("expected an exception")
開發者ID:kakwa,項目名稱:ldapcherry,代碼行數:10,代碼來源:test_LdapCherry.py

示例7: testInitgBackendModuleFail

 def testInitgBackendModuleFail(self):
     app = LdapCherry()
     loadconf('./tests/cfg/ldapcherry.ini', app)
     cfg = {'backends': {'ldap.module': 'ldapcherry.backend'}}
     try:
         app._init_backends(cfg)
     except BackendModuleInitFail:
         return
     else:
         raise AssertionError("expected an exception")
開發者ID:kakwa,項目名稱:ldapcherry,代碼行數:10,代碼來源:test_LdapCherry.py

示例8: testMissingBackendModule

 def testMissingBackendModule(self):
     app = LdapCherry()
     loadconf('./tests/cfg/ldapcherry.ini', app)
     cfg = {'backends': {'ldap.module': 'dontexists'}}
     try:
         app._init_backends(cfg)
     except BackendModuleLoadingFail:
         return
     else:
         raise AssertionError("expected an exception")
開發者ID:kakwa,項目名稱:ldapcherry,代碼行數:10,代碼來源:test_LdapCherry.py

示例9: testLogin

 def testLogin(self):
     app = LdapCherry()
     loadconf('./tests/cfg/ldapcherry_test.ini', app)
     app.auth_mode = 'or'
     try:
         app.login('jwatson', 'passwordwatson')
     except cherrypy.HTTPRedirect as e:
         expected = 'http://127.0.0.1:8080/'
         assert e[0][0] == expected
     else:
         raise AssertionError("expected an exception")
開發者ID:kounoike,項目名稱:ldapcherry,代碼行數:11,代碼來源:test_LdapCherry.py

示例10: testLoginFailure

 def testLoginFailure(self):
     app = LdapCherry()
     loadconf('./tests/cfg/ldapcherry_test.ini', app)
     app.auth_mode = 'or'
     try:
         app.login(u'jwatsoné', u'wrongPasswordé')
     except cherrypy.HTTPRedirect as e:
         expected = 'http://127.0.0.1:8080/signin'
         assert e.urls[0] == expected
     else:
         raise AssertionError("expected an exception")
開發者ID:kakwa,項目名稱:ldapcherry,代碼行數:11,代碼來源:test_LdapCherry.py

示例11: testGetUser

 def testGetUser(self):
     app = LdapCherry()
     loadconf('./tests/cfg/ldapcherry_test.ini', app)
     expected = {
         'password': u'passwordsmith',
         'cn': u'Sheri Smith',
         'uid': u'ssmith',
         'name': u'smith',
         'email': [u'[email protected]',
                  u'[email protected]',
                  u'[email protected]'
             ],
         }
     ret = app._get_user('ssmith')
     assert expected == ret
開發者ID:kakwa,項目名稱:ldapcherry,代碼行數:15,代碼來源:test_LdapCherry.py

示例12: testModifUser

 def testModifUser(self):
     app = LdapCherry()
     loadconf('./tests/cfg/ldapcherry_test.ini', app)
     form = {'groups': {}, 'attrs': {'password1': u'password☭', 'password2': u'password☭', 'cn': u'Test ☭ Test', 'name': u'Test ☭', 'uidNumber': u'1000', 'gidNumber': u'1000', 'home': u'/home/test', 'first-name': u'Test ☭', 'email': u'[email protected]', 'uid': u'test'}, 'roles': {'admin-lv3': u'on', 'admin-lv2': u'on', 'users': u'on'}}
     app._adduser(form)
     modify_form = { 'attrs': {'first-name': u'Test42 ☭', 'uid': u'test'}, 'roles': { 'admin-lv3': u'on'}}
     app._modify(modify_form)
     app._deleteuser('test')
開發者ID:kakwa,項目名稱:ldapcherry,代碼行數:8,代碼來源:test_LdapCherry.py

示例13: testHtml

 def testHtml(self):
     app = LdapCherry()
     loadconf('./tests/cfg/ldapcherry_test.ini', app)
     pages = {
             'signin': app.signin(),
             'index': app.index(),
             'searchuser': app.searchuser('smit'),
             'searchadmin':app.searchadmin('smit'),
             'adduser': app.adduser(),
             'modify':app.modify('jsmith'),
             'selfmodify':app.selfmodify(),
             }
     for page in pages:
         print(page)
         htmlvalidator(pages[page])
開發者ID:kakwa,項目名稱:ldapcherry,代碼行數:15,代碼來源:test_LdapCherry.py

示例14: testModifyUserOneBackend

 def testModifyUserOneBackend(self):
     app = LdapCherry()
     loadconf('./tests/cfg/ldapcherry_adldap.cfg', app)
     inv = ldapcherry.backend.backendAD.Backend(adcfg, cherrypy.log, u'test☭', adattr, 'sAMAccountName')
     try:
         app._deleteuser(u'☭default_user')
     except:
         pass
     inv.add_user(addefault_user.copy())
     modify_form = { 'attrs': {'first-name': u'Test42 ☭', 'uid': u'☭default_user'}, 'roles': { 'admin-lv3': u'on'}}
     app._modify(modify_form)
     app._deleteuser(u'☭default_user')
開發者ID:kakwa,項目名稱:ldapcherry,代碼行數:12,代碼來源:test_LdapCherry.py

示例15: testNaughtyStrings

 def testNaughtyStrings(self):
     app = LdapCherry()
     loadconf('./tests/cfg/ldapcherry_test.ini', app)
     with open('./tests/cfg/blns.json') as data_file:
         data = json.load(data_file)
     for attr in data:
         print('testing: ' + attr)
         # delete whatever is happening...
         try:
             app._deleteuser('test')
         except:
             pass
         form = {'groups': {}, 'attrs': {'password1': u'password☭', 'password2': u'password☭', 'cn': 'Test', 'name': attr, 'uidNumber': u'1000', 'gidNumber': u'1000', 'home': u'/home/test', 'first-name': u'Test ☭', 'email': u'[email protected]', 'uid': 'test'}, 'roles': {'admin-lv3': u'on', 'admin-lv2': u'on', 'users': u'on'}}
         app._adduser(form)
         page = app.searchuser('test'),
         app._deleteuser('test')
         htmlvalidator(page[0])
開發者ID:kakwa,項目名稱:ldapcherry,代碼行數:17,代碼來源:test_LdapCherry.py


注:本文中的ldapcherry.LdapCherry類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。