Пример #1
0
    def Run(self):
        # Fix the time to avoid regressions.
        with test_lib.FakeTime(42):
            client_id = self.SetupClients(1)[0]
            with aff4.FACTORY.Open(client_id, mode="rw",
                                   token=self.token) as grr_client:
                grr_client.Set(grr_client.Schema.MEMORY_SIZE(4294967296))
                # Delete the certificate as it's being regenerated every time the
                # client is created.
                grr_client.DeleteAttribute(grr_client.Schema.CERT)

        with test_lib.FakeTime(45):
            with aff4.FACTORY.Open(client_id, mode="rw",
                                   token=self.token) as grr_client:
                grr_client.Set(
                    grr_client.Schema.HOSTNAME("some-other-hostname.org"))

        with test_lib.FakeTime(47):
            for mode in ["FULL", "DIFF"]:
                self.Check("GetClientVersions",
                           args=client_plugin.ApiGetClientVersionsArgs(
                               client_id=client_id.Basename(), mode=mode))
                self.Check(
                    "GetClientVersions",
                    args=client_plugin.ApiGetClientVersionsArgs(
                        client_id=client_id.Basename(),
                        end=rdfvalue.RDFDatetime().FromSecondsFromEpoch(44),
                        mode=mode))
                self.Check(
                    "GetClientVersions",
                    args=client_plugin.ApiGetClientVersionsArgs(
                        client_id=client_id.Basename(),
                        start=rdfvalue.RDFDatetime().FromSecondsFromEpoch(44),
                        end=rdfvalue.RDFDatetime().FromSecondsFromEpoch(46),
                        mode=mode))
Пример #2
0
    def Run(self):
        client_id = self._SetupTestClient()

        with test_lib.FakeTime(47):
            self.Check("GetClientVersions",
                       args=client_plugin.ApiGetClientVersionsArgs(
                           client_id=client_id, mode=self.mode))
            self.Check("GetClientVersions",
                       args=client_plugin.ApiGetClientVersionsArgs(
                           client_id=client_id,
                           end=rdfvalue.RDFDatetime().FromSecondsFromEpoch(44),
                           mode=self.mode))
            self.Check(
                "GetClientVersions",
                args=client_plugin.ApiGetClientVersionsArgs(
                    client_id=client_id,
                    start=rdfvalue.RDFDatetime().FromSecondsFromEpoch(44),
                    end=rdfvalue.RDFDatetime().FromSecondsFromEpoch(46),
                    mode=self.mode))