Пример #1
0
    def testDoesNotRemoveSystemLabelFromSingleClient(self):
        with aff4.FACTORY.Open(self.client_ids[0], mode="rw",
                               token=self.token) as grr_client:
            grr_client.AddLabels("foo", owner="GRR")

        result = self.renderer.Render(
            client_plugin.ApiClientsRemoveLabelsRendererArgs(
                client_ids=[self.client_ids[0]], labels=["foo"]),
            token=self.token)
        self.assertEqual(result["status"], "OK")

        labels = aff4.FACTORY.Open(self.client_ids[0],
                                   token=self.token).GetLabels()
        self.assertEqual(len(labels), 1)
Пример #2
0
    def testRemovesUserLabelFromSingleClient(self):
        with aff4.FACTORY.Open(self.client_ids[0], mode="rw",
                               token=self.token) as grr_client:
            grr_client.AddLabels("foo", "bar")

        result = self.renderer.Render(
            client_plugin.ApiClientsRemoveLabelsRendererArgs(
                client_ids=[self.client_ids[0]], labels=["foo"]),
            token=self.token)
        self.assertEqual(result["status"], "OK")

        labels = aff4.FACTORY.Open(self.client_ids[0],
                                   token=self.token).GetLabels()
        self.assertEqual(len(labels), 1)
        self.assertEqual(labels[0].name, "bar")
        self.assertEqual(labels[0].owner, self.token.username)
Пример #3
0
    def testRemovesUserLabelWhenSystemLabelWithSimilarNameAlsoExists(self):
        with aff4.FACTORY.Open(self.client_ids[0], mode="rw",
                               token=self.token) as grr_client:
            grr_client.AddLabels("foo")
            grr_client.AddLabels("foo", owner="GRR")

        result = self.renderer.Render(
            client_plugin.ApiClientsRemoveLabelsRendererArgs(
                client_ids=[self.client_ids[0]], labels=["foo"]),
            token=self.token)
        self.assertEqual(result["status"], "OK")

        labels = aff4.FACTORY.Open(self.client_ids[0],
                                   token=self.token).GetLabels()
        self.assertEqual(len(labels), 1)
        self.assertEqual(labels[0].name, "foo")
        self.assertEqual(labels[0].owner, "GRR")