Search in sources :

Example 76 with Config

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

the class TestProvAlias method testAliasDomain_Case3.

/*
        Case 3:
            Alias1@aliasdomain.com points at account1@localdomain.com.  (there is no alias1@localdomain.com alias)
            Global config zimbra default domain is set to localdomain.com.
            Auth is attempted with "alias1".  Does it work?  NO
            
    */
@Test
public void testAliasDomain_Case3() throws Exception {
    String testName = getTestName();
    String acctLocalPart = "account1";
    String acctName = getEmail(acctLocalPart, LOCAL_DOMAIN_NAME, testName);
    String aliasLocalPart = "alias1";
    String aliasName = getEmail(aliasLocalPart, ALIAS_DOMAIN_NAME, testName);
    Config config = prov.getConfig();
    String origDefaltDomainName = config.getAttr(Provisioning.A_zimbraDefaultDomainName);
    Map<String, Object> attrs = new HashMap<String, Object>();
    attrs.put(Provisioning.A_zimbraDefaultDomainName, LOCAL_DOMAIN_NAME);
    prov.modifyAttrs(config, attrs);
    Account acct = prov.createAccount(acctName, PASSWORD, null);
    prov.addAlias(acct, aliasName);
    String authAs = getLocalPart(aliasLocalPart, testName);
    Account acctGot = prov.get(AccountBy.name, authAs);
    assertNull(acctGot);
    // put the orig back
    attrs.clear();
    attrs.put(Provisioning.A_zimbraDefaultDomainName, "");
    prov.modifyAttrs(config, attrs);
}
Also used : Account(com.zimbra.cs.account.Account) HashMap(java.util.HashMap) Config(com.zimbra.cs.account.Config)

Example 77 with Config

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

the class TestProvAlias method cleanup.

@AfterClass
public static void cleanup() throws Exception {
    Config config = prov.getConfig();
    Map<String, Object> attrs = new HashMap<String, Object>();
    attrs.put(Provisioning.A_zimbraDefaultDomainName, origDefaultDomainName);
    prov.modifyAttrs(config, attrs);
    Cleanup.deleteAll(baseDomainName());
}
Also used : HashMap(java.util.HashMap) Config(com.zimbra.cs.account.Config)

Example 78 with Config

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

the class TestProvIDN method testDomainInvalidNames.

@Test
public void testDomainInvalidNames() throws Exception {
    Config config = prov.getConfig();
    // save he current value of zimbraAllowNonLDHCharsInDomain
    String curAllowNonLDH = config.getAttr(Provisioning.A_zimbraAllowNonLDHCharsInDomain);
    // test values
    String goodEnglish = "good" + "." + BASE_DOMAIN_NAME;
    String goodIDN = makeTestDomainName("good");
    String LDHEnglish_comma = "ldh'ldh" + "." + BASE_DOMAIN_NAME;
    String LDHIDN_comma = makeTestDomainName("ldh'ldh");
    // when zimbraAllowNonLDHCharsInDomain is TRUE
    Map<String, Object> attrs = new HashMap<String, Object>();
    attrs.put(Provisioning.A_zimbraAllowNonLDHCharsInDomain, ProvisioningConstants.TRUE);
    prov.modifyAttrs(config, attrs);
    // so that we don't run into domain exist problem
    String prefix = "allowtest.";
    doTestInvalidNames(prefix + goodEnglish, true);
    doTestInvalidNames(prefix + goodIDN, true);
    // test failed. javamail does not allow it anymore, fix? bug 41123
    doTestInvalidNames(prefix + LDHEnglish_comma, true);
    // test failed. javamail does not allow it anymore. fix? bug 41123
    doTestInvalidNames(prefix + LDHIDN_comma, true);
    // when zimbraAllowNonLDHCharsInDomain is FALSE
    attrs.clear();
    attrs.put(Provisioning.A_zimbraAllowNonLDHCharsInDomain, ProvisioningConstants.FALSE);
    prov.modifyAttrs(config, attrs);
    prefix = "notallowtest.";
    doTestInvalidNames(prefix + goodEnglish, true);
    doTestInvalidNames(prefix + goodIDN, true);
    doTestInvalidNames(prefix + LDHEnglish_comma, false);
    doTestInvalidNames(prefix + LDHIDN_comma, false);
    // restore the orig config value back
    attrs.clear();
    attrs.put(Provisioning.A_zimbraAllowNonLDHCharsInDomain, curAllowNonLDH);
    prov.modifyAttrs(config, attrs);
}
Also used : HashMap(java.util.HashMap) Config(com.zimbra.cs.account.Config) Test(org.junit.Test)

Aggregations

Config (com.zimbra.cs.account.Config)78 HashMap (java.util.HashMap)24 Test (org.junit.Test)11 Provisioning (com.zimbra.cs.account.Provisioning)10 ServiceException (com.zimbra.common.service.ServiceException)9 Account (com.zimbra.cs.account.Account)7 RetentionPolicy (com.zimbra.soap.mail.type.RetentionPolicy)7 Element (com.zimbra.common.soap.Element)6 Policy (com.zimbra.soap.mail.type.Policy)6 Cos (com.zimbra.cs.account.Cos)5 Server (com.zimbra.cs.account.Server)5 Domain (com.zimbra.cs.account.Domain)4 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)4 Pair (com.zimbra.common.util.Pair)3 HashSet (java.util.HashSet)3 SMTPMessage (com.sun.mail.smtp.SMTPMessage)2 ZFilterAction (com.zimbra.client.ZFilterAction)2 ZFileIntoAction (com.zimbra.client.ZFilterAction.ZFileIntoAction)2 ZFilterCondition (com.zimbra.client.ZFilterCondition)2 ZHeaderCondition (com.zimbra.client.ZFilterCondition.ZHeaderCondition)2