Example #1
0
 def test_get_login_backend(self):
     # test that we get the real one
     self.assertEqual(type(get_login_backend(None, None, None)),
                      LoginBackendDbusSSO)
     # test that we get the fake one
     os.environ["SOFTWARE_CENTER_FAKE_REVIEW_API"] = "1"
     self.assertEqual(type(get_login_backend(None, None, None)),
                      LoginBackendDbusSSOFake)
     # clean the environment
     del os.environ["SOFTWARE_CENTER_FAKE_REVIEW_API"]
Example #2
0
 def test_get_login_backend(self):
     # test that we get the real one
     self.assertEqual(type(get_login_backend(None, None, None)),
                      LoginBackendDbusSSO)
     # test that we get the fake one
     os.environ["SOFTWARE_CENTER_FAKE_REVIEW_API"] = "1"
     self.assertEqual(type(get_login_backend(None, None, None)),
                      LoginBackendDbusSSOFake)
     # clean the environment
     del os.environ["SOFTWARE_CENTER_FAKE_REVIEW_API"]
Example #3
0
 def _get_login_backend_and_connect(self):
     sso = get_login_backend(self.xid, SOFTWARE_CENTER_NAME_KEYRING,
                             _(SOFTWARE_CENTER_SSO_DESCRIPTION))
     sso.connect("login-successful", self._login_successful)
     sso.connect("login-failed", lambda s: self.loop.quit())
     sso.connect("login-canceled", lambda s: self.loop.quit())
     return sso
Example #4
0
 def _get_login_backend_and_connect(self):
     sso = get_login_backend(
         self.xid,
         SOFTWARE_CENTER_NAME_KEYRING,
         _(SOFTWARE_CENTER_SSO_DESCRIPTION))
     sso.connect("login-successful", self._login_successful)
     sso.connect("login-failed", lambda s: self.loop.quit())
     sso.connect("login-canceled", lambda s: self.loop.quit())
     return sso
Example #5
0
 def _try_login(self):
     '''Try to get the credential or login on ubuntu sso'''
     logging.debug("OneConf login()")
     help_text = _("With multiple Ubuntu computers, you can publish "
                   "their inventories online to compare the software "
                   "installed on each\nNo-one else will be able to see "
                   "what you have installed.")
     self.sso = get_login_backend(
         0, SOFTWARE_CENTER_NAME_KEYRING, help_text)
     self.sso.connect("login-successful", self._maybe_login_successful)
     self.sso.connect("login-canceled", self._login_canceled)
     self.sso.login_or_register()
Example #6
0
 def _try_login(self):
     '''Try to get the credential or login on ubuntu sso'''
     logging.debug("OneConf login()")
     help_text = _("With multiple Ubuntu computers, you can publish "
                   "their inventories online to compare the software "
                   "installed on each\nNo-one else will be able to see "
                   "what you have installed.")
     self.sso = get_login_backend(0, SOFTWARE_CENTER_NAME_KEYRING,
                                  help_text)
     self.sso.connect("login-successful", self._maybe_login_successful)
     self.sso.connect("login-canceled", self._login_canceled)
     self.sso.login_or_register()
Example #7
0
 def _try_sso_login(self):
     # display the SSO login dialog if needed
     # FIXME: consider improving the text in the SSO dialog, for now
     #        we simply reuse the opt-in text from the panel since we
     #        are well past string freeze
     self.spinner_notebook.show_spinner()
     self.sso = get_login_backend(get_parent_xid(self),
                                SOFTWARE_CENTER_NAME_KEYRING,
                                self.RECOMMENDATIONS_OPT_IN_TEXT)
     self.sso.connect("login-successful", self._maybe_login_successful)
     self.sso.connect("login-failed", self._login_failed)
     self.sso.connect("login-canceled", self._login_canceled)
     self.sso.login_or_register()
 def _try_sso_login(self):
     # display the SSO login dialog if needed
     # FIXME: consider improving the text in the SSO dialog, for now
     #        we simply reuse the opt-in text from the panel since we
     #        are well past string freeze
     self.spinner_notebook.show_spinner()
     self.sso = get_login_backend(get_parent_xid(self),
                                SOFTWARE_CENTER_NAME_KEYRING,
                                self.RECOMMENDATIONS_OPT_IN_TEXT)
     self.sso.connect("login-successful", self._maybe_login_successful)
     self.sso.connect("login-failed", self._login_failed)
     self.sso.connect("login-canceled", self._login_canceled)
     self.sso.login_or_register()
Example #9
0
    sys.stdout.flush()
    password = sys.stdin.readline().strip()
    sso.login(user, password)


# interactive test code
if __name__ == "__main__":
    def _whoami(sso, result):
        print "res: ", result
        Gtk.main_quit()

    def _error(sso, result):
        print "err: ", result
        Gtk.main_quit()

    def _dbus_maybe_login_successful(ssologin, oauth_result):
        print "got token, verify it now"
        sso = UbuntuSSO()
        sso.connect("whoami", _whoami)
        sso.connect("error", _error)
        sso.whoami()

    from gi.repository import Gtk
    logging.basicConfig(level=logging.DEBUG)
    softwarecenter.paths.datadir = "./data"

    backend = get_login_backend("", "appname", "help_text")
    backend.connect("login-successful", _dbus_maybe_login_successful)
    backend.login_or_register()
    Gtk.main()
Example #10
0
    password = sys.stdin.readline().strip()
    sso.login(user, password)


# interactive test code
if __name__ == "__main__":

    def _whoami(sso, result):
        print "res: ", result
        Gtk.main_quit()

    def _error(sso, result):
        print "err: ", result
        Gtk.main_quit()

    def _dbus_maybe_login_successful(ssologin, oauth_result):
        print "got token, verify it now"
        sso = UbuntuSSO()
        sso.connect("whoami", _whoami)
        sso.connect("error", _error)
        sso.whoami()

    from gi.repository import Gtk
    logging.basicConfig(level=logging.DEBUG)
    softwarecenter.paths.datadir = "./data"

    backend = get_login_backend("", "appname", "help_text")
    backend.connect("login-successful", _dbus_maybe_login_successful)
    backend.login_or_register()
    Gtk.main()