@Test
public void testGetUserTokenMismatchName() {

    int code = 401;
    
    Authority userAuthority = new com.yahoo.athenz.common.server.debug.DebugUserAuthority();
    
    String userId = "user1";
    Principal principal = SimplePrincipal.create("user", userId, userId + ":password",
            0, userAuthority);
    assertNotNull(principal);
    ((SimplePrincipal) principal).setUnsignedCreds(userId);
    ResourceContext rsrcCtx1 = createResourceContext(principal);
    
    try {
        zms.getUserToken(rsrcCtx1, "user2", null, null);
        fail("unauthorizederror not thrown.");
    } catch (ResourceException ex) {
        assertEquals(ex.getCode(), code);
    }
    
    try {
        zms.getUserToken(rsrcCtx1, "_self", null, false);
        fail("unauthorizederror not thrown.");
    } catch (ResourceException ex) {
        assertEquals(ex.getCode(), code);
    }
    
    try {
        zms.getUserToken(rsrcCtx1, "self", null, false);
        fail("unauthorizederror not thrown.");
    } catch (ResourceException ex) {
        assertEquals(ex.getCode(), code);
    }
}