Пример #1
0
    def GetGrrUser(self, args, token=None):
        # Everybody can get their own user object.

        interface_traits = api_user.ApiGrrUserInterfaceTraits(
            search_clients_action_enabled=True)
        return api_user.ApiGetOwnGrrUserHandler(
            interface_traits=interface_traits)
Пример #2
0
    def testGetGrrUserReturnsRestrictedTraitsForNonAdminUser(self):
        error = access_control.UnauthorizedAccess("some error")
        self.access_checker_mock.CheckIfUserIsAdmin.side_effect = error
        handler = self.router.GetGrrUser(None, token=self.token)

        self.assertNotEqual(handler.interface_traits,
                            api_user.ApiGrrUserInterfaceTraits().EnableAll())
Пример #3
0
  def testRendersTraitsPassedInConstructor(self):
    result = self.handler.Handle(None,
                                 token=access_control.ACLToken(username="******"))
    self.assertFalse(result.interface_traits.create_hunt_action_enabled)

    handler = user_plugin.ApiGetGrrUserHandler(
        interface_traits=user_plugin.ApiGrrUserInterfaceTraits(
            create_hunt_action_enabled=True))
    result = handler.Handle(None, token=access_control.ACLToken(username="******"))
    self.assertTrue(result.interface_traits.create_hunt_action_enabled)
Пример #4
0
    def GetGrrUser(self, args, token=None):
        # Everybody can get their own user settings.

        interface_traits = api_user.ApiGrrUserInterfaceTraits().EnableAll()
        try:
            self.CheckIfUserIsAdmin(token=token)
        except access_control.UnauthorizedAccess:
            interface_traits.manage_binaries_nav_item_enabled = False

        return api_user.ApiGetGrrUserHandler(interface_traits=interface_traits)
Пример #5
0
 def testRaisesIfTraitsSetInRequest(self):
   user = user_plugin.ApiGrrUser(
       interface_traits=user_plugin.ApiGrrUserInterfaceTraits())
   with self.assertRaises(ValueError):
     self.handler.Handle(user, token=access_control.ACLToken(username="******"))
 def GetGrrUser(self, args, token=None):
     return api_user.ApiGetOwnGrrUserHandler(
         interface_traits=api_user.ApiGrrUserInterfaceTraits().EnableAll())
    def testGetGrrUserReturnsRestrictedTraitsForNonAdminUser(self):
        handler = self.router.GetGrrUser(None, token=self.token)

        self.assertNotEqual(handler.interface_traits,
                            api_user.ApiGrrUserInterfaceTraits().EnableAll())
    def testGetGrrUserReturnsFullTraitsForAdminUser(self):
        self.CreateAdminUser(self.token.username)
        handler = self.router.GetGrrUser(None, token=self.token)

        self.assertEqual(handler.interface_traits,
                         api_user.ApiGrrUserInterfaceTraits().EnableAll())