use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class LdapDefaultLoginModuleTest method testGuestLogin.
/**
* Login with {@link javax.jcr.GuestCredentials} must succeed and result in
* an guest session as the SUFFICIENT
* {@link org.apache.jackrabbit.oak.security.authentication.user.LoginModuleImpl}
* handles the guest login (in contrast to the ExternalLoginModule).
*
* @throws Exception
*/
@Test
public void testGuestLogin() throws Exception {
ContentSession cs = login(new GuestCredentials());
assertEquals(UserConstants.DEFAULT_ANONYMOUS_ID, cs.getAuthInfo().getUserID());
cs.close();
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class LdapLoginStandaloneTest method testGuestLogin.
@Test
public void testGuestLogin() throws Exception {
try {
ContentSession sc = login(new GuestCredentials());
sc.close();
fail("Guest login must fail.");
} catch (LoginException e) {
// success
}
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class LdapLoginTestBase method testSyncCreateUser.
@Test
public void testSyncCreateUser() throws Exception {
ContentSession cs = null;
try {
cs = login(new SimpleCredentials(USER_ID, USER_PWD.toCharArray()));
root.refresh();
Authorizable user = userManager.getAuthorizable(USER_ID);
assertNotNull(user);
assertTrue(user.hasProperty(USER_PROP));
Tree userTree = cs.getLatestRoot().getTree(user.getPath());
assertFalse(userTree.hasProperty(UserConstants.REP_PASSWORD));
assertNull(userManager.getAuthorizable(GROUP_DN));
} finally {
if (cs != null) {
cs.close();
}
options.clear();
}
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class LdapLoginTestBase method testNullLogin.
/**
* Null login must fail.
*
* @throws Exception
* @see org.apache.jackrabbit.oak.security.authentication.ldap.GuestTokenDefaultLdapLoginModuleTest
*/
@Test
public void testNullLogin() throws Exception {
ContentSession cs = null;
try {
cs = login(null);
fail("Expected null login to fail.");
} catch (LoginException e) {
// success
} finally {
if (cs != null) {
cs.close();
}
}
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class LdapLoginTestBase method testSyncUpdate.
@Test
public void testSyncUpdate() throws Exception {
// create user upfront in order to test update mode
Authorizable user = userManager.createUser(USER_ID, null);
ExternalUser externalUser = idp.getUser(USER_ID);
user.setProperty("rep:externalId", new ValueFactoryImpl(root, NamePathMapper.DEFAULT).createValue(externalUser.getExternalId().getString()));
root.commit();
ContentSession cs = null;
try {
cs = login(new SimpleCredentials(USER_ID, USER_PWD.toCharArray()));
root.refresh();
user = userManager.getAuthorizable(USER_ID);
assertNotNull(user);
assertTrue(user.hasProperty(USER_PROP));
assertNull(userManager.getAuthorizable(GROUP_DN));
} finally {
if (cs != null) {
cs.close();
}
options.clear();
}
}
Aggregations