use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.
the class TestDelegatedDL method hideInGal.
@Test
@Bug(bug = 66234)
public void hideInGal() throws Exception {
// setup GAL sync account
GalTestUtil.enableGalSyncAccount(prov, domain.getName());
String GROUP_NAME = getAddress(genGroupNameLocalPart("group"));
Multimap<String, String> attrs = ArrayListMultimap.create();
attrs.put(Provisioning.A_zimbraHideInGal, ProvisioningConstants.TRUE);
// create an owner account
Account ownerAcct = provUtil.createAccount(genAcctNameLocalPart("owner"), domain);
Group group = createGroupAndAddOwner(GROUP_NAME, attrs, ownerAcct.getName());
// create member accounts and add it to the group
Account memberAcct1 = provUtil.createAccount(genAcctNameLocalPart("member1"), domain);
Account memberAcct2 = provUtil.createAccount(genAcctNameLocalPart("member2"), domain);
Account memberAcct3 = provUtil.createAccount(genAcctNameLocalPart("member3"), domain);
prov.addGroupMembers(group, new String[] { memberAcct3.getName(), memberAcct2.getName(), memberAcct1.getName() });
// create a non-member account
Account nonMemberAcct = provUtil.createAccount(genAcctNameLocalPart("non-member"), domain);
/*
* Owners should be able to see members even when the list is hideInGal
*/
// auth as the owner
SoapTransport transport = authUser(ownerAcct.getName());
GetDistributionListMembersRequest req = new GetDistributionListMembersRequest(null, null, group.getName());
GetDistributionListMembersResponse resp = invokeJaxb(transport, req);
List<String> members = resp.getDlMembers();
//make sure members are returned sorted
Verify.verifyEquals(Lists.newArrayList(memberAcct1.getName(), memberAcct2.getName(), memberAcct3.getName()), members);
// add another member, verify cache is updated
Account memberAcct4 = provUtil.createAccount(genAcctNameLocalPart("member4"), domain);
prov.addGroupMembers(group, new String[] { memberAcct4.getName() });
resp = invokeJaxb(transport, req);
members = resp.getDlMembers();
Verify.verifyEquals(Lists.newArrayList(memberAcct1.getName(), memberAcct2.getName(), memberAcct3.getName(), memberAcct4.getName()), members);
String errorCode = null;
/*
* non owner cannot see members when the list is hideInGal
*/
transport = authUser(memberAcct1.getName());
errorCode = null;
try {
invokeJaxb(transport, req);
} catch (ServiceException e) {
errorCode = e.getCode();
}
assertEquals(AccountServiceException.NO_SUCH_DISTRIBUTION_LIST, errorCode);
/*
* non owner cannot see members when the list is hideInGal
*/
transport = authUser(nonMemberAcct.getName());
errorCode = null;
try {
invokeJaxb(transport, req);
} catch (ServiceException e) {
errorCode = e.getCode();
}
assertEquals(AccountServiceException.NO_SUCH_DISTRIBUTION_LIST, errorCode);
GalTestUtil.disableGalSyncAccount(prov, domain.getName());
provUtil.deleteAccount(ownerAcct);
provUtil.deleteAccount(memberAcct1);
provUtil.deleteAccount(memberAcct2);
provUtil.deleteAccount(memberAcct3);
provUtil.deleteAccount(memberAcct4);
provUtil.deleteAccount(nonMemberAcct);
provUtil.deleteGroup(group);
}
use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.
the class TestDelegatedDL method distributionListActionDelete.
@Test
public void distributionListActionDelete() throws Exception {
// create a group for the delete test
String NAME = getAddress(genGroupNameLocalPart());
Group group = createGroupAndAddOwner(NAME);
SoapTransport transport = authUser(USER_OWNER);
DistributionListAction action = new DistributionListAction(Operation.delete);
DistributionListActionRequest req = new DistributionListActionRequest(DistributionListSelector.fromName(NAME), action);
DistributionListActionResponse resp;
String errorCode = null;
try {
// only people with create right and owner right can delete
resp = invokeJaxb(transport, req);
} catch (ServiceException e) {
errorCode = e.getCode();
}
assertEquals(ServiceException.PERM_DENIED, errorCode);
/*
* auth as creator and try again, should still fail
*/
transport = authUser(USER_CREATOR);
errorCode = null;
try {
resp = invokeJaxb(transport, req);
} catch (ServiceException e) {
errorCode = e.getCode();
}
assertEquals(ServiceException.PERM_DENIED, errorCode);
// make the creator an owner
transport = authUser(USER_OWNER);
addOwner(transport, group.getName(), USER_CREATOR);
// now try delete as the creator (also an owner now), should succeed
transport = authUser(USER_CREATOR);
resp = invokeJaxb(transport, req);
group = prov.getGroup(Key.DistributionListBy.name, NAME);
assertNull(null);
}
use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.
the class TestCsrfRequest method getCreateSigWithAuthAndCsrfDisabled.
@Test
public void getCreateSigWithAuthAndCsrfDisabled() 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);
}
}
use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.
the class TestCsrfRequest method getCreateSigWithAuthAndCsrfEnabledNoCsrfToken.
@Test
public void getCreateSigWithAuthAndCsrfEnabledNoCsrfToken() throws Exception {
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);
} 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 TestCsrfRequest method getCreateSigWithAuthAndCsrfEnabledAndCsrfToken.
@Test
public void getCreateSigWithAuthAndCsrfEnabledAndCsrfToken() throws Exception {
Account acct = provUtil.createAccount(genAcctNameLocalPart(), domain);
boolean csrfEnabled = Boolean.TRUE;
SoapTransport transport = authUser(acct.getName(), csrfEnabled, Boolean.TRUE);
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) {
assertNull(e);
}
}
Aggregations