当前位置: 首页>>代码示例>>Python>>正文


Python users.User方法代码示例

本文整理汇总了Python中google.appengine.api.users.User方法的典型用法代码示例。如果您正苦于以下问题:Python users.User方法的具体用法?Python users.User怎么用?Python users.User使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在google.appengine.api.users的用法示例。


在下文中一共展示了users.User方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: from google.appengine.api import users [as 别名]
# 或者: from google.appengine.api.users import User [as 别名]
def setUp(self):
    super(LoanerEndpointsTest, self).setUp()
    self.service = FakeApiPermissionChecks()
    self.request = message_types.VoidMessage()

    user_model.Role.create(
        'technical_admin',
        role_permissions=[permissions.Permissions.AUDIT_SHELF],
        associated_group=loanertest.TECHNICAL_ADMIN_EMAIL)

    user_model.User(
        id=loanertest.SUPER_ADMIN_EMAIL, superadmin=True).put()
    user_model.User(
        id=loanertest.TECHNICAL_ADMIN_EMAIL,
        roles=[ndb.Key(user_model.Role, 'technical_admin')]).put()
    user_model.User(id=loanertest.USER_EMAIL).put() 
开发者ID:google,项目名称:loaner,代码行数:18,代码来源:auth_test.py

示例2: call_test_as

# 需要导入模块: from google.appengine.api import users [as 别名]
# 或者: from google.appengine.api.users import User [as 别名]
def call_test_as(self, api_name, user):
    """Makes a call FakeApiPermissionChecks APIs with different users.

    Args:
      api_name: str, the name of the test API to call.
      user: users.User obj, the App Engine API users object being checked.

    Returns:
      True if permission or user auth passed the call to the API.
    """
    with mock.patch.object(
        xsrf, 'validate_request') as mock_validate_request:
      mock_validate_request.return_value = True
      with mock.patch.object(users, 'get_current_user') as mock_user:
        mock_user.return_value = user
        api_method = getattr(self.service, api_name)
        if api_method(self.request) == message_types.VoidMessage():
          return True 
开发者ID:google,项目名称:loaner,代码行数:20,代码来源:auth_test.py

示例3: test_loaner_endpoints_auth_method__api_for_any_authenticated_user

# 需要导入模块: from google.appengine.api import users [as 别名]
# 或者: from google.appengine.api.users import User [as 别名]
def test_loaner_endpoints_auth_method__api_for_any_authenticated_user(
      self, mock_config):
    # Test api_with_permission with a user.
    user = users.User(email=loanertest.USER_EMAIL)
    self.assertTrue(self.call_test_as('api_for_any_authenticated_user', user))

    # Test api_for_any_authenticated_user with permission.
    user = users.User(email=loanertest.TECHNICAL_ADMIN_EMAIL)
    self.assertTrue(self.call_test_as('api_for_any_authenticated_user', user))

    # Test api_for_any_authenticated_user with the superadmin.
    user = users.User(email=loanertest.SUPER_ADMIN_EMAIL)
    self.assertTrue(self.call_test_as('api_for_any_authenticated_user', user))

    # Test invalid domain.
    user = users.User(email='userl@fakedomain.com')
    with self.assertRaises(endpoints.UnauthorizedException):
      self.call_test_as('api_for_any_authenticated_user', user) 
开发者ID:google,项目名称:loaner,代码行数:20,代码来源:auth_test.py

示例4: VerifyIdToken

# 需要导入模块: from google.appengine.api import users [as 别名]
# 或者: from google.appengine.api.users import User [as 别名]
def VerifyIdToken(self, cls, *args):
    with mock.patch.object(users_id_token, 'time') as mock_time,\
          mock.patch.object(users_id_token, '_get_id_token_user') as mock_get:
      mock_time.time.return_value = 1001
      mock_get.return_value = users.User('test@gmail.com')
      os.environ['HTTP_AUTHORIZATION'] = ('Bearer ' + self._SAMPLE_TOKEN)
      if args:
        cls.method(*args)
      else:
        users_id_token._maybe_set_current_user_vars(cls.method)
      mock_time.time.assert_called_once_with()
      mock_get.assert_called_once_with(
        self._SAMPLE_TOKEN,
        users_id_token._DEFAULT_GOOGLE_ISSUER,
        self._SAMPLE_AUDIENCES,
        (constants.API_EXPLORER_CLIENT_ID,) + self._SAMPLE_ALLOWED_CLIENT_IDS,
        1001,
        memcache,
      ) 
开发者ID:cloudendpoints,项目名称:endpoints-python,代码行数:21,代码来源:users_id_token_test.py

示例5: __init__

