예제 #1
0
    def run_once(self, username, password):
        """Test body."""
        if not username:
          raise error.TestFail('User not set.')
        if not password:
          raise error.TestFail('Password not set.')

        with chrome.Chrome(gaia_login=True,
                           username=username,
                           password=password) as cr:
            if not cryptohome.is_vault_mounted(
                    user=chrome.NormalizeEmail(username)):
                raise error.TestFail('Expected to find a mounted vault for %s'
                                     % username)
            tab = cr.browser.tabs.New()
            # TODO(achuith): Use a better signal of being logged in, instead of
            # parsing accounts.google.com.
            tab.Navigate('http://accounts.google.com')
            tab.WaitForDocumentReadyStateToBeComplete()
            res = tab.EvaluateJavaScript('''
                    var res = '',
                        divs = document.getElementsByTagName('div');
                    for (var i = 0; i < divs.length; i++) {
                        res = divs[i].textContent;
                        if (res.search('%s') > 1) {
                            break;
                        }
                    }
                    res;
            ''' % username)
            if not res:
                raise error.TestFail('No references to %s on accounts page.'
                                     % username)
            tab.Close()
예제 #2
0
    def run_once(self, child_user, child_pass, parent_user, parent_pass):
        """Test function body."""
        if not (child_user and child_pass and parent_user and parent_pass):
            raise error.TestFail('Credentials not set.')

        with chrome.Chrome(auto_login=False) as cr:
            cr.browser.oobe.NavigateUnicornLogin(child_user=child_user,
                                                 child_pass=child_pass,
                                                 parent_user=parent_user,
                                                 parent_pass=parent_pass)
            if not cryptohome.is_vault_mounted(
                    user=chrome.NormalizeEmail(child_user)):
                raise error.TestFail(
                    'Expected to find a mounted vault for %s' % child_user)
            tab = cr.browser.tabs.New()
            # TODO(achuith): Use a better signal of being logged in, instead of
            # parsing accounts.google.com.
            tab.Navigate('http://accounts.google.com')
            tab.WaitForDocumentReadyStateToBeComplete()
            res = tab.EvaluateJavaScript('''
          var res = '',
          divs = document.getElementsByTagName('div');
          for (var i = 0; i < divs.length; i++) {
            res = divs[i].textContent;
            if (res.search('%s') > 1) {
              break;
            }
          }
          res;
      ''' % child_user)
            if not res:
                raise error.TestFail('No references to %s on accounts page.' %
                                     child_user)
            tab.Close()
예제 #3
0
    def run_once(self, username=None, password=None):
        if username is None:
            username = chrome.CAP_USERNAME

        if password is None:
            with tempfile.NamedTemporaryFile() as cap:
                file_utils.download_file(chrome.CAP_URL, cap.name)
                password = cap.read().rstrip()

        if not password:
            raise error.TestFail('Password not set.')

        with chrome.Chrome(gaia_login=True,
                           username=username,
                           password=password) as cr:
            if not cryptohome.is_vault_mounted(
                    user=chrome.NormalizeEmail(username)):
                raise error.TestFail(
                    'Expected to find a mounted vault for %s' % username)
            tab = cr.browser.tabs.New()
            # TODO(achuith): Use a better signal of being logged in, instead of
            # parsing accounts.google.com.
            tab.Navigate('http://accounts.google.com')
            tab.WaitForDocumentReadyStateToBeComplete()
            res = tab.EvaluateJavaScript('''
                    var res = '',
                        divs = document.getElementsByTagName('div');
                    for (var i = 0; i < divs.length; i++) {
                        res = divs[i].textContent;
                        if (res.search('%s') > 1) {
                            break;
                        }
                    }
                    res;
            ''' % username)
            if not res:
                raise error.TestFail('No references to %s on accounts page.' %
                                     username)
            tab.Close()
 def _validate(self):
     # Validate if the environment is expected.
     if not cryptohome.is_vault_mounted(
             user=chrome.NormalizeEmail(self.username)):
         raise error.TestFail('Expected to find a mounted vault for %s' %
                              self.username)
     tab = self.cr.browser.tabs.New()
     tab.Navigate('http://accounts.google.com')
     tab.WaitForDocumentReadyStateToBeComplete()
     res = tab.EvaluateJavaScript('''
             var res = '',
                 divs = document.getElementsByTagName('div');
             for (var i = 0; i < divs.length; i++) {
                 res = divs[i].textContent;
                 if (res.search('%s') > 1) {
                 break;
                 }
             }
             res;
     ''' % self.username)
     if not res:
         raise error.TestFail('No references to %s on accounts page.' %
                              self.username)
     tab.Close()