예제 #1
0
    def test_get_backend(self):
        with patch(settings,
                   A_PRESENT_BACKEND_SETTING='django_digest.tests.DummyBackendClass',
                   AN_ABSENT_BACKEND_SETTING=NotImplemented):
            self.assertEqual(
                DummyBackendClass,
                type(get_backend('A_PRESENT_BACKEND_SETTING',
                                 'django_digest.tests.OtherDummyBackendClass')))

            self.assertEqual(
                OtherDummyBackendClass,
                type(get_backend('AN_ABSENT_BACKEND_SETTING',
                                 'django_digest.tests.OtherDummyBackendClass')))
예제 #2
0
    def test_get_backend(self):
        with patch(settings,
                   A_PRESENT_BACKEND_SETTING='django_digest.tests.DummyBackendClass',
                   AN_ABSENT_BACKEND_SETTING=NotImplemented):
            self.assertEqual(
                DummyBackendClass,
                type(get_backend('A_PRESENT_BACKEND_SETTING',
                                 'django_digest.tests.OtherDummyBackendClass')))

            self.assertEqual(
                OtherDummyBackendClass,
                type(get_backend('AN_ABSENT_BACKEND_SETTING',
                                 'django_digest.tests.OtherDummyBackendClass')))
예제 #3
0
파일: __init__.py 프로젝트: dimagi/carehq
 def __init__(self,
              account_storage=None,
              nonce_storage=None,
              realm=None,
              timeout=None,
              enforce_nonce_count=None):
     if not enforce_nonce_count == None:
         self._enforce_nonce_count = enforce_nonce_count
     else:
         self._enforce_nonce_count = get_setting('DIGEST_ENFORCE_NONCE_COUNT', True)
     self.realm = realm or get_setting('DIGEST_REALM', DEFAULT_REALM)
     self.timeout = timeout or get_setting('DIGEST_NONCE_TIMEOUT_IN_SECONDS', 5*60)
     self._account_storage = (account_storage or get_backend(
             'DIGEST_ACCOUNT_BACKEND', 'django_digest.backend.db.AccountStorage'))
     self._nonce_storage = (nonce_storage or get_backend(
             'DIGEST_NONCE_BACKEND', 'django_digest.backend.db.NonceStorage'))
     self.secret_key = get_setting('SECRET_KEY')
예제 #4
0
def _get_logins(user, method_name):
    login_factory = get_backend('DIGEST_LOGIN_FACTORY',
                                'django_digest.DefaultLoginFactory')
    method = getattr(login_factory, method_name, None)
    if method:
        return set(method(user))
    else:
        return set()
예제 #5
0
def _get_logins(user, method_name):
    login_factory = get_backend('DIGEST_LOGIN_FACTORY',
                                'django_digest.DefaultLoginFactory')
    method = getattr(login_factory, method_name, None)
    if method:
        return set(method(user))
    else:
        return set()
예제 #6
0
 def __init__(self,
              account_storage=None,
              nonce_storage=None,
              realm=None,
              timeout=None,
              enforce_nonce_count=None,
              failure_callback=None):
     if not enforce_nonce_count == None:
         self._enforce_nonce_count = enforce_nonce_count
     else:
         self._enforce_nonce_count = get_setting('DIGEST_ENFORCE_NONCE_COUNT', True)
     self.realm = realm or get_setting('DIGEST_REALM', DEFAULT_REALM)
     self.timeout = timeout or get_setting('DIGEST_NONCE_TIMEOUT_IN_SECONDS', 5*60)
     self._account_storage = (account_storage or get_backend(
             'DIGEST_ACCOUNT_BACKEND', 'django_digest.backend.storage.AccountStorage'))
     self._nonce_storage = (nonce_storage or get_backend(
             'DIGEST_NONCE_BACKEND', 'django_digest.backend.storage.NonceStorage'))
     self.secret_key = get_setting('SECRET_KEY')
     self.failure_callback = failure_callback