'Check PING and CLOCK are updated, simulate bad client clock.'

def testClientPingAndClockIsUpdated(self):

    new_client = self.MakeClientAFF4Record()
    now = rdfvalue.RDFDatetime.Now()
    client_now = (now - 20)
    with test_lib.FakeTime(now):
        self.ClientServerCommunicate(timestamp=client_now)
        client_obj = aff4.FACTORY.Open(new_client.urn, token=self.token)
        self.assertEqual(now.AsSecondsFromEpoch(), client_obj.Get(client_obj.Schema.PING).AsSecondsFromEpoch())
        self.assertEqual(client_now.AsSecondsFromEpoch(), client_obj.Get(client_obj.Schema.CLOCK).AsSecondsFromEpoch())
    now += 60
    client_now += 40
    with test_lib.FakeTime(now):
        self.ClientServerCommunicate(timestamp=client_now)
        client_obj = aff4.FACTORY.Open(new_client.urn, token=self.token)
        self.assertEqual(now.AsSecondsFromEpoch(), client_obj.Get(client_obj.Schema.PING).AsSecondsFromEpoch())
        self.assertEqual(client_now.AsSecondsFromEpoch(), client_obj.Get(client_obj.Schema.CLOCK).AsSecondsFromEpoch())
