@Test
public void testLogPrincipal() {

    HttpServletRequest servletRequest = new MockHttpServletRequest();
    HttpServletResponse servletResponse = Mockito.mock(HttpServletResponse.class);
    AuthorityList authListMock = new AuthorityList();
    Authorizer authorizerMock = Mockito.mock(Authorizer.class);
    Metric metricMock = Mockito.mock(Metric.class);
    Object timerMetricMock = Mockito.mock(Object.class);
    RsrcCtxWrapper wrapper = new RsrcCtxWrapper(servletRequest, servletResponse,
            authListMock, false, authorizerMock, metricMock, timerMetricMock, "apiName");
    wrapper.logPrincipal((Principal) null);
    assertNull(servletRequest.getAttribute("com.yahoo.athenz.auth.principal"));
    wrapper.logPrincipal((String) null);
    assertNull(servletRequest.getAttribute("com.yahoo.athenz.auth.principal"));
    SimplePrincipal principal = (SimplePrincipal) SimplePrincipal.create("hockey", "kings",
            "v=S1,d=hockey;n=kings;s=sig", 0, new PrincipalAuthority());
    wrapper.logPrincipal(principal);
    assertEquals(servletRequest.getAttribute("com.yahoo.athenz.auth.principal"), "hockey.kings");
    assertEquals(servletRequest.getAttribute("com.yahoo.athenz.auth.authority_id"), "Auth-NTOKEN");
}