Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
OortComet oortComet21 = oort2.findComet(oort1.getURL());
Assert.assertTrue(oortComet21.waitFor(5000, BayeuxClient.State.CONNECTED));
// Test that a valid remote client can connect
Message.Mutable authFields = new HashMapMessage();
authFields.getExt(true).put(TestSecurityPolicy.TOKEN_FIELD, "something");
BayeuxClient client1 = startClient(oort1, authFields);
Assert.assertTrue(client1.waitFor(5000, BayeuxClient.State.CONNECTED));
// Wait for long poll to be established
Thread.sleep(1000);
Assert.assertTrue(client1.disconnect(5000));
// An invalid client may not connect
BayeuxClient client2 = startClient(oort1, null);
Assert.assertTrue(client2.waitFor(5000, BayeuxClient.State.DISCONNECTED));
// A client that forges an Oort comet authentication may not connect
Message.Mutable forgedAuthFields = new HashMapMessage();
Map<String, Object> ext = forgedAuthFields.getExt(true);
Map<String, Object> oortExt = new HashMap<>();
ext.put(Oort.EXT_OORT_FIELD, oortExt);
oortExt.put(Oort.EXT_OORT_URL_FIELD, oort1.getURL());
oortExt.put(Oort.EXT_OORT_SECRET_FIELD, "anything");
oortExt.put(Oort.EXT_COMET_URL_FIELD, oort2.getURL());