コード例 #1
0
    def Get(self) -> "GrrUser":
        """Fetches user's data and returns it wrapped in a Grruser object."""

        args = user_management_pb2.ApiGetGrrUserArgs(username=self.username)
        data = self._context.SendRequest("GetGrrUser", args)
        if not isinstance(data, user_pb2.ApiGrrUser):
            raise TypeError(f"Unexpected response type: '{type(data)}'")

        return GrrUser(data=data, context=self._context)
コード例 #2
0
  def testCorrectlyCallsAmbiguouslyNamedMethod(self):
    acl_test_lib.CreateUser(self.token.username)

    # Here arguments are provided, so root router is correctly chosen.
    args = user_management_pb2.ApiGetGrrUserArgs(username="******")
    with self.assertRaises(errors.ResourceNotFoundError):
      self.connector.SendRequest("GetGrrUser", args)

    # Here no arguments are provided, so non-root router is correctly chosen.
    result = self.connector.SendRequest("GetGrrUser", None)
    self.assertEqual(result.username, self.token.username)
コード例 #3
0
ファイル: root.py プロジェクト: syth3/grr
    def Get(self):
        """Fetches user's data and returns it wrapped in a Grruser object."""

        args = user_management_pb2.ApiGetGrrUserArgs(username=self.username)
        data = self._context.SendRequest("GetGrrUser", args)
        return GrrUser(data=data, context=self._context)