use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.
the class TestCsrfRequest method getCreateSigWithAuthAndCsrfEnabledAndInvalidCsrfToken.
@Test
public void getCreateSigWithAuthAndCsrfEnabledAndInvalidCsrfToken() throws Exception {
Map<String, Object> attrs = new HashMap<String, Object>();
attrs.put(Provisioning.A_zimbraCsrfTokenCheckEnabled, "TRUE");
prov.modifyAttrs(prov.getConfig(), attrs, true);
Account acct = provUtil.createAccount(genAcctNameLocalPart(), domain);
boolean csrfEnabled = Boolean.TRUE;
SoapTransport transport = authUser(acct.getName(), csrfEnabled, Boolean.TRUE);
String temp = transport.getCsrfToken().substring(7);
transport.setCsrfToken(temp);
String sigContent = "xss<script>alert(\"XSS\")</script><a href=javascript:alert(\"XSS\")><";
Signature sig = new Signature(null, "testSig", sigContent, "text/html");
CreateSignatureRequest req = new CreateSignatureRequest(sig);
SoapProtocol proto = SoapProtocol.Soap12;
Element sigReq = JaxbUtil.jaxbToElement(req, proto.getFactory());
try {
Element element = transport.invoke(sigReq, false, false, null);
String sigt = element.getElement("signature").getAttribute("id");
assertNull(sigt);
} catch (SoapFaultException e) {
assertNotNull(e);
Assert.assertEquals(true, e.getCode().contains("AUTH_REQUIRED"));
}
}
use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.
the class TestDelegatedDL method getDistributionList.
@Test
public void getDistributionList() throws Exception {
SoapTransport transport = authUser(USER_OWNER);
GetDistributionListRequest req = new GetDistributionListRequest(DistributionListSelector.fromName(DL_NAME), Boolean.TRUE);
GetDistributionListResponse resp = invokeJaxb(transport, req);
DistributionListInfo dlInfo = resp.getDl();
assertTrue(dlInfo.isOwner());
assertFalse(dlInfo.isMember());
String dlId = dlInfo.getId();
Group group = prov.getGroup(Key.DistributionListBy.name, DL_NAME);
assertNotNull(group);
assertEquals(group.getId(), dlId);
boolean seenMail = false;
boolean seenSubsPolicy = false;
boolean seenUnsubsPolicy = false;
List<? extends KeyValuePair> attrs = dlInfo.getAttrList();
for (KeyValuePair attr : attrs) {
String name = attr.getKey();
String value = attr.getValue();
if (Provisioning.A_mail.equals(name)) {
assertEquals(group.getName(), value);
seenMail = true;
}
if (Provisioning.A_zimbraDistributionListSubscriptionPolicy.equals(name)) {
assertEquals(ZAttrProvisioning.DistributionListSubscriptionPolicy.ACCEPT.name(), value);
seenSubsPolicy = true;
}
// zimbraAccount:GetDistributionListResponse should return the default value, instead of empty.
if (Provisioning.A_zimbraDistributionListUnsubscriptionPolicy.equals(name)) {
assertEquals(ZAttrProvisioning.DistributionListUnsubscriptionPolicy.REJECT.name(), value);
seenUnsubsPolicy = true;
}
}
assertTrue(seenMail);
assertTrue(seenSubsPolicy);
assertTrue(seenUnsubsPolicy);
List<? extends DistributionListGranteeInfoInterface> dlOwners = dlInfo.getOwners();
assertEquals(1, dlOwners.size());
for (DistributionListGranteeInfoInterface owner : dlOwners) {
com.zimbra.soap.type.GranteeType type = owner.getType();
String id = owner.getId();
String name = owner.getName();
assertEquals(com.zimbra.soap.type.GranteeType.usr, type);
assertEquals(USER_OWNER, name);
}
}
use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.
the class TestAutoProvision method attributeCallbackAutoProvPollingInterval.
@Test
public void attributeCallbackAutoProvPollingInterval() throws Exception {
Domain domain1 = createZimbraDomain(genDomainSegmentName("1"), null);
domain1.setAutoProvMode(Provisioning.AutoProvMode.EAGER);
Domain domain2 = createZimbraDomain(genDomainSegmentName("2"), null);
domain2.setAutoProvMode(Provisioning.AutoProvMode.EAGER);
Account admin = provUtil.createGlobalAdmin(genAcctNameLocalPart(), domain1);
SoapTransport transport = authAdmin(admin.getName());
/*
* verify auto prov thread is not running at the beginning
*/
verifyAutoProvTask(transport, Action.status, Status.idle);
/*
* schedule eager prov for domain1 and domain2 on server
*/
Server localServer = prov.getLocalServer();
localServer.setAutoProvScheduledDomains(new String[] { domain1.getName(), domain2.getName() });
/*
* verify auto prov thread is now running, because at last one domain is scheduled
*/
verifyAutoProvTask(transport, Action.status, Status.running);
/*
* set polling interval to 0, verify the auth prov thread is not running
*/
// remember cur value and set it back after the test
String curPollingInterval = localServer.getAutoProvPollingIntervalAsString();
localServer.setAutoProvPollingInterval("0");
verifyAutoProvTask(transport, Action.status, Status.idle);
/*
* done test, clean all data on the server
*/
localServer.unsetAutoProvScheduledDomains();
localServer.setAutoProvPollingInterval(curPollingInterval);
Verify.verifyEquals(new HashSet<String>(), localServer.getAutoProvScheduledDomains());
assertEquals(curPollingInterval, localServer.getAutoProvPollingIntervalAsString());
}
use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.
the class TestAutoProvision method revertAllToDefault.
// put everything back, in case the test did not run through previously
private static void revertAllToDefault() throws Exception {
SoapTransport transport = authZimbraAdmin();
modifyLocalconfigAndReload(transport, LC.autoprov_initial_sleep_ms, DEFAULT_AUTOPROV_INITIAL_SLEEP_MS);
Server localServer = prov.getLocalServer();
localServer.setAutoProvPollingInterval(DEFAULT_AUTOPROV_POLLING_INTERVAL);
localServer.unsetAutoProvScheduledDomains();
}
use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.
the class TestAutoProvision method autoProvTaskControl.
@Test
public void autoProvTaskControl() throws Exception {
Domain domain = createZimbraDomain(genDomainSegmentName(), null);
Account admin = provUtil.createGlobalAdmin(genAcctNameLocalPart(), domain);
SoapTransport transport = authAdmin(admin.getName());
/*
* verify auto prov thread is not running at the beginning
*/
verifyAutoProvTask(transport, Action.status, Status.idle);
/*
* force start the auto prov thread, verify it is started
*/
verifyAutoProvTask(transport, Action.start, Status.started);
verifyAutoProvTask(transport, Action.status, Status.running);
/*
* force stop the auot prov thread, verify it is stopped
*/
verifyAutoProvTask(transport, Action.stop, Status.stopped);
verifyAutoProvTask(transport, Action.status, Status.idle);
}
Aggregations