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')))
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')
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()
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