# 需要导入模块: from google.appengine.api import users [as 别名]
# 或者: from google.appengine.api.users import User [as 别名]
def __init__(self, model, key_name, property_name, cache=None, user=None):
    """Constructor for Storage.

    Args:
      model: db.Model or ndb.Model, model class
      key_name: string, key name for the entity that has the credentials
      property_name: string, name of the property that is a CredentialsProperty
        or CredentialsNDBProperty.
      cache: memcache, a write-through cache to put in front of the datastore.
        If the model you are using is an NDB model, using a cache will be
        redundant since the model uses an instance cache and memcache for you.
      user: users.User object, optional. Can be used to grab user ID as a
        key_name if no key name is specified.
    """
    if key_name is None:
      if user is None:
        raise ValueError('StorageByKeyName called with no key name or user.')
      key_name = user.user_id()

    self._model = model
    self._key_name = key_name
    self._property_name = property_name
    self._cache = cache 
开发者ID:mortcanty,项目名称:earthengine,代码行数:25,代码来源:appengine.py

示例6: _build_state_value

# 需要导入模块: from google.appengine.api import users [as 别名]
# 或者: from google.appengine.api.users import User [as 别名]
def _build_state_value(request_handler, user):
  """Composes the value for the 'state' parameter.

  Packs the current request URI and an XSRF token into an opaque string that
  can be passed to the authentication server via the 'state' parameter.

  Args:
    request_handler: webapp.RequestHandler, The request.
    user: google.appengine.api.users.User, The current user.

  Returns:
    The state value as a string.
  """
  uri = request_handler.request.url
  token = xsrfutil.generate_token(xsrf_secret_key(), user.user_id(),
                                  action_id=str(uri))
  return  uri + ':' + token 
开发者ID:mortcanty,项目名称:earthengine,代码行数:19,代码来源:appengine.py

示例7: _parse_state_value

# 需要导入模块: from google.appengine.api import users [as 别名]
# 或者: from google.appengine.api.users import User [as 别名]
def _parse_state_value(state, user):
  """Parse the value of the 'state' parameter.

  Parses the value and validates the XSRF token in the state parameter.

  Args:
    state: string, The value of the state parameter.
    user: google.appengine.api.users.User, The current user.

  Raises:
    InvalidXsrfTokenError: if the XSRF token is invalid.

  Returns:
    The redirect URI.
  """
  uri, token = state.rsplit(':', 1)
  if not xsrfutil.validate_token(xsrf_secret_key(), token, user.user_id(),
                                 action_id=uri):
    raise InvalidXsrfTokenError()

  return uri 
开发者ID:mortcanty,项目名称:earthengine,代码行数:23,代码来源:appengine.py

示例8: _build_state_value

# 需要导入模块: from google.appengine.api import users [as 别名]
# 或者: from google.appengine.api.users import User [as 别名]
def _build_state_value(request_handler, user):
    """Composes the value for the 'state' parameter.

    Packs the current request URI and an XSRF token into an opaque string that
    can be passed to the authentication server via the 'state' parameter.

    Args:
        request_handler: webapp.RequestHandler, The request.
        user: google.appengine.api.users.User, The current user.

    Returns:
        The state value as a string.
    """
    uri = request_handler.request.url
    token = xsrfutil.generate_token(xsrf_secret_key(), user.user_id(),
                                    action_id=str(uri))
    return uri + ':' + token 
开发者ID:Deltares,项目名称:aqua-monitor,代码行数:19,代码来源:appengine.py

示例9: _parse_state_value

# 需要导入模块: from google.appengine.api import users [as 别名]
# 或者: from google.appengine.api.users import User [as 别名]
def _parse_state_value(state, user):
    """Parse the value of the 'state' parameter.

    Parses the value and validates the XSRF token in the state parameter.

    Args:
        state: string, The value of the state parameter.
        user: google.appengine.api.users.User, The current user.

    Raises:
        InvalidXsrfTokenError: if the XSRF token is invalid.

    Returns:
        The redirect URI.
    """
    uri, token = state.rsplit(':', 1)
    if not xsrfutil.validate_token(xsrf_secret_key(), token, user.user_id(),
                                   action_id=uri):
        raise InvalidXsrfTokenError()

    return uri 
开发者ID:Deltares,项目名称:aqua-monitor,代码行数:23,代码来源:appengine.py

示例10: _parse_state_value

# 需要导入模块: from google.appengine.api import users [as 别名]
# 或者: from google.appengine.api.users import User [as 别名]
def _parse_state_value(state, user):
    """Parse the value of the 'state' parameter.

    Parses the value and validates the XSRF token in the state parameter.

    Args:
        state: string, The value of the state parameter.
        user: google.appengine.api.users.User, The current user.

    Returns:
        The redirect URI, or None if XSRF token is not valid.
    """
    uri, token = state.rsplit(':', 1)
    if xsrfutil.validate_token(xsrf_secret_key(), token, user.user_id(),
                               action_id=uri):
        return uri
    else:
        return None 
开发者ID:fniephaus,项目名称:alfred-gmail,代码行数:20,代码来源:appengine.py


注:本文中的google.appengine.api.users.User方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。