/** * Connects 2 identities, if toConfirm = true, they're connected. If false, in pending connection * type. * * @param senderIdentity the identity who sends connection request * @param receiverIdentity the identity who receives connnection request * @param beConfirmed boolean value */ private void connectIdentities( Identity senderIdentity, Identity receiverIdentity, boolean beConfirmed) { relationshipManager.inviteToConnect(senderIdentity, receiverIdentity); if (beConfirmed) { relationshipManager.confirm(receiverIdentity, senderIdentity); } tearDownRelationshipList.add(relationshipManager.get(senderIdentity, receiverIdentity)); }
/** Tests {@link SecurityManager#canPostActivity(PortalContainer, Identity, Identity)}. */ public void testCanPostActivity() { boolean demoPostToDemo = SecurityManager.canPostActivity(getContainer(), demoIdentity, demoIdentity); assertTrue("demoPostToDemo must be true", demoPostToDemo); boolean demoPostToJohn = SecurityManager.canPostActivity(getContainer(), demoIdentity, johnIdentity); assertFalse("demoPostToJohn must be false", demoPostToJohn); // demo is connected to mary => they can post activity to each other's activity stream relationshipManager.inviteToConnect(demoIdentity, maryIdentity); boolean demoPostToMary = SecurityManager.canPostActivity(getContainer(), demoIdentity, maryIdentity); boolean maryPostToDemo = SecurityManager.canPostActivity(getContainer(), maryIdentity, demoIdentity); assertFalse("demoPostToMary must be false", demoPostToMary); assertFalse("maryPostToDemo must be false", maryPostToDemo); relationshipManager.confirm(maryIdentity, demoIdentity); tearDownRelationshipList.add(relationshipManager.get(demoIdentity, maryIdentity)); demoPostToMary = SecurityManager.canPostActivity(getContainer(), demoIdentity, maryIdentity); maryPostToDemo = SecurityManager.canPostActivity(getContainer(), maryIdentity, demoIdentity); assertTrue("demoPostToMary must be true", demoPostToMary); assertTrue("maryPostToDemo must be true", maryPostToDemo); // checks user posts to space createSpaces(1); Space createdSpace = tearDownSpaceList.get(0); Identity spaceIdentity = identityManager.getOrCreateIdentity( SpaceIdentityProvider.NAME, createdSpace.getPrettyName(), false); assertNotNull("spaceIdentity must not be null", spaceIdentity); // demo, mary could post activity to this space's activity stream boolean demoPostToSpace = SecurityManager.canPostActivity(getContainer(), demoIdentity, spaceIdentity); assertTrue("demoPostToSpace must be true", demoPostToSpace); boolean maryPostToSpace = SecurityManager.canPostActivity(getContainer(), maryIdentity, spaceIdentity); assertTrue("maryPostToSpace must be false", maryPostToSpace); // john could not boolean johnPostToSpace = SecurityManager.canPostActivity(getContainer(), johnIdentity, spaceIdentity); assertFalse("johnPostToSpace must be false", johnPostToSpace); }