示例#1
0
 def testDumpADCRequiredQuotaProject_NotUserAccount(self):
     self.StartPatch('oauth2client.crypt.Signer', autospec=True)
     creds.ADC(self.MakeServiceAccountCredentials()).DumpADCToFile()
     with self.AssertRaisesExceptionMatches(
             c_exc.BadFileException,
             'The application default credentials are not user credentials'
     ):
         auth_util.AddQuotaProjectToADC(self.fake_project)
示例#2
0
 def testDumpADCRequiredQuotaProject_WithoutPermission(self):
     self.adc_permission_checking.return_value = False
     auth_util.WriteGcloudCredentialsToADC(
         creds.FromJson(self.USER_CREDENTIALS_JSON))
     with self.AssertRaisesExceptionMatches(
             auth_util.MissingPermissionOnQuotaProjectError,
             'Cannot add the project "{}" to application default credentials'
             .format(self.fake_project)):
         auth_util.AddQuotaProjectToADC(self.fake_project)
     self.adc_permission_checking.assert_called()
示例#3
0
 def testDumpADCRequiredQuotaProject_WithPermission(self):
     self.adc_permission_checking.return_value = True
     auth_util.WriteGcloudCredentialsToADC(
         creds.FromJson(self.USER_CREDENTIALS_JSON))
     auth_util.AddQuotaProjectToADC(self.fake_project)
     auth_util.AssertADCExists()
     self.AssertQuotaProjectEquals(self.fake_project)
     self.AssertErrContains('Credentials saved to file')
     self.AssertErrContains('Quota project "{}" was added to ADC'.format(
         self.fake_project))
     self.adc_permission_checking.assert_called()
示例#4
0
 def Run(self, args):
     return auth_util.AddQuotaProjectToADC(args.quota_project_id)
示例#5
0
 def testDumpADCRequiredQuotaProject_NoADC(self):
     with self.AssertRaisesExceptionMatches(
             c_exc.BadFileException,
             'Application default credentials have not been set up'):
         auth_util.AddQuotaProjectToADC(self.fake_project)
 def testDumpADCRequiredQuotaProject_NotUserAccount(self):
   creds.ADC(self.MakeServiceAccountCredentials()).DumpADCToFile()
   with self.AssertRaisesExceptionMatches(
       c_exc.BadFileException,
       'The application default credentials are not user credentials'):
     auth_util.AddQuotaProjectToADC(self.fake_project)