use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class ContentRemoteSessionTest method testReadLastRevisionAsString.
@Test
public void testReadLastRevisionAsString() {
Root root = mock(Root.class);
AuthInfo authInfo = mock(AuthInfo.class);
ContentSession session = mock(ContentSession.class);
doReturn(authInfo).when(session).getAuthInfo();
doReturn(root).when(session).getLatestRoot();
ContentRemoteRevisions revisions = mock(ContentRemoteRevisions.class);
doReturn("id").when(revisions).put(authInfo, root);
assertEquals("id", createSession(session, revisions).readLastRevision().asString());
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class ContentRemoteSessionTest method testReadRevisionAsString.
@Test
public void testReadRevisionAsString() {
Root root = mock(Root.class);
AuthInfo authInfo = mock(AuthInfo.class);
ContentSession session = mock(ContentSession.class);
doReturn(authInfo).when(session).getAuthInfo();
ContentRemoteRevisions revisions = mock(ContentRemoteRevisions.class);
doReturn(root).when(revisions).get(authInfo, "id");
assertEquals("id", createSession(session, revisions).readRevision("id").asString());
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class ContentRemoteSessionTest method testWriteBinaryFailure.
@Test(expected = RuntimeException.class)
public void testWriteBinaryFailure() throws Exception {
InputStream stream = mock(InputStream.class);
Root root = mock(Root.class);
doThrow(IOException.class).when(root).createBlob(stream);
ContentSession session = mock(ContentSession.class);
doReturn(root).when(session).getLatestRoot();
ContentRemoteSession remoteSession = createSession(session);
remoteSession.writeBinary(stream);
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class ContentRemoteSessionTest method testReadRevision.
@Test
public void testReadRevision() {
Root root = mock(Root.class);
AuthInfo authInfo = mock(AuthInfo.class);
ContentSession session = mock(ContentSession.class);
doReturn(authInfo).when(session).getAuthInfo();
ContentRemoteRevisions revisions = mock(ContentRemoteRevisions.class);
doReturn(root).when(revisions).get(authInfo, "id");
assertNotNull(createSession(session, revisions).readRevision("id"));
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class ExternalLoginModuleAutoMembershipTest method testLoginSyncAutoMembershipSetup1.
@Test
public void testLoginSyncAutoMembershipSetup1() throws Exception {
ContentSession cs = null;
try {
cs = login(new SimpleCredentials(USER_ID, new char[0]));
// the login must set the existing auto-membership principals to the subject
Set<Principal> principals = cs.getAuthInfo().getPrincipals();
assertTrue(principals.contains(setup1.gr.getPrincipal()));
assertFalse(principals.contains(new PrincipalImpl(NON_EXISTING_NAME)));
assertFalse(principals.contains(setup2.gr.getPrincipal()));
assertFalse(principals.contains(setup3.gr.getPrincipal()));
// however, the existing auto-membership group must _not_ have changed
// and the test user must not be a stored member of this group.
root.refresh();
UserManager uMgr = getUserManager(root);
User user = uMgr.getAuthorizable(USER_ID, User.class);
Group gr = uMgr.getAuthorizable(setup1.gr.getID(), Group.class);
assertFalse(gr.isDeclaredMember(user));
assertFalse(gr.isMember(user));
} finally {
options.clear();
if (cs != null) {
cs.close();
}
}
}
Aggregations