def testApprovalExpiry(self):
    """Tests that approvals expire after the correct time."""

    client_id = "C.%016X" % 0
    urn = rdf_client.ClientURN(client_id).Add("/fs/os/c")
    token = access_control.ACLToken(username="test", reason="For testing")
    self.assertRaises(access_control.UnauthorizedAccess, aff4.FACTORY.Open, urn,
                      None, "rw", token)

    with test_lib.FakeTime(100.0, increment=1e-3):
      self.RequestAndGrantClientApproval(client_id, token)

      # This should work now.
      aff4.FACTORY.Open(urn, mode="rw", token=token)

    token_expiry = config_lib.CONFIG["ACL.token_expiry"]

    # This is close to expiry but should still work.
    with test_lib.FakeTime(100.0 + token_expiry - 100.0):
      aff4.FACTORY.Open(urn, mode="rw", token=token)

    # Past expiry, should fail.
    with test_lib.FakeTime(100.0 + token_expiry + 100.0):
      self.assertRaises(access_control.UnauthorizedAccess,
                        aff4.FACTORY.Open, urn, None, "rw", token)
dataset/ETHPy150Open google/grr/grr/lib/aff4_objects/user_managers_test.py/FullAccessControlManagerIntegrationTest.testApprovalExpiry/original