use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.
the class TestDLMembership method testRemoveMemberByAlias.
@Test
public void testRemoveMemberByAlias() {
SoapTransport transport;
try {
transport = TestUtil.getAdminSoapTransport();
// add an alias to the account
AddAccountAliasResponse addAliasResp = SoapTest.invokeJaxb(transport, new AddAccountAliasRequest(testUser.getId(), TestUtil.getAddress(TEST_ALIAS)));
assertNotNull("AddAccountAliasResponse cannot be null", addAliasResp);
Account acct = Provisioning.getInstance().getAccount(testUser.getId());
assertNotNull(acct);
assertNotNull("account's aliases are null", acct.getAliases());
assertEquals("account has no aliases", acct.getAliases().length, 1);
// add account to DL by alias
AddDistributionListMemberResponse addDLMemberResp = SoapTest.invokeJaxb(transport, new AddDistributionListMemberRequest(testDL.getId(), Collections.singleton(TestUtil.getAddress(TEST_ALIAS))));
assertNotNull("AddDistributionListMemberResponse cannot be null", addDLMemberResp);
// verify that account is a member of the DL
ArrayList<DistributionList> result = new ArrayList<DistributionList>();
GetAccountMembershipResponse resp = SoapTest.invokeJaxb(transport, new GetAccountMembershipRequest(AccountSelector.fromName(TEST_USER)));
assertNotNull("GetAccountMembershipRequest cannot be null", resp);
List<DLInfo> dlInfoList = resp.getDlList();
assertTrue("Account is not a member of any DLs", dlInfoList.size() > 0);
assertEquals("Account should be a member of the test DL only", dlInfoList.get(0).getName(), testDL.getName());
// remove the account's alias from the DL
RemoveDistributionListMemberResponse rdlmresp = SoapTest.invokeJaxb(transport, new RemoveDistributionListMemberRequest(testDL.getId(), Arrays.asList(new String[] { TestUtil.getAddress(TEST_ALIAS) })));
assertNotNull("RemoveDistributionListMemberRequest cannot be null", rdlmresp);
// verify that account is NOT a member of the DL anymore
result = new ArrayList<DistributionList>();
resp = SoapTest.invokeJaxb(transport, new GetAccountMembershipRequest(AccountSelector.fromName(TEST_USER)));
assertNotNull("GetAccountMembershipRequest cannot be null", resp);
dlInfoList = resp.getDlList();
assertTrue("Account should not be a member of any DLs", dlInfoList.size() == 0);
} catch (Exception e) {
fail(e.getLocalizedMessage());
}
}
use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.
the class TestDLMembership method testAddMemberByName.
@Test
public void testAddMemberByName() {
SoapTransport transport;
try {
transport = TestUtil.getAdminSoapTransport();
// add a member by account name
AddDistributionListMemberResponse addDLMemberResp = SoapTest.invokeJaxb(transport, new AddDistributionListMemberRequest(testDL.getId(), Collections.singleton(testUser.getName())));
assertNotNull("AddDistributionListMemberResponse cannot be null", addDLMemberResp);
// verify that account is a member of the DL
ArrayList<DistributionList> result = new ArrayList<DistributionList>();
GetAccountMembershipResponse resp = SoapTest.invokeJaxb(transport, new GetAccountMembershipRequest(AccountSelector.fromName(TEST_USER)));
assertNotNull("GetAccountMembershipRequest cannot be null", resp);
List<DLInfo> dlInfoList = resp.getDlList();
assertTrue("Account is not a member of any DLs", dlInfoList.size() > 0);
assertEquals("Account should be a member of the test DL only", dlInfoList.get(0).getName(), testDL.getName());
} catch (Exception e) {
fail(e.getLocalizedMessage());
}
}
use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.
the class TestDLMembership method testRemoveMemberByName.
@Test
public void testRemoveMemberByName() {
SoapTransport transport;
try {
transport = TestUtil.getAdminSoapTransport();
// add an alias to the account
AddAccountAliasResponse addAliasResp = SoapTest.invokeJaxb(transport, new AddAccountAliasRequest(testUser.getId(), TestUtil.getAddress(TEST_ALIAS)));
assertNotNull("AddAccountAliasResponse cannot be null", addAliasResp);
Account acct = Provisioning.getInstance().getAccount(testUser.getId());
assertNotNull(acct);
assertNotNull("account's aliases are null", acct.getAliases());
assertEquals("account has no aliases", acct.getAliases().length, 1);
// add account to DL by alias
AddDistributionListMemberResponse addDLMemberResp = SoapTest.invokeJaxb(transport, new AddDistributionListMemberRequest(testDL.getId(), Collections.singleton(TestUtil.getAddress(TEST_ALIAS))));
assertNotNull("AddDistributionListMemberResponse cannot be null", addDLMemberResp);
// verify that account is a member of the DL
ArrayList<DistributionList> result = new ArrayList<DistributionList>();
GetAccountMembershipResponse resp = SoapTest.invokeJaxb(transport, new GetAccountMembershipRequest(AccountSelector.fromName(TEST_USER)));
assertNotNull("GetAccountMembershipRequest cannot be null", resp);
List<DLInfo> dlInfoList = resp.getDlList();
assertTrue("Account is not a member of any DLs", dlInfoList.size() > 0);
assertEquals("Account should be a member of the test DL only", dlInfoList.get(0).getName(), testDL.getName());
// remove the account's alias from the DL
RemoveDistributionListMemberResponse rdlmresp = SoapTest.invokeJaxb(transport, new RemoveDistributionListMemberRequest(testDL.getId(), null, Arrays.asList(new String[] { TestUtil.getAddress(TEST_USER) })));
assertNotNull("RemoveDistributionListMemberRequest cannot be null", rdlmresp);
// verify that account is NOT a member of the DL anymore
result = new ArrayList<DistributionList>();
resp = SoapTest.invokeJaxb(transport, new GetAccountMembershipRequest(AccountSelector.fromName(TEST_USER)));
assertNotNull("GetAccountMembershipRequest cannot be null", resp);
dlInfoList = resp.getDlList();
assertTrue("Account should not be a member of any DLs", dlInfoList.size() == 0);
} catch (Exception e) {
fail(e.getLocalizedMessage());
}
}
use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.
the class TestUtil method waitForSessions.
public static QueryWaitSetResponse waitForSessions(int numExpectedSessions, int numExpectedFolderInterests, int timeout_millis, String wsID, Server server) throws Exception {
QueryWaitSetResponse resp = null;
while (timeout_millis > 0) {
QueryWaitSetRequest req = new QueryWaitSetRequest(wsID);
SoapTransport transport = getAdminSoapTransport(server);
resp = JaxbUtil.elementToJaxb(transport.invoke(JaxbUtil.jaxbToElement(req)));
List<WaitSetInfo> wsInfoList = resp.getWaitsets();
assertFalse("Expecting to find a waitset", wsInfoList.isEmpty());
assertEquals("Expecting to find only one waitset", 1, wsInfoList.size());
WaitSetInfo wsInfo = wsInfoList.get(0);
assertEquals("Found wrong waitset", wsID, wsInfo.getWaitSetId());
List<SessionForWaitSet> sessions = wsInfo.getSessions();
if (sessions != null && numExpectedSessions > 0) {
if (sessions.size() == numExpectedSessions) {
int foundFolderInterests = 0;
for (SessionForWaitSet s : sessions) {
WaitSetSessionInfo sessionInfo = s.getWaitSetSession();
if (sessionInfo != null) {
foundFolderInterests += s.getWaitSetSession().getFolderInterestsAsSet().size();
}
}
if (foundFolderInterests == numExpectedFolderInterests) {
return resp;
}
}
} else if ((sessions == null || sessions.isEmpty()) && numExpectedSessions == 0) {
return resp;
}
try {
if (timeout_millis > 500) {
Thread.sleep(500);
timeout_millis = timeout_millis - 500;
} else {
Thread.sleep(timeout_millis);
timeout_millis = 0;
}
} catch (InterruptedException e) {
ZimbraLog.test.debug("sleep got interrupted", e);
}
}
return resp;
}
use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.
the class TestAccess method DeleteDataSource.
@Test
public void DeleteDataSource() throws Exception {
String dateSourceName = genDataSourceName(seq);
// create a data cource
SoapTransport transport = authUser(ACCT_NAME);
CreateDataSourceRequest createReq = buildCeateDataSourceRequest(dateSourceName);
CreateDataSourceResponse createResp = invokeJaxb(transport, createReq);
assertNotNull("CreateDataSourceResponse", createResp);
Pop3DataSourceNameOrId name = new Pop3DataSourceNameOrId();
name.setName(dateSourceName);
DeleteDataSourceRequest req = new DeleteDataSourceRequest();
req.addDataSource(name);
/*
DataSource ds = mProvAdmin.setup_createDataSource(this, role, perm, ACCT_1_EMAIL, dateSourceName);
XMLElement req = new XMLElement(MailConstants.DELETE_DATA_SOURCE_REQUEST);
Element dataSource = req.addElement(MailConstants.E_DS_POP3);
dataSource.addAttribute(MailConstants.A_ID, ds.getId());
*/
accessTest(Perm.PERM_SELF_ONLY, req);
}
Aggregations