use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.
the class TestDiscoverRights method granteeAll.
@Test
public void granteeAll() throws Exception {
Domain testDomain = provUtil.createDomain(genDomainName(domain.getName()));
Account acct = provUtil.createAccount(genAcctNameLocalPart(), testDomain);
String RIGHT_NAME = Right.RT_createDistList;
prov.grantRight(TargetType.domain.getCode(), TargetBy.name, testDomain.getName(), GranteeType.GT_AUTHUSER.getCode(), null, null, 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();
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();
result.add(Verify.makeResultStr(id, name));
}
}
Verify.verifyEquals(Lists.newArrayList(Verify.makeResultStr(testDomain.getId(), testDomain.getName())), result);
provUtil.deleteAccount(acct);
provUtil.deleteDomain(testDomain);
}
use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.
the class TestGetSignature method getSignaturePlainSig.
@Test
public void getSignaturePlainSig() 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/plain");
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.assertTrue(index > -1);
} catch (SoapFaultException e) {
e.printStackTrace();
assertNull(e);
}
}
use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.
the class GalTestUtil method createAndSyncGalSyncAccount.
static void createAndSyncGalSyncAccount(String galSyncAcctName, String domainName, GSAType type) throws Exception {
String dataSourceName;
String dataSourceType;
String folderName;
if (type == GSAType.zimbra || type == GSAType.both) {
dataSourceName = "zimbra";
dataSourceType = "zimbra";
folderName = "zimbra-gal-contacts";
} else {
dataSourceName = "external";
dataSourceType = "ldap";
folderName = "external-gal-contacts";
}
SoapTransport transport = TestUtil.getAdminSoapTransport();
//
// create gal sync account and data sources, then force sync
//
String gsaZimbraId = GalTestUtil.createGalSyncAccountOrDataSource(transport, galSyncAcctName, domainName, dataSourceName, dataSourceType, folderName);
GalTestUtil.syncGASDataSource(transport, gsaZimbraId, dataSourceName);
if (type == GSAType.both) {
dataSourceName = "external";
dataSourceType = "ldap";
folderName = "external-gal-contacts";
GalTestUtil.createGalSyncAccountOrDataSource(transport, galSyncAcctName, domainName, dataSourceName, dataSourceType, folderName);
GalTestUtil.syncGASDataSource(transport, gsaZimbraId, dataSourceName);
}
//
// index the gal sync account (otherwise the first search will fail)
//
Element eReIndex = Element.create(transport.getRequestProtocol(), AdminConstants.REINDEX_REQUEST);
eReIndex.addAttribute(AdminConstants.A_ACTION, "start");
Element eMbox = eReIndex.addElement(AdminConstants.E_MAILBOX);
eMbox.addAttribute(AdminConstants.A_ID, gsaZimbraId);
transport.invoke(eReIndex);
// wait for the reindex to finish
Thread.sleep(2000);
}
use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.
the class TestAuth method soapByCookie.
@Test
public void soapByCookie() throws Exception {
boolean isAdmin = false;
String USER_NAME = TestUtil.getAddress("user1");
String authToken = getAuthToken(USER_NAME, isAdmin);
Element req = Element.create(SoapProtocol.Soap12, AccountConstants.GET_INFO_REQUEST);
SoapTransport transport = new AuthTokenInCookieTransport(authToken, isAdmin);
Element resp = transport.invoke(req);
Element eName = resp.getElement(AccountConstants.E_NAME);
String value = eName.getText();
assertEquals(USER_NAME, value);
}
Aggregations