示例#1
0
 def test_handles_skipped_fields(self):
     with _AuthReferenceServer('["*****@*****.**"]'):
         creds = DevshellCredentials()
         self.assertEqual('*****@*****.**', creds.user_email)
         self.assertEqual(None, creds.project_id)
         self.assertEqual(None, creds.access_token)
         self.assertEqual(None, creds.token_expiry)
示例#2
0
 def test_handles_ignores_extra_fields(self):
     with _AuthReferenceServer(
             '["*****@*****.**", "fooproj", "sometoken", "extra"]'):
         creds = DevshellCredentials()
         self.assertEqual('*****@*****.**', creds.user_email)
         self.assertEqual('fooproj', creds.project_id)
         self.assertEqual('sometoken', creds.access_token)
示例#3
0
 def test_refuses_to_save_to_well_known_file(self):
   ORIGINAL_ISDIR = os.path.isdir
   try:
     os.path.isdir = lambda path: True
     with _AuthReferenceServer():
       creds = DevshellCredentials()
       self.assertRaises(NotImplementedError, save_to_well_known_file, creds)
   finally:
     os.path.isdir = ORIGINAL_ISDIR
示例#4
0
 def test_reads_credentials(self, utcnow):
     NOW = datetime.datetime(1992, 12, 31)
     utcnow.return_value = NOW
     with _AuthReferenceServer():
         creds = DevshellCredentials()
         self.assertEqual('*****@*****.**', creds.user_email)
         self.assertEqual('fooproj', creds.project_id)
         self.assertEqual('sometoken', creds.access_token)
         self.assertEqual(
             NOW + datetime.timedelta(seconds=EXPIRES_IN),
             creds.token_expiry)
         utcnow.assert_called_once_with()
示例#5
0
 def test_reads_credentials(self):
     with _AuthReferenceServer():
         creds = DevshellCredentials()
         self.assertEqual('*****@*****.**', creds.user_email)
         self.assertEqual('fooproj', creds.project_id)
         self.assertEqual('sometoken', creds.access_token)
示例#6
0
 def test_no_refresh_token(self):
     with _AuthReferenceServer():
         creds = DevshellCredentials()
         self.assertEquals(None, creds.refresh_token)
示例#7
0
 def test_handles_tiny_response(self):
     with _AuthReferenceServer('[]'):
         creds = DevshellCredentials()
         self.assertEqual(None, creds.user_email)
         self.assertEqual(None, creds.project_id)
         self.assertEqual(None, creds.access_token)
示例#8
0
 def test_serialization_data(self):
     with _AuthReferenceServer('[]'):
         credentials = DevshellCredentials()
         self.assertRaises(NotImplementedError, getattr,
                           credentials, 'serialization_data')
示例#9
0
 def test_refuses_to_save_to_well_known_file(self):
   with _AuthReferenceServer():
     creds = DevshellCredentials()
     self.assertRaises(NotImplementedError, save_to_well_known_file, creds)