Search in sources :

Example 16 with Provisioning

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

the class EnvelopeTest method testAllDomainLocalIs.

@Test
public void testAllDomainLocalIs() {
    String filterScript = "require  [\"envelope\", \"tag\"];\n" + "if envelope :domain :is \"to\" \"zimbra.com\" {\n" + "    tag \"is-domain\";\n" + "}\n" + "if envelope :localpart :is \"to\" \"xyz\" {\n" + "    tag \"is-local\";\n" + "}\n" + "if envelope :all :is \"to\" \"xyz@zimbra.com\" {" + "    tag \"is-all\";\n" + "}";
    LmtpEnvelope env = new LmtpEnvelope();
    LmtpAddress sender = new LmtpAddress("<t1@zimbra.com>", new String[] { "BODY", "SIZE" }, null);
    LmtpAddress recipient = new LmtpAddress("<xyz@zimbra.com>", null, null);
    env.setSender(sender);
    env.addLocalRecipient(recipient);
    try {
        Provisioning prov = Provisioning.getInstance();
        Account account = prov.createAccount("xyz@zimbra.com", "secret", new HashMap<String, Object>());
        account.setMail("xyz@zimbra.com");
        RuleManager.clearCachedRules(account);
        Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(account);
        account.setMailSieveScript(filterScript);
        List<ItemId> ids = RuleManager.applyRulesToIncomingMessage(new OperationContext(mbox), mbox, new ParsedMessage(sampleMsg.getBytes(), false), 0, account.getName(), env, new DeliveryContext(), Mailbox.ID_FOLDER_INBOX, true);
        Assert.assertEquals(1, ids.size());
        Message msg = mbox.getMessageById(null, ids.get(0).getId());
        String[] tags = msg.getTags();
        Assert.assertTrue(tags != null);
        Assert.assertEquals(3, tags.length);
        Assert.assertEquals("is-domain", tags[0]);
        Assert.assertEquals("is-local", tags[1]);
        Assert.assertEquals("is-all", tags[2]);
    } catch (Exception e) {
        fail("No exception should be thrown: " + e);
    }
}
Also used : OperationContext(com.zimbra.cs.mailbox.OperationContext) Account(com.zimbra.cs.account.Account) Message(com.zimbra.cs.mailbox.Message) ParsedMessage(com.zimbra.cs.mime.ParsedMessage) ParsedMessage(com.zimbra.cs.mime.ParsedMessage) ItemId(com.zimbra.cs.service.util.ItemId) MockProvisioning(com.zimbra.cs.account.MockProvisioning) Provisioning(com.zimbra.cs.account.Provisioning) Mailbox(com.zimbra.cs.mailbox.Mailbox) LmtpAddress(com.zimbra.cs.lmtpserver.LmtpAddress) LmtpEnvelope(com.zimbra.cs.lmtpserver.LmtpEnvelope) DeliveryContext(com.zimbra.cs.mailbox.DeliveryContext) Test(org.junit.Test)

Example 17 with Provisioning

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

the class FlaggedTestTest method init.

@BeforeClass
public static void init() throws Exception {
    MailboxTestUtil.initServer();
    Provisioning prov = Provisioning.getInstance();
    prov.createAccount("test@zimbra.com", "secret", new HashMap<String, Object>());
}
Also used : MockProvisioning(com.zimbra.cs.account.MockProvisioning) Provisioning(com.zimbra.cs.account.Provisioning) BeforeClass(org.junit.BeforeClass)

Example 18 with Provisioning

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

the class RedirectCopyTest method init.

