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)
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)
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
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()
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)
def test_no_refresh_token(self): with _AuthReferenceServer(): creds = DevshellCredentials() self.assertEquals(None, creds.refresh_token)
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)
def test_serialization_data(self): with _AuthReferenceServer('[]'): credentials = DevshellCredentials() self.assertRaises(NotImplementedError, getattr, credentials, 'serialization_data')
def test_refuses_to_save_to_well_known_file(self): with _AuthReferenceServer(): creds = DevshellCredentials() self.assertRaises(NotImplementedError, save_to_well_known_file, creds)