예제 #1
0
파일: abutil.py 프로젝트: msisov/chromium68
def main(argv):
    parser = GetParser()
    opts = parser.parse_args(argv)
    opts.Freeze()
    creds = androidbuild.LoadCredentials(opts.json_key_file)
    ab_client = androidbuild.GetApiClient(creds)
    return opts.func(ab_client, opts)
예제 #2
0
    def testLoadCredentials_ServiceAccount(self):
        """Checks that loading a service account from JSON works."""
        creds = androidbuild.LoadCredentials(
            os.path.join(TESTDATA_PATH, 'androidbuild',
                         'test_creds_service_account.json'))

        # In this method, for service accounts, we need to check inside private
        # attributes, so pylint: disable=protected-access

        # Check that this was indeed recognized as a service account.
        self.assertIsInstance(
            creds, oauth2client.service_account._ServiceAccountCredentials)

        # Check identification of this service account.
        self.assertEqual(
            creds._service_account_id,
            '78539106351-7rmgdpp1v64a3dpqqqpoi2qeir3tse0k'
            '.apps.googleusercontent.com')
        self.assertEqual(
            creds._service_account_email,
            '78539106351-7rmgdpp1v64a3dpqqqpoi2qeir3tse0k'
            '@developer.gserviceaccount.com')

        # Check that the test private key matches the one we expected to see.
        self.assertEqual(creds._private_key_id,
                         'c3f27df17b54445bf56fab801323563537405f35')

        # Check that the scope has been set correctly.
        self.assertEqual(
            creds._scopes,
            'https://www.googleapis.com/auth/androidbuild.internal')
예제 #3
0
def OpenBuildApiProxy(json_key_file):
    """Open an Android Internal Build API Apiary proxy.

  Will NOT error out if authentication fails until the first real request is
  made.

  Args:
    json_key_file: A Json key file to authenticate with. Retrieved from the
                   Google Developer Console associated with the account to
                   be used for the requests.

  Returns:
    Proxy object used to make requests against the API.
  """
    # Load the private key associated with the Google service account.
    creds = androidbuild.LoadCredentials(json_credentials_path=json_key_file)
    return androidbuild.GetApiClient(creds)
예제 #4
0
    def testLoadCredentials_AuthorizedUser(self):
        """Checks that loading authorized user credentials works."""
        creds = androidbuild.LoadCredentials(
            os.path.join(TESTDATA_PATH, 'androidbuild',
                         'test_creds_authorized_user.json'))

        # Check that this was indeed recognized as a service account.
        self.assertIsInstance(creds, oauth2client.client.GoogleCredentials)

        # Check identification of the client.
        self.assertEqual(
            creds.client_id, '78539106351-iijlq710v1ia1g6dadm3bcvb1vmiotq5'
            '.apps.googleusercontent.com')

        # Check that the client secret matches the one we expected to see.
        self.assertEqual(creds.client_secret, 'W40GFz7qWi8RdtTh5dx7J_zv')

        # Authorized user credentials are scopeless.
        self.assertFalse(creds.create_scoped_required())