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);
}
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());
}
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);
}
Aggregations