Search in sources :

Example 66 with Provisioning

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

the class JMSessionTest method messageID.

@Test
public void messageID() throws Exception {
    Provisioning prov = Provisioning.getInstance();
    Domain domain = prov.createDomain("example.com", new HashMap<String, Object>());
    Account account = prov.createAccount("user1@example.com", "test123", new HashMap<String, Object>());
    MimeMessage mm = new MimeMessage(JMSession.getSmtpSession(account));
    mm.saveChanges();
    Assert.assertEquals("message ID contains account domain", domain.getName() + '>', mm.getMessageID().split("@")[1]);
}
Also used : Account(com.zimbra.cs.account.Account) MimeMessage(javax.mail.internet.MimeMessage) Domain(com.zimbra.cs.account.Domain) MockProvisioning(com.zimbra.cs.account.MockProvisioning) Provisioning(com.zimbra.cs.account.Provisioning) Test(org.junit.Test)

Example 67 with Provisioning

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

the class CsrfUtilTest method setUpBeforeClass.

/**
     * @throws java.lang.Exception
     */
@BeforeClass
public static void setUpBeforeClass() throws Exception {
    byte[] nonce = new byte[16];
    Random nonceGen = new Random();
    nonceGen.nextBytes(nonce);
    MailboxTestUtil.initServer();
    Provisioning prov = Provisioning.getInstance();
    Map<String, Object> attrs = Maps.newHashMap();
    attrs.put(Provisioning.A_zimbraId, ACCOUNT_ID);
    prov.createAccount("test@zimbra.com", "secret", attrs);
}
Also used : Random(java.util.Random) Provisioning(com.zimbra.cs.account.Provisioning) BeforeClass(org.junit.BeforeClass)

Example 68 with Provisioning

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

the class ZimletUserPropertiesTest method save.

@Test
public void save() throws Exception {
    Provisioning prov = Provisioning.getInstance();
    Account account = prov.getAccount(MockProvisioning.DEFAULT_ACCOUNT_ID);
    ZimletUserProperties prop = ZimletUserProperties.getProperties(account);
    prop.setProperty("phone", "123123", "aaaaaaaaaaaa");
    prop.setProperty("phone", "number", "bar");
    prop.saveProperties(account);
    String[] values = account.getZimletUserProperties();
    Arrays.sort(values);
    Assert.assertArrayEquals(new String[] { "phone:123123:aaaaaaaaaaaa", "phone:number:bar" }, values);
}
Also used : Account(com.zimbra.cs.account.Account) MockProvisioning(com.zimbra.cs.account.MockProvisioning) Provisioning(com.zimbra.cs.account.Provisioning) Test(org.junit.Test)

Example 69 with Provisioning

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

the class AttributeConstraint method main.

/**
     * @param args
     */
public static void main(String[] args) throws ServiceException {
    Provisioning prov = Provisioning.getInstance();
    AttributeManager am = AttributeManager.getInstance();
    AttributeConstraint.fromString(am, "zimbraPasswordMinLength:min=6");
    AttributeConstraint.fromString(am, "zimbraPasswordMaxLength:min=64");
    AttributeConstraint.fromString(am, "zimbraPasswordMinLength:min=6:max=64:values=1,2,3");
    AttributeConstraint.fromString(am, "zimbraFeatureMailEnabled:values=FALSE,TRUE");
    Account acct = prov.get(Key.AccountBy.name, "user1@phoebe.mac");
    Cos cos = prov.getCOS(acct);
    cos.unsetConstraint();
    Map<String, Object> cosConstraints = new HashMap<String, Object>();
    // integer
    cos.addConstraint("zimbraPasswordMinLength:min=6:max=10:values=8,9", cosConstraints);
    // long
    long longMax = Long.MAX_VALUE;
    long longMaxMinusOne = longMax - 1;
    cos.addConstraint("zimbraMailQuota:max=" + longMaxMinusOne, cosConstraints);
    // duration
    cos.addConstraint("zimbraPasswordLockoutDuration:min=5h:max=1d", cosConstraints);
    // gentime
    cos.addConstraint("zimbraPrefPop3DownloadSince:min=20060315023000Z", cosConstraints);
    // string
    cos.addConstraint("zimbraPrefGroupMailBy:values=conversation", cosConstraints);
    // bad constraint, invalid min constraint
    cos.addConstraint("zimbraCalendarMaxRevisions:min=zz:max=10", cosConstraints);
    // multi-value
    cos.addConstraint("zimbraZimletAvailableZimlets:values=A,B,C", cosConstraints);
    prov.modifyAttrs(cos, cosConstraints);
    Map<String, AttributeConstraint> constraints = getConstraint(cos);
    // integer
    test(constraints, "zimbraPasswordMinLength", "5", true);
    test(constraints, "zimbraPasswordMinLength", "6", true);
    test(constraints, "zimbraPasswordMinLength", "7", true);
    test(constraints, "zimbraPasswordMinLength", "8", false);
    test(constraints, "zimbraPasswordMinLength", "9", false);
    test(constraints, "zimbraPasswordMinLength", "10", true);
    test(constraints, "zimbraPasswordMinLength", "11", true);
    // long
    test(constraints, "zimbraMailQuota", "" + longMaxMinusOne, false);
    test(constraints, "zimbraMailQuota", "" + longMax, true);
    // duration
    test(constraints, "zimbraPasswordLockoutDuration", "3h", true);
    test(constraints, "zimbraPasswordLockoutDuration", "25h", true);
    test(constraints, "zimbraPasswordLockoutDuration", "30m", true);
    test(constraints, "zimbraPasswordLockoutDuration", "5h", false);
    test(constraints, "zimbraPasswordLockoutDuration", "600m", false);
    test(constraints, "zimbraPasswordLockoutDuration", "24h", false);
    // gentime
    test(constraints, "zimbraPrefPop3DownloadSince", "20050315023000Z", true);
    test(constraints, "zimbraPrefPop3DownloadSince", "20060315023000Z", false);
    test(constraints, "zimbraPrefPop3DownloadSince", "20060315023001Z", false);
    // string, enum, ...
    test(constraints, "zimbraPrefGroupMailBy", "message", true);
    test(constraints, "zimbraPrefGroupMailBy", "conversation", false);
    // bad constraint
    test(constraints, "zimbraCalendarMaxRevisions", "1", false);
    test(constraints, "zimbraCalendarMaxRevisions", "10", false);
    test(constraints, "zimbraCalendarMaxRevisions", "11", true);
    // multi-value
    test(constraints, "zimbraZimletAvailableZimlets", new String[] { "A", "B" }, false);
    test(constraints, "zimbraZimletAvailableZimlets", new String[] { "A", "X" }, true);
    // no constraint
    test(constraints, "zimbraPasswordMaxLength", "100", false);
}
Also used : Account(com.zimbra.cs.account.Account) AttributeManager(com.zimbra.cs.account.AttributeManager) HashMap(java.util.HashMap) Cos(com.zimbra.cs.account.Cos) Provisioning(com.zimbra.cs.account.Provisioning)

