예제 #1
0
def _ValidateOauthUser():
    """Validates the oauth user and raises an exception if not authorized.
  Returns:
    A tuple (user_email, is_admin).
    user_email (str): The email address of the oauth user.
    is_admin (bool): True if the oauth user is an Admin.

  Raises:
    endpoints.UnauthorizedException if the user has no permission.
  """
    try:
        return acl.ValidateOauthUserForNewAnalysis()
    except exceptions.UnauthorizedException as e:
        raise endpoints.UnauthorizedException('Unauthorized: %s' % e.message)
예제 #2
0
 def testValidateOauthUserForAuthorizedUser(self, *_):
     user_email, is_admin = acl.ValidateOauthUserForNewAnalysis()
     self.assertEqual('email', user_email)
     self.assertTrue(is_admin)
예제 #3
0
 def testValidateOauthUserForUnauthorizedServiceAccount(self, *_):
     with self.assertRaises(exceptions.UnauthorizedException):
         acl.ValidateOauthUserForNewAnalysis()
예제 #4
0
 def testValidateOauthUserForUnauthorizedClientId(self, *_):
     with self.assertRaises(exceptions.UnauthorizedException):
         acl.ValidateOauthUserForNewAnalysis()
예제 #5
0
 def testValidateOauthUserForAuthorizedServiceAccount(self, *_):
     user_email, is_admin = acl.ValidateOauthUserForNewAnalysis()
     self.assertEqual('*****@*****.**', user_email)
     self.assertFalse(is_admin)