@BeforeClass
public static void init() throws Exception {
    MailboxTestUtil.initServer();
    Provisioning prov = Provisioning.getInstance();
    Map<String, Object> attrs = Maps.newHashMap();
    prov.createDomain("zimbra.com", attrs);
    attrs = Maps.newHashMap();
    attrs.put(Provisioning.A_zimbraId, UUID.randomUUID().toString());
    prov.createAccount("test1@zimbra.com", "secret", attrs);
    attrs = Maps.newHashMap();
    attrs.put(Provisioning.A_zimbraId, UUID.randomUUID().toString());
    Account acct = prov.createAccount("test2@zimbra.com", "secret", attrs);
    attrs = Maps.newHashMap();
    attrs.put(Provisioning.A_zimbraId, UUID.randomUUID().toString());
    prov.createAccount("test3@zimbra.com", "secret", attrs);
    Server server = Provisioning.getInstance().getServer(acct);
    // this MailboxManager does everything except actually send mail
    MailboxManager.setInstance(new DirectInsertionMailboxManager());
}
Also used : Account(com.zimbra.cs.account.Account) Server(com.zimbra.cs.account.Server) Provisioning(com.zimbra.cs.account.Provisioning) DirectInsertionMailboxManager(com.zimbra.cs.service.mail.SendMsgTest.DirectInsertionMailboxManager) BeforeClass(org.junit.BeforeClass)

Example 19 with Provisioning

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

the class ReplyTest method init.

@BeforeClass
public static void init() throws Exception {
    MailboxTestUtil.initServer();
    MailboxTestUtil.clearData();
    Provisioning prov = Provisioning.getInstance();
    Map<String, Object> attrs = Maps.newHashMap();
    prov.createDomain("zimbra.com", attrs);
    attrs = Maps.newHashMap();
    attrs.put(Provisioning.A_zimbraId, UUID.randomUUID().toString());
    attrs.put(Provisioning.A_zimbraSieveNotifyActionRFCCompliant, "FALSE");
    prov.createAccount("test@zimbra.com", "secret", attrs);
    attrs = Maps.newHashMap();
    attrs.put(Provisioning.A_zimbraId, UUID.randomUUID().toString());
    attrs.put(Provisioning.A_zimbraSieveNotifyActionRFCCompliant, "FALSE");
    prov.createAccount("test2@zimbra.com", "secret", attrs);
    // this MailboxManager does everything except actually send mail
    MailboxManager.setInstance(new DirectInsertionMailboxManager());
}
Also used : Provisioning(com.zimbra.cs.account.Provisioning) DirectInsertionMailboxManager(com.zimbra.cs.service.mail.SendMsgTest.DirectInsertionMailboxManager) BeforeClass(org.junit.BeforeClass)

Example 20 with Provisioning

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

the class RuleManagerAdminFilterTest method init.

@BeforeClass
public static void init() throws Exception {
    MailboxTestUtil.initServer();
    Provisioning prov = Provisioning.getInstance();
    prov.createAccount("test@zimbra.com", "secret", new HashMap<String, Object>());
}
Also used : MockProvisioning(com.zimbra.cs.account.MockProvisioning) Provisioning(com.zimbra.cs.account.Provisioning) BeforeClass(org.junit.BeforeClass)

Aggregations

Provisioning (com.zimbra.cs.account.Provisioning)532 Account (com.zimbra.cs.account.Account)216 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)158 Element (com.zimbra.common.soap.Element)144 ServiceException (com.zimbra.common.service.ServiceException)96 BeforeClass (org.junit.BeforeClass)93 MockProvisioning (com.zimbra.cs.account.MockProvisioning)89 Server (com.zimbra.cs.account.Server)83 HashMap (java.util.HashMap)76 Domain (com.zimbra.cs.account.Domain)70 SoapProvisioning (com.zimbra.cs.account.soap.SoapProvisioning)53 Mailbox (com.zimbra.cs.mailbox.Mailbox)50 Cos (com.zimbra.cs.account.Cos)32 Test (org.junit.Test)30 NamedEntry (com.zimbra.cs.account.NamedEntry)25 AuthToken (com.zimbra.cs.account.AuthToken)23 Group (com.zimbra.cs.account.Group)23 ArrayList (java.util.ArrayList)23 AccountServiceException (com.zimbra.cs.account.AccountServiceException)22 DistributionList (com.zimbra.cs.account.DistributionList)22