def test_cannot_specify_both_filename_and_store(self): ignore, filename = tempfile.mkstemp() store = KeyringCredentialStore() self.assertRaises( ValueError, NoNetworkLaunchpad.login_with, application_name='not important', credentials_file=filename, credential_store=store) os.remove(filename)
def credential_store_factory(cls, credential_save_failed): if cls._is_sudo(): # Do not try to store credentials under sudo; # it can be problematic with shared sudo access, # and we may not have access to the normal keyring provider # LP: #1862948 return MemoryCredentialStore(credential_save_failed) return KeyringCredentialStore(credential_save_failed, fallback=True)
def test_inconsistent_credential_save_failed(self): # Catch an attempt to specify inconsistent callbacks for # credential save failure. def callback1(): pass store = KeyringCredentialStore(credential_save_failed=callback1) def callback2(): pass self.assertRaises(ValueError, NoNetworkLaunchpad.login_with, "app name", credential_store=store, credential_save_failed=callback2)
def setUp(self): self.keyring = InMemoryKeyring() self.store = KeyringCredentialStore()
def credential_store_factory(cls, credential_save_failed): return KeyringCredentialStore(credential_save_failed)