@Test
public void testAuthenticateWithPathAndPrivilege() throws Exception {
String serviceName = "service";
TransportAuthenticationContext context = new TransportAuthenticationContext();
String path = "/foo/bar";
context.addAttribute("path", path);
String privilege = Privilege.JCR_WRITE;
context.addAttribute("privilege", privilege);
SlingRepository repo = mock(SlingRepository.class);
Session authenticatedSession = mock(Session.class);
when(authenticatedSession.hasPermission(path, privilege)).thenReturn(true);
when(repo.loginService(serviceName, null)).thenReturn(authenticatedSession);