use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.
the class TestCheckRights method grantRight.
private void grantRight(Account target, GranteeType granteeType, NamedEntry grantee, String right) throws Exception {
SoapTransport transport = authUser(target.getName());
GrantRightsRequest req = new GrantRightsRequest();
AccountACEInfo ace = new AccountACEInfo(granteeType, right);
ace.setZimbraId(grantee.getId());
req.addAce(ace);
GrantRightsResponse resp = invokeJaxb(transport, req);
}
use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.
the class TestCsrfRequest method getCreateSigWithCsrfFeatureDisbaledAndAuthTokenIsCsrfEnabled.
@Test
public void getCreateSigWithCsrfFeatureDisbaledAndAuthTokenIsCsrfEnabled() throws Exception {
Map<String, Object> attrs = new HashMap<String, Object>();
attrs.put(Provisioning.A_zimbraCsrfTokenCheckEnabled, "FALSE");
prov.modifyAttrs(prov.getConfig(), attrs, true);
Account acct = provUtil.createAccount(genAcctNameLocalPart(), domain);
boolean csrfEnabled = Boolean.TRUE;
SoapTransport transport = authUser(acct.getName(), csrfEnabled, Boolean.FALSE);
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");
assertNotNull(sigt);
} catch (SoapFaultException e) {
e.printStackTrace();
assertNull(e);
}
}
use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.
the class TestDiscoverRights method displayName.
/*
* verify display name is returned in DiscoverRights and discovered targets
* are sorted by displayName
*/
@Test
@Bug(bug = 68225)
public void displayName() throws Exception {
Account acct = provUtil.createAccount(genAcctNameLocalPart(), domain);
String GROUP_1_NAME = getAddress(genGroupNameLocalPart("1"));
String GROUP_1_DISPLAY_NAME = "third";
String GROUP_2_NAME = getAddress(genGroupNameLocalPart("2"));
String GROUP_2_DISPLAY_NAME = "first";
String GROUP_3_NAME = getAddress(genGroupNameLocalPart("3"));
String GROUP_3_DISPLAY_NAME = "first";
Group group1 = provUtil.createGroup(GROUP_1_NAME, Collections.singletonMap(Provisioning.A_displayName, (Object) GROUP_1_DISPLAY_NAME), false);
Group group2 = provUtil.createGroup(GROUP_2_NAME, Collections.singletonMap(Provisioning.A_displayName, (Object) GROUP_2_DISPLAY_NAME), false);
Group group3 = provUtil.createGroup(GROUP_3_NAME, Collections.singletonMap(Provisioning.A_displayName, (Object) GROUP_3_DISPLAY_NAME), false);
String RIGHT_NAME = User.R_ownDistList.getName();
prov.grantRight(TargetType.dl.getCode(), TargetBy.name, group1.getName(), GranteeType.GT_USER.getCode(), GranteeBy.name, acct.getName(), null, RIGHT_NAME, null);
prov.grantRight(TargetType.dl.getCode(), TargetBy.name, group2.getName(), GranteeType.GT_USER.getCode(), GranteeBy.name, acct.getName(), null, RIGHT_NAME, null);
prov.grantRight(TargetType.dl.getCode(), TargetBy.name, group3.getName(), GranteeType.GT_USER.getCode(), GranteeBy.name, acct.getName(), null, RIGHT_NAME, null);
SoapTransport transport = authUser(acct.getName());
DiscoverRightsRequest req = new DiscoverRightsRequest(Collections.singletonList(RIGHT_NAME));
DiscoverRightsResponse resp = invokeJaxb(transport, req);
List<DiscoverRightsInfo> rightsInfo = resp.getDiscoveredRights();
assertEquals(1, rightsInfo.size());
List<String> result = Lists.newArrayList();
for (DiscoverRightsInfo rightInfo : rightsInfo) {
List<DiscoverRightsTarget> targets = rightInfo.getTargets();
for (DiscoverRightsTarget target : targets) {
String id = target.getId();
String name = target.getName();
String displayName = target.getDisplayName();
result.add(Verify.makeResultStr(id, name, displayName));
}
}
// result should be sorted by displayName.
// If displayName are the same, sorted by entry.getLabel()
Verify.verifyEquals(Lists.newArrayList(Verify.makeResultStr(group2.getId(), group2.getName(), group2.getDisplayName()), Verify.makeResultStr(group3.getId(), group3.getName(), group3.getDisplayName()), Verify.makeResultStr(group1.getId(), group1.getName(), group1.getDisplayName())), result);
}
use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.
the class TestGetSignature method getSignature.
@Test
public void getSignature() throws Exception {
Account acct = provUtil.createAccount(genAcctNameLocalPart(), domain);
boolean csrfEnabled = Boolean.FALSE;
SoapTransport transport = authUser(acct.getName(), csrfEnabled, Boolean.FALSE);
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");
assertNotNull(sigt);
} catch (SoapFaultException e) {
e.printStackTrace();
assertNull(e);
}
GetSignaturesRequest getSigReq = new GetSignaturesRequest();
sigReq = JaxbUtil.jaxbToElement(getSigReq, proto.getFactory());
try {
Element element = transport.invoke(sigReq, false, false, null);
String sigtContent = element.getElement("signature").getElement("content").getText();
assertNotNull(sigContent);
int index = sigtContent.indexOf("alert(\"XSS\")");
Assert.assertEquals(-1, index);
} catch (SoapFaultException e) {
e.printStackTrace();
assertNull(e);
}
}
use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.
the class TestSearchGal method searchWithOffsetLimit.
private void searchWithOffsetLimit(boolean ldap, String domainName) throws Exception {
SoapTransport transport = authUser(TestUtil.getAddress(AUTHED_USER, domainName));
Element request = Element.create(transport.getRequestProtocol(), AccountConstants.SEARCH_GAL_REQUEST);
request.addElement(AccountConstants.E_NAME).setText(".");
int offset = 5;
int limit = 3;
request.addAttribute(MailConstants.A_QUERY_OFFSET, offset);
request.addAttribute(MailConstants.A_QUERY_LIMIT, limit);
request.addAttribute(MailConstants.A_SORTBY, "nameAsc");
Element response = transport.invoke(request);
boolean paginationSupported = response.getAttributeBool(AccountConstants.A_PAGINATION_SUPPORTED);
List<GalContact> result = new ArrayList<GalContact>();
for (Element e : response.listElements(AdminConstants.E_CN)) {
result.add(new GalContact(AdminConstants.A_ID, SoapProvisioning.getAttrs(e)));
}
if (ldap) {
// pagination is not supported
assertFalse(paginationSupported);
// limit is ignored, ldap search is limited by zimbraGalMaxResults
// should find all objects, plus the authed user
assertEquals(NUM_ALL_OBJECTS + 1, result.size());
} else {
// pagination is supported
assertTrue(paginationSupported);
assertEquals(limit, result.size());
for (int i = 0; i < limit; i++) {
assertEquals(getAcctEmail(offset + i, domainName), result.get(i).getSingleAttr(ContactConstants.A_email));
}
}
}
Aggregations