Fixes #3407: Prevent NPE when publishing event

Fixes #3407: Prevent NPE
Principal is null only if client endpoint is not authenticated. And it seems that we are trying to use principal when not authenticated to send an event.  
In normal scenario of the test, we should not get unauthenticated client. It seems that this test is run before another finished. This is why we get unauthenticated client, which is nice because it revealed NPE.