Search in sources :

Example 1 with ShareInfo

use of com.zimbra.soap.type.ShareInfo in project zm-mailbox by Zimbra.

the class TestAclPush method testAclPushAndDiscovery.

@Test
public void testAclPushAndDiscovery() throws Exception {
    // create a folder in user1's mailbox
    Mailbox mbox1 = MailboxManager.getInstance().getMailboxByAccount(acct1);
    Folder.FolderOptions fopt = new Folder.FolderOptions().setDefaultView(MailItem.Type.DOCUMENT);
    Folder folder = mbox1.createFolder(null, "/folder1", fopt);
    // grant access to the created folder to user2
    Account acct2 = Provisioning.getInstance().getAccountByName(TestUtil.getAddress(USER2_NAME));
    mbox1.grantAccess(null, folder.getId(), acct2.getId(), ACL.GRANTEE_USER, ACL.stringToRights("r"), null);
    // Give some time for AclPushTask to run
    Thread.sleep(100);
    // invoke GetShareInfoRequest from user2 and check that the shared is discovered
    ZMailbox zMailbox2 = TestUtil.getZMailbox(USER2_NAME);
    GetShareInfoRequest req = new GetShareInfoRequest();
    GetShareInfoResponse resp = zMailbox2.invokeJaxb(req);
    List<ShareInfo> shares = resp.getShares();
    ShareInfo share = getShare(shares, "/folder1");
    assertNotNull(share);
    assertEquals(acct2.getId(), share.getGranteeId());
    assertEquals(ACL.typeToString(ACL.GRANTEE_USER), share.getGranteeType());
    assertEquals(folder.getPath(), share.getFolderPath());
    assertEquals(folder.getId(), share.getFolderId());
    assertEquals(folder.getUuid(), share.getFolderUuid());
    assertEquals(folder.getDefaultView().toString(), share.getDefaultView());
    assertEquals("r", share.getRights());
    assertEquals(acct1.getId(), share.getOwnerId());
    // rename folder
    mbox1.rename(null, folder.getId(), MailItem.Type.FOLDER, "/folder2");
    Thread.sleep(100);
    resp = zMailbox2.invokeJaxb(req);
    shares = resp.getShares();
    assertNotNull(getShare(shares, "/folder2"));
    // create another folder and share with DL
    Folder dlFolder = mbox1.createFolder(null, "/" + DL_NAME, fopt);
    mbox1.grantAccess(null, dlFolder.getId(), dl.getId(), ACL.GRANTEE_GROUP, ACL.stringToRights("rwi"), null);
    Thread.sleep(100);
    resp = zMailbox2.invokeJaxb(req);
    shares = resp.getShares();
    ShareInfo dlShare = getShare(shares, "/" + DL_NAME);
    assertNotNull(dlShare);
    assertEquals(dl.getId(), dlShare.getGranteeId());
    assertEquals(dlFolder.getPath(), dlShare.getFolderPath());
    assertEquals(dlFolder.getDefaultView().toString(), dlShare.getDefaultView());
    assertEquals("rwi", dlShare.getRights());
    assertEquals(acct1.getId(), dlShare.getOwnerId());
    // create another folder and share with "public"
    Folder pubFolder = mbox1.createFolder(null, "/public", fopt);
    mbox1.grantAccess(null, pubFolder.getId(), null, ACL.GRANTEE_PUBLIC, ACL.stringToRights("rw"), null);
    Thread.sleep(100);
    resp = zMailbox2.invokeJaxb(req);
    shares = resp.getShares();
    ShareInfo pubShare = getShare(shares, "/public");
    assertNotNull(pubShare);
    assertEquals(pubFolder.getPath(), pubShare.getFolderPath());
    assertEquals(pubFolder.getDefaultView().toString(), pubShare.getDefaultView());
    assertEquals("rw", pubShare.getRights());
    assertEquals(acct1.getId(), pubShare.getOwnerId());
    // revoke access for user2 on the first folder
    mbox1.revokeAccess(null, folder.getId(), acct2.getId());
    Thread.sleep(100);
    resp = zMailbox2.invokeJaxb(req);
    shares = resp.getShares();
    assertNull(getShare(shares, "/folder2"));
    assertNotNull(getShare(shares, "/" + DL_NAME));
    assertNotNull(getShare(shares, "/public"));
    // delete dlFolder and pubFolder
    mbox1.delete(null, dlFolder.getId(), MailItem.Type.FOLDER);
    mbox1.delete(null, pubFolder.getId(), MailItem.Type.FOLDER);
    Thread.sleep(100);
    resp = zMailbox2.invokeJaxb(req);
    shares = resp.getShares();
    assertNull(getShare(shares, "/" + DL_NAME));
    assertNull(getShare(shares, "/public"));
}
Also used : Account(com.zimbra.cs.account.Account) ZMailbox(com.zimbra.client.ZMailbox) Mailbox(com.zimbra.cs.mailbox.Mailbox) ZMailbox(com.zimbra.client.ZMailbox) GetShareInfoResponse(com.zimbra.soap.account.message.GetShareInfoResponse) GetShareInfoRequest(com.zimbra.soap.account.message.GetShareInfoRequest) Folder(com.zimbra.cs.mailbox.Folder) ShareInfo(com.zimbra.soap.type.ShareInfo) Test(org.junit.Test)

Example 2 with ShareInfo

use of com.zimbra.soap.type.ShareInfo in project zm-mailbox by Zimbra.

the class TestJaxbProvisioning method checkGetShareInfo.

public void checkGetShareInfo(ShareSet expected, List<ShareInfo> shares) {
    if (expected != null) {
        Assert.assertEquals("Number of shares", expected.shares.size(), shares.size());
        for (CutDownShareInfo share : expected.shares) {
            boolean found = false;
            for (ShareInfo aShare : shares) {
                if (share.matches(aShare)) {
                    found = true;
                    break;
                }
            }
            Assert.assertTrue(String.format("no match for '%s' in: %s", share, shares), found);
        }
    }
}
Also used : ShareInfo(com.zimbra.soap.type.ShareInfo)

Example 3 with ShareInfo

use of com.zimbra.soap.type.ShareInfo in project zm-mailbox by Zimbra.

the class TestJaxbProvisioning method setupShare.

public void setupShare(Account sharerAccount, String sharerFolderName, byte color, String defaultView, String granteeType, String perm, Account shareeAccount, Account mountingAccount, String mountFolderName) {
    ShareInfo fred = new ShareInfo();
    fred.getGranteeType();
    String theSharee = (shareeAccount != null) ? shareeAccount.getName() : null;
    String folderId = createFolder(sharerAccount, sharerFolderName, Byte.valueOf(color), defaultView);
    grantAccess(sharerAccount, folderId, granteeType, theSharee, perm);
    if (mountingAccount != null) {
        createMountpoint(mountingAccount, mountFolderName, defaultView, sharerAccount.getId(), folderId);
    }
}
Also used : ShareInfo(com.zimbra.soap.type.ShareInfo)

Aggregations

ShareInfo (com.zimbra.soap.type.ShareInfo)3 ZMailbox (com.zimbra.client.ZMailbox)1 Account (com.zimbra.cs.account.Account)1 Folder (com.zimbra.cs.mailbox.Folder)1 Mailbox (com.zimbra.cs.mailbox.Mailbox)1 GetShareInfoRequest (com.zimbra.soap.account.message.GetShareInfoRequest)1 GetShareInfoResponse (com.zimbra.soap.account.message.GetShareInfoResponse)1 Test (org.junit.Test)1