Example 70 with Provisioning

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

the class CollectAllEffectiveRights method setupShapeTest1.

private static void setupShapeTest1() throws ServiceException {
    Provisioning prov = Provisioning.getInstance();
    // create test
    String domainName = "test.com";
    Domain domain = prov.createDomain(domainName, new HashMap<String, Object>());
    DistributionList groupA = prov.createDistributionList("groupA@" + domainName, new HashMap<String, Object>());
    DistributionList groupB = prov.createDistributionList("groupB@" + domainName, new HashMap<String, Object>());
    DistributionList groupC = prov.createDistributionList("groupC@" + domainName, new HashMap<String, Object>());
    DistributionList groupD = prov.createDistributionList("groupD@" + domainName, new HashMap<String, Object>());
    String pw = "test123";
    Account A = prov.createAccount("A@" + domainName, pw, null);
    Account B = prov.createAccount("B@" + domainName, pw, null);
    Account C = prov.createAccount("C@" + domainName, pw, null);
    Account D = prov.createAccount("D@" + domainName, pw, null);
    Account AB = prov.createAccount("AB@" + domainName, pw, null);
    Account AC = prov.createAccount("AC@" + domainName, pw, null);
    Account AD = prov.createAccount("AD@" + domainName, pw, null);
    Account BC = prov.createAccount("BC@" + domainName, pw, null);
    Account BD = prov.createAccount("BD@" + domainName, pw, null);
    Account CD = prov.createAccount("CD@" + domainName, pw, null);
    Account ABC = prov.createAccount("ABC@" + domainName, pw, null);
    Account ABD = prov.createAccount("ABD@" + domainName, pw, null);
    Account ACD = prov.createAccount("ACD@" + domainName, pw, null);
    Account BCD = prov.createAccount("BCD@" + domainName, pw, null);
    Account ABCD = prov.createAccount("ABCD@" + domainName, pw, null);
    groupA.addMembers(new String[] { A.getName(), AB.getName(), AC.getName(), AD.getName(), ABC.getName(), ABD.getName(), ACD.getName(), ABCD.getName() });
    groupB.addMembers(new String[] { B.getName(), AB.getName(), BC.getName(), BD.getName(), ABC.getName(), ABD.getName(), BCD.getName(), ABCD.getName() });
    groupC.addMembers(new String[] { C.getName(), AC.getName(), BC.getName(), CD.getName(), ABC.getName(), ACD.getName(), BCD.getName(), ABCD.getName() });
    groupD.addMembers(new String[] { D.getName(), AD.getName(), BD.getName(), CD.getName(), ABD.getName(), ACD.getName(), BCD.getName(), ABCD.getName() });
}
Also used : Account(com.zimbra.cs.account.Account) Domain(com.zimbra.cs.account.Domain) Provisioning(com.zimbra.cs.account.Provisioning) DistributionList(com.zimbra.cs.account.DistributionList)

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