Search in sources :

Example 1 with ResetPassword

use of com.zimbra.cs.service.account.ResetPassword in project zm-mailbox by Zimbra.

the class TestResetPassword method testResetPassword.

@Test
public void testResetPassword() throws Exception {
    Provisioning prov = Provisioning.getInstance();
    Account acct1 = prov.getAccount(USER_NAME);
    acct1.setFeatureResetPasswordStatus(FeatureResetPasswordStatus.enabled);
    ResetPassword resetPassword = new TestResetPassword();
    Map<String, Object> ctxt = ServiceTestUtil.getRequestContext(acct1);
    ResetPasswordRequest resetReq = new ResetPasswordRequest();
    resetReq.setPassword(NEW_PASSWORD);
    Element request = JaxbUtil.jaxbToElement(resetReq);
    try {
        resetPassword.handle(request, ctxt);
    } catch (ServiceException se) {
        Assert.fail("This should not happen");
    }
}
Also used : ResetPassword(com.zimbra.cs.service.account.ResetPassword) Account(com.zimbra.cs.account.Account) ResetPasswordRequest(com.zimbra.soap.account.message.ResetPasswordRequest) ServiceException(com.zimbra.common.service.ServiceException) Element(com.zimbra.common.soap.Element) Provisioning(com.zimbra.cs.account.Provisioning) Test(org.junit.Test)

Example 2 with ResetPassword

use of com.zimbra.cs.service.account.ResetPassword in project zm-mailbox by Zimbra.

the class TestResetPassword method testResetPassword_FeatureDisabled.

@Test
public void testResetPassword_FeatureDisabled() throws Exception {
    Provisioning prov = Provisioning.getInstance();
    Account acct1 = prov.getAccount(USER_NAME);
    acct1.setFeatureResetPasswordStatus(FeatureResetPasswordStatus.enabled);
    ResetPassword resetPassword = new TestResetPassword();
    Map<String, Object> ctxt = ServiceTestUtil.getRequestContext(acct1);
    ResetPasswordRequest resetReq = new ResetPasswordRequest();
    resetReq.setPassword(NEW_PASSWORD);
    Element request = JaxbUtil.jaxbToElement(resetReq);
    try {
        resetPassword.handle(request, ctxt);
    } catch (ServiceException se) {
        Assert.assertEquals("permission denied: Reset password feature is disabled", se.getMessage());
    }
}
Also used : ResetPassword(com.zimbra.cs.service.account.ResetPassword) Account(com.zimbra.cs.account.Account) ResetPasswordRequest(com.zimbra.soap.account.message.ResetPasswordRequest) ServiceException(com.zimbra.common.service.ServiceException) Element(com.zimbra.common.soap.Element) Provisioning(com.zimbra.cs.account.Provisioning) Test(org.junit.Test)

Aggregations

ServiceException (com.zimbra.common.service.ServiceException)2 Element (com.zimbra.common.soap.Element)2 Account (com.zimbra.cs.account.Account)2 Provisioning (com.zimbra.cs.account.Provisioning)2 ResetPassword (com.zimbra.cs.service.account.ResetPassword)2 ResetPasswordRequest (com.zimbra.soap.account.message.ResetPasswordRequest)2 Test (org.junit.Test)2