示例#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))
示例#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())
示例#3
0
 def test_gce_service_account(self):
   self.mock_all(
       '*****@*****.**',
       '123456789123.project.googleusercontent.com')
   self.assertEqual(
       self.user('*****@*****.**'),
       api.extract_oauth_caller_identity())
示例#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()
示例#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())
示例#6
0
 def test_internal_service_account(self):
     self.mock_all('*****@*****.**', 'anonymous')
     self.assertEqual(self.user('*****@*****.**'),
                      api.extract_oauth_caller_identity())
示例#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()
示例#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())
示例#9
0
 def test_gae_service_account(self):
   self.mock_all('*****@*****.**', 'anonymous')
   self.assertEqual(
       self.user('*****@*****.**'),
       api.extract_oauth_caller_identity())
示例#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()
示例#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())