コード例 #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)