Exemple #1
0
 def test_unrecognized_service_account(self):
     self.mock_all('*****@*****.**', 'anonymous')
     with self.assertRaises(api.AuthorizationError) as e:
         api.extract_oauth_caller_identity()
     self.assertEqual(
         'Unrecognized combination of email ([email protected]) '
         'and client_id (anonymous). Is client_id whitelisted? Is it '
         'unrecognized service account?', str(e.exception))
Exemple #2
0
 def test_private_key_service_account(self):
   self.mock_all(
       '*****@*****.**',
       '111111111111-abcdefghq20gfl1.apps.googleusercontent.com')
   self.assertEqual(
       self.user('*****@*****.**'),
       api.extract_oauth_caller_identity())
Exemple #3
0
 def test_gce_service_account(self):
   self.mock_all(
       '*****@*****.**',
       '123456789123.project.googleusercontent.com')
   self.assertEqual(
       self.user('*****@*****.**'),
       api.extract_oauth_caller_identity())
Exemple #4
0
 def test_is_allowed_oauth_client_id_not_ok_empty(self):
     self.mock_all('*****@*****.**', 'some-client-id')
     with self.assertRaises(api.AuthorizationError):
         api.extract_oauth_caller_identity()
Exemple #5
0
 def test_is_allowed_oauth_client_id_ok(self):
     self.mock_all('*****@*****.**', 'some-client-id', ['some-client-id'])
     self.assertEqual(self.user('*****@*****.**'),
                      api.extract_oauth_caller_identity())
Exemple #6
0
 def test_internal_service_account(self):
     self.mock_all('*****@*****.**', 'anonymous')
     self.assertEqual(self.user('*****@*****.**'),
                      api.extract_oauth_caller_identity())
Exemple #7
0
 def test_is_allowed_oauth_client_id_not_ok_empty(self):
     self.mock_all("*****@*****.**", "some-client-id")
     with self.assertRaises(api.AuthorizationError):
         api.extract_oauth_caller_identity()
Exemple #8
0
 def test_is_allowed_oauth_client_id_ok(self):
     self.mock_all("*****@*****.**", "some-client-id", ["some-client-id"])
     self.assertEqual(self.user("*****@*****.**"), api.extract_oauth_caller_identity())
Exemple #9
0
 def test_gae_service_account(self):
   self.mock_all('*****@*****.**', 'anonymous')
   self.assertEqual(
       self.user('*****@*****.**'),
       api.extract_oauth_caller_identity())
Exemple #10
0
 def test_is_allowed_oauth_client_id_not_ok(self):
   self.mock_all('*****@*****.**', 'some-client-id', ['another-client-id'])
   with self.assertRaises(api.AuthorizationError):
     api.extract_oauth_caller_identity()
Exemple #11
0
 def test_is_allowed_oauth_client_id_ok(self):
   self.mock_all('*****@*****.**', 'some-client-id', ['some-client-id'])
   self.assertEqual(
       self.user('*****@*****.**'), api.extract_oauth_caller_identity())