use of org.apache.sling.hc.support.impl.DefaultLoginsHealthCheck in project sling by apache.
the class DefaultLoginsHealthCheckTest method getTestResult.
private Result getTestResult(String login) throws Exception {
final DefaultLoginsHealthCheck c = new DefaultLoginsHealthCheck();
SetField.set(c, "logins", Arrays.asList(new String[] { login }));
final SlingRepository repo = Mockito.mock(SlingRepository.class);
SetField.set(c, "repository", repo);
final Session s = Mockito.mock(Session.class);
Mockito.when(repo.login(Matchers.any(Credentials.class))).thenAnswer(new Answer<Session>() {
@Override
public Session answer(InvocationOnMock invocation) {
final SimpleCredentials c = (SimpleCredentials) invocation.getArguments()[0];
if ("admin".equals(c.getUserID())) {
return s;
}
return null;
}
});
return c.execute();
}
Aggregations