Search in sources :

Example 26 with Identity

use of com.zimbra.cs.account.Identity in project zm-mailbox by Zimbra.

the class TestLdapProvIdentity method createIdentity.

private Identity createIdentity(Account acct, String identityName) throws Exception {
    Identity identity = prov.get(acct, Key.IdentityBy.name, identityName);
    assertNull(identity);
    createIdentityRaw(acct, identityName);
    identity = prov.get(acct, Key.IdentityBy.name, identityName);
    assertNotNull(identity);
    assertEquals(identityName, identity.getName());
    return identity;
}
Also used : Identity(com.zimbra.cs.account.Identity)

Example 27 with Identity

use of com.zimbra.cs.account.Identity in project zm-mailbox by Zimbra.

the class TestLdapProvIdentity method createIdentity.

@Test
public void createIdentity() throws Exception {
    String ACCT_NAME_LOCALPART = Names.makeAccountNameLocalPart(genAcctNameLocalPart());
    String IDENTITY_NAME = Names.makeIdentityName(genIdentityName());
    Account acct = createAccount(ACCT_NAME_LOCALPART);
    Identity identity = createIdentity(acct, IDENTITY_NAME);
    assertEquals(acct.getId(), identity.getAccount().getId());
    deleteIdentity(acct, identity);
    deleteAccount(acct);
}
Also used : Account(com.zimbra.cs.account.Account) Identity(com.zimbra.cs.account.Identity) Test(org.junit.Test)

Example 28 with Identity

use of com.zimbra.cs.account.Identity in project zm-mailbox by Zimbra.

the class TestLdapProvIdentity method getAllIdentitys.

@Test
public void getAllIdentitys() throws Exception {
    String ACCT_NAME_LOCALPART = Names.makeAccountNameLocalPart(genAcctNameLocalPart());
    String IDENTITYE_NAME_1 = Names.makeIdentityName(genIdentityName("1"));
    String IDENTITYE_NAME_2 = Names.makeIdentityName(genIdentityName("2"));
    String IDENTITYE_NAME_3 = Names.makeIdentityName(genIdentityName("3"));
    Account acct = createAccount(ACCT_NAME_LOCALPART);
    Identity identity1 = createIdentity(acct, IDENTITYE_NAME_1);
    Identity identity2 = createIdentity(acct, IDENTITYE_NAME_2);
    Identity identity3 = createIdentity(acct, IDENTITYE_NAME_3);
    acct = getFresh(acct);
    List<Identity> allIdentitys = prov.getAllIdentities(acct);
    // 3 + the account identity
    assertEquals(4, allIdentitys.size());
    Set<String> allIdentityIds = new HashSet<String>();
    for (Identity identity : allIdentitys) {
        allIdentityIds.add(identity.getId());
    }
    assertTrue(allIdentityIds.contains(identity1.getId()));
    assertTrue(allIdentityIds.contains(identity2.getId()));
    assertTrue(allIdentityIds.contains(identity3.getId()));
    deleteIdentity(acct, identity1);
    deleteIdentity(acct, identity2);
    deleteIdentity(acct, identity3);
    deleteAccount(acct);
}
Also used : Account(com.zimbra.cs.account.Account) Identity(com.zimbra.cs.account.Identity) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 29 with Identity

use of com.zimbra.cs.account.Identity in project zm-mailbox by Zimbra.

the class TestLdapProvRenameDomain method createIdentities.

private void createIdentities(Account acct, String[] sigIds) throws Exception {
    for (int i = 0; i < NUM_IDENTITIES; i++) {
        Map<String, Object> attrs = new HashMap<String, Object>();
        // just some random id, not used anywhere
        attrs.put(Provisioning.A_zimbraPrefDefaultSignatureId, LdapUtil.generateUUID());
        attrs.put(Provisioning.A_zimbraPrefFromAddress, "micky.mouse@zimbra,com");
        attrs.put(Provisioning.A_zimbraPrefFromDisplay, "Micky Mouse");
        attrs.put(Provisioning.A_zimbraPrefReplyToEnabled, "TRUE");
        attrs.put(Provisioning.A_zimbraPrefReplyToAddress, "goofy@yahoo.com");
        attrs.put(Provisioning.A_zimbraPrefReplyToDisplay, "Micky");
        if (i < NUM_SIGNATURES)
            attrs.put(Provisioning.A_zimbraPrefDefaultSignatureId, sigIds[i]);
        Identity entry = prov.createIdentity(acct, IDENTITY_NAME(acct, i), attrs);
    }
}
Also used : HashMap(java.util.HashMap) Identity(com.zimbra.cs.account.Identity)

Aggregations

Identity (com.zimbra.cs.account.Identity)29 Account (com.zimbra.cs.account.Account)17 Test (org.junit.Test)7 ServiceException (com.zimbra.common.service.ServiceException)5 AccountServiceException (com.zimbra.cs.account.AccountServiceException)5 ArrayList (java.util.ArrayList)5 Element (com.zimbra.common.soap.Element)4 AuthFailedServiceException (com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException)4 LdapIdentity (com.zimbra.cs.account.ldap.entry.LdapIdentity)4 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)4 HashMap (java.util.HashMap)4 Provisioning (com.zimbra.cs.account.Provisioning)3 LdapEntry (com.zimbra.cs.account.ldap.entry.LdapEntry)3 JavaMailInternetAddress (com.zimbra.common.mime.shim.JavaMailInternetAddress)2 Signature (com.zimbra.cs.account.Signature)2 ZLdapContext (com.zimbra.cs.ldap.ZLdapContext)2 Date (java.util.Date)2 Locale (java.util.Locale)2 Address (javax.mail.Address)2 InternetAddress (javax.mail.internet.InternetAddress)2