def testGetForAccountException(self):
     self.StartObjectPatch(
         store,
         'Load',
         side_effect=google_auth_exceptions.GoogleAuthError())
     with self.assertRaises(refresh_token.LoadingCredentialsError):
         refresh_token.GetForAccount('my-account')
Beispiel #2
0
    def testActivateAndRetrieve(self):
        self.StartObjectPatch(store, 'Refresh', autospec=True)

        refresh_token.ActivateCredentials('my-account', 'my-refresh-token')
        self.assertEqual('my-account', properties.VALUES.core.account.Get())

        self.assertEqual('my-refresh-token',
                         refresh_token.GetForAccount('my-account'))
Beispiel #3
0
  def testActivate(self):
    self.StartObjectPatch(store, 'Refresh', autospec=True)
    account = '*****@*****.**'
    token = 'asdf'

    self.Run(
        'auth activate-refresh-token {account} {token}'.format(
            account=account, token=token))

    self.assertEqual(token, refresh_token.GetForAccount(account))
    self.assertEqual('*****@*****.**', properties.VALUES.core.account.Get())
    self.assertEqual('junkproj', properties.VALUES.core.project.Get())
    self.AssertOutputEquals('')
    self.AssertErrEquals(
        'Activated refresh token credentials: [[email protected]]\n')
Beispiel #4
0
  def testActivateStdin(self):
    self.StartObjectPatch(store, 'Refresh', autospec=True)
    account = '*****@*****.**'
    token = 'asdf'

    self.WriteInput(token)
    self.Run(
        '--project=myproj auth activate-refresh-token {account}'.format(
            account=account))

    self.assertEqual(token, refresh_token.GetForAccount(account))
    self.assertEqual('*****@*****.**', properties.VALUES.core.account.Get())
    self.assertEqual('myproj', properties.VALUES.core.project.Get())
    self.AssertOutputEquals('')
    self.AssertErrEquals(
        '{"ux": "PROMPT_RESPONSE", "message": "Refresh token: "}'
        'Activated refresh token credentials: [[email protected]]\n')
    def Run(self, args):
        """Run the helper command."""

        return {'refresh_token': refresh_token.GetForAccount(args.account)}