use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class ContentRemoteSessionTest method testWriteBinary.
@Test
public void testWriteBinary() throws Exception {
Blob blob = mock(Blob.class);
InputStream stream = mock(InputStream.class);
Root root = mock(Root.class);
doReturn(blob).when(root).createBlob(stream);
ContentSession session = mock(ContentSession.class);
doReturn(root).when(session).getLatestRoot();
ContentRemoteBinaries binaries = mock(ContentRemoteBinaries.class);
doReturn("id").when(binaries).put(blob);
ContentRemoteSession remoteSession = createSession(session, binaries);
assertEquals("id", remoteSession.writeBinary(stream).asString());
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class L3_LoginModuleTest method testLogin.
@Test
public void testLogin() throws LoginException, NoSuchWorkspaceException, IOException {
ContentSession contentSession = login(new GuestCredentials());
contentSession.close();
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class LoginModuleImplTest method testGuestLogin.
@Test
public void testGuestLogin() throws Exception {
try (ContentSession cs = login(new GuestCredentials())) {
AuthInfo authInfo = cs.getAuthInfo();
String anonymousID = UserUtil.getAnonymousId(getUserConfiguration().getParameters());
assertEquals(anonymousID, authInfo.getUserID());
}
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class LoginModuleImplTest method testUserLoginIsCaseInsensitive.
@Test
public void testUserLoginIsCaseInsensitive() throws Exception {
ContentSession cs = null;
try {
createTestUser();
cs = login(new SimpleCredentials(USER_ID_CASED, USER_PW.toCharArray()));
AuthInfo authInfo = cs.getAuthInfo();
UserManager userMgr = getUserManager(root);
Authorizable auth = userMgr.getAuthorizable(authInfo.getUserID());
assertNotNull(auth);
assertTrue(auth.getID().equalsIgnoreCase(USER_ID_CASED));
} finally {
if (cs != null) {
cs.close();
}
}
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class LoginModuleImplTest method testUnknownUserLogin.
@Test
public void testUnknownUserLogin() throws Exception {
ContentSession cs = null;
try {
cs = login(new SimpleCredentials("unknown", "".toCharArray()));
fail("Unknown user must not be able to login");
} catch (LoginException e) {
// success
} finally {
if (cs != null) {
cs.close();
}
}
}
Aggregations