title: Unit testing JAX-RS (RESTEasy)
body: <p>I have developed a REST application server based on RESTEasy (JAX-RS).</p>
  
  <p>I have a set of unit tests for each service based on <code>org.jboss.resteasy.mock.MockDispatcherFactory</code>. These mock out the database calls so that I can return "canned" database responses.</p>
  
  <p>Everything worked well until I added security code that checked the DIGEST Principal (<code>java.security.Principal</code>). I wrote a security interceptor that expects to retrieve the user identity of the user calling the service and verify that this user has authorization to execute the service.</p>
  
  <p>I can't find any way to send in a mock Principal.</p>
  
  <p>Short of disabling my security checks in my unit tests, is there any way to tell the mock server to use a mock Principal? I would rather <strong>NOT</strong> disable the security, because that is part of what I want to test.</p>