Mockito.stub(impl.getUserName()).toReturn("steve@somedomain");
Mockito.stub(impl.getLoginContext()).toReturn(Mockito.mock(LoginContext.class));
final ArrayList<String> domains = new ArrayList<String>();
domains.add("somedomain");
SessionServiceImpl ssi = new SessionServiceImpl() {
@Override
protected TeiidLoginContext authenticate(String userName, Credentials credentials, String applicationName, List<String> domains, SecurityHelper helper, boolean passthough)
throws LoginException {
impl.authenticateUser(userName, credentials, applicationName, domains, passthough);
return impl;
}
};
ssi.setSecurityDomains("somedomain");
try {
ssi.validateSession(String.valueOf(1));
fail("exception expected"); //$NON-NLS-1$
} catch (InvalidSessionException e) {
}
SessionMetadata info = ssi.createSession("steve", null, "foo", new Properties(), false, true); //$NON-NLS-1$ //$NON-NLS-2$
if (securityEnabled) {
Mockito.verify(impl).authenticateUser("steve", null, "foo", domains, false);
}
String id1 = info.getSessionId();
ssi.validateSession(id1);
assertEquals(1, ssi.getActiveSessionsCount());
assertEquals(0, ssi.getSessionsLoggedInToVDB("a", 1).size()); //$NON-NLS-1$
ssi.closeSession(id1);
try {
ssi.validateSession(id1);
fail("exception expected"); //$NON-NLS-1$
} catch (InvalidSessionException e) {
}
try {
ssi.closeSession(id1);
fail("exception expected"); //$NON-NLS-1$
} catch (InvalidSessionException e) {
}
}