Search in sources :

Example 6 with AttachmentIdAttrib

use of com.zimbra.soap.admin.type.AttachmentIdAttrib in project zm-mailbox by Zimbra.

the class TestDeployZimlet method testZipWithInvalidCharacter.

@Test
public void testZipWithInvalidCharacter() throws Exception {
    SoapHttpTransport transport = new SoapHttpTransport(TestUtil.getAdminSoapUrl());
    com.zimbra.soap.admin.message.AuthRequest authReq = new com.zimbra.soap.admin.message.AuthRequest(LC.zimbra_ldap_user.value(), LC.zimbra_ldap_password.value());
    authReq.setCsrfSupported(false);
    Element response = transport.invoke(JaxbUtil.jaxbToElement(authReq, SoapProtocol.SoapJS.getFactory()));
    com.zimbra.soap.admin.message.AuthResponse authResp = JaxbUtil.elementToJaxb(response);
    String authToken = authResp.getAuthToken();
    String aid = adminUpload(authToken, "jelmer.zip", "/opt/zimbra/unittest/zimlets/jelmer.zip");
    assertNotNull("Attachment ID should not be null", aid);
    AttachmentIdAttrib att = new AttachmentIdAttrib(aid);
    transport.setAdmin(true);
    transport.setAuthToken(authToken);
    DeployZimletRequest deployReq = new DeployZimletRequest(AdminConstants.A_DEPLOYLOCAL, false, true, att);
    Element req = JaxbUtil.jaxbToElement(deployReq);
    try {
        Element res = transport.invoke(req);
        JaxbUtil.elementToJaxb(res);
        fail("Should throw SoapFaultException");
    } catch (SoapFaultException e) {
    //expected
    }
}
Also used : Element(com.zimbra.common.soap.Element) SoapFaultException(com.zimbra.common.soap.SoapFaultException) DeployZimletRequest(com.zimbra.soap.admin.message.DeployZimletRequest) SoapHttpTransport(com.zimbra.common.soap.SoapHttpTransport) AttachmentIdAttrib(com.zimbra.soap.admin.type.AttachmentIdAttrib) Test(org.junit.Test)

Example 7 with AttachmentIdAttrib

use of com.zimbra.soap.admin.type.AttachmentIdAttrib in project zm-mailbox by Zimbra.

the class TestDeployZimlet method testBadAid.

@Test
public void testBadAid() throws Exception {
    SoapHttpTransport transport = new SoapHttpTransport(TestUtil.getAdminSoapUrl());
    com.zimbra.soap.admin.message.AuthRequest authReq = new com.zimbra.soap.admin.message.AuthRequest(LC.zimbra_ldap_user.value(), LC.zimbra_ldap_password.value());
    authReq.setCsrfSupported(false);
    Element response = transport.invoke(JaxbUtil.jaxbToElement(authReq, SoapProtocol.SoapJS.getFactory()));
    com.zimbra.soap.admin.message.AuthResponse authResp = JaxbUtil.elementToJaxb(response);
    String authToken = authResp.getAuthToken();
    AttachmentIdAttrib att = new AttachmentIdAttrib("invalidaid");
    transport.setAdmin(true);
    transport.setAuthToken(authToken);
    DeployZimletRequest deployReq = new DeployZimletRequest(AdminConstants.A_DEPLOYLOCAL, false, true, att);
    Element req = JaxbUtil.jaxbToElement(deployReq);
    try {
        Element res = transport.invoke(req);
        JaxbUtil.elementToJaxb(res);
        fail("Should throw SoapFaultException");
    } catch (SoapFaultException e) {
    //expected
    }
}
Also used : Element(com.zimbra.common.soap.Element) SoapFaultException(com.zimbra.common.soap.SoapFaultException) DeployZimletRequest(com.zimbra.soap.admin.message.DeployZimletRequest) SoapHttpTransport(com.zimbra.common.soap.SoapHttpTransport) AttachmentIdAttrib(com.zimbra.soap.admin.type.AttachmentIdAttrib) Test(org.junit.Test)

Example 8 with AttachmentIdAttrib

use of com.zimbra.soap.admin.type.AttachmentIdAttrib in project zm-mailbox by Zimbra.

the class TestDeployZimlet method testValidAdminExtension.

@Test
public void testValidAdminExtension() throws Exception {
    SoapHttpTransport transport = new SoapHttpTransport(TestUtil.getAdminSoapUrl());
    com.zimbra.soap.admin.message.AuthRequest authReq = new com.zimbra.soap.admin.message.AuthRequest(LC.zimbra_ldap_user.value(), LC.zimbra_ldap_password.value());
    authReq.setCsrfSupported(false);
    Element response = transport.invoke(JaxbUtil.jaxbToElement(authReq, SoapProtocol.SoapJS.getFactory()));
    com.zimbra.soap.admin.message.AuthResponse authResp = JaxbUtil.elementToJaxb(response);
    String authToken = authResp.getAuthToken();
    String aid = adminUpload(authToken, "adminextension.zip", "/opt/zimbra/unittest/zimlets/adminextension.zip");
    assertNotNull("Attachment ID should not be null", aid);
    AttachmentIdAttrib att = new AttachmentIdAttrib(aid);
    transport.setAdmin(true);
    transport.setAuthToken(authToken);
    DeployZimletRequest deployReq = new DeployZimletRequest(AdminConstants.A_DEPLOYLOCAL, false, true, att);
    Element req = JaxbUtil.jaxbToElement(deployReq);
    Element res = transport.invoke(req);
    DeployZimletResponse deployResp = JaxbUtil.elementToJaxb(res);
    assertNotNull(deployResp);
    String status = deployResp.getProgresses().get(0).getStatus();
    assertTrue("should be getting 'pending' or 'succeeded' status", status.equals(DeployZimlet.sPENDING) || status.equals(DeployZimlet.sSUCCEEDED));
    UndeployZimletRequest undeployReq = new UndeployZimletRequest("adminextension", AdminConstants.A_DEPLOYALL);
    req = JaxbUtil.jaxbToElement(undeployReq);
    res = transport.invoke(req);
    UndeployZimletResponse undeployResp = JaxbUtil.elementToJaxb(res);
    assertNotNull(undeployResp);
}
Also used : Element(com.zimbra.common.soap.Element) UndeployZimletRequest(com.zimbra.soap.admin.message.UndeployZimletRequest) DeployZimletResponse(com.zimbra.soap.admin.message.DeployZimletResponse) DeployZimletRequest(com.zimbra.soap.admin.message.DeployZimletRequest) UndeployZimletResponse(com.zimbra.soap.admin.message.UndeployZimletResponse) SoapHttpTransport(com.zimbra.common.soap.SoapHttpTransport) AttachmentIdAttrib(com.zimbra.soap.admin.type.AttachmentIdAttrib) Test(org.junit.Test)

Example 9 with AttachmentIdAttrib

use of com.zimbra.soap.admin.type.AttachmentIdAttrib in project zm-mailbox by Zimbra.

the class TestDeployZimlet method testZimletDelegatedAdmin.

@Test
public void testZimletDelegatedAdmin() throws Exception {
    SoapHttpTransport transport = new SoapHttpTransport(TestUtil.getAdminSoapUrl());
    com.zimbra.soap.admin.message.AuthRequest authReq = new com.zimbra.soap.admin.message.AuthRequest(delegatedAdmin.getName(), TestUtil.DEFAULT_PASSWORD);
    authReq.setCsrfSupported(false);
    Element response = transport.invoke(JaxbUtil.jaxbToElement(authReq, SoapProtocol.SoapJS.getFactory()));
    com.zimbra.soap.admin.message.AuthResponse authResp = JaxbUtil.elementToJaxb(response);
    String authToken = authResp.getAuthToken();
    String aid = adminUpload(authToken, "com_zimbra_mailarchive.zip", "/opt/zimbra/zimlets/com_zimbra_mailarchive.zip");
    assertNotNull("Attachment ID should not be null", aid);
    AttachmentIdAttrib att = new AttachmentIdAttrib(aid);
    transport.setAdmin(true);
    transport.setAuthToken(authToken);
    DeployZimletRequest deployReq = new DeployZimletRequest(AdminConstants.A_DEPLOYLOCAL, false, true, att);
    Element req = JaxbUtil.jaxbToElement(deployReq);
    Element res = transport.invoke(req);
    DeployZimletResponse deployResp = JaxbUtil.elementToJaxb(res);
    assertNotNull(deployResp);
    String status = deployResp.getProgresses().get(0).getStatus();
    assertTrue("should be getting 'pending' or 'succeeded' status", status.equals(DeployZimlet.sPENDING) || status.equals(DeployZimlet.sSUCCEEDED));
}
Also used : Element(com.zimbra.common.soap.Element) DeployZimletResponse(com.zimbra.soap.admin.message.DeployZimletResponse) DeployZimletRequest(com.zimbra.soap.admin.message.DeployZimletRequest) SoapHttpTransport(com.zimbra.common.soap.SoapHttpTransport) AttachmentIdAttrib(com.zimbra.soap.admin.type.AttachmentIdAttrib) Test(org.junit.Test)

Example 10 with AttachmentIdAttrib

use of com.zimbra.soap.admin.type.AttachmentIdAttrib in project zm-mailbox by Zimbra.

the class TestDeployZimlet method testPhilsZip.

@Test
public void testPhilsZip() throws Exception {
    SoapHttpTransport transport = new SoapHttpTransport(TestUtil.getAdminSoapUrl());
    com.zimbra.soap.admin.message.AuthRequest authReq = new com.zimbra.soap.admin.message.AuthRequest(LC.zimbra_ldap_user.value(), LC.zimbra_ldap_password.value());
    authReq.setCsrfSupported(false);
    Element response = transport.invoke(JaxbUtil.jaxbToElement(authReq, SoapProtocol.SoapJS.getFactory()));
    com.zimbra.soap.admin.message.AuthResponse authResp = JaxbUtil.elementToJaxb(response);
    String authToken = authResp.getAuthToken();
    String aid = adminUpload(authToken, "phil.zip", "/opt/zimbra/unittest/zimlets/phil.zip");
    assertNotNull("Attachment ID should not be null", aid);
    AttachmentIdAttrib att = new AttachmentIdAttrib(aid);
    transport.setAdmin(true);
    transport.setAuthToken(authToken);
    DeployZimletRequest deployReq = new DeployZimletRequest(AdminConstants.A_DEPLOYLOCAL, false, true, att);
    Element req = JaxbUtil.jaxbToElement(deployReq);
    try {
        Element res = transport.invoke(req);
        JaxbUtil.elementToJaxb(res);
        fail("Should throw SoapFaultException");
    } catch (SoapFaultException e) {
    //expected
    }
}
Also used : Element(com.zimbra.common.soap.Element) SoapFaultException(com.zimbra.common.soap.SoapFaultException) DeployZimletRequest(com.zimbra.soap.admin.message.DeployZimletRequest) SoapHttpTransport(com.zimbra.common.soap.SoapHttpTransport) AttachmentIdAttrib(com.zimbra.soap.admin.type.AttachmentIdAttrib) Test(org.junit.Test)

Aggregations

Element (com.zimbra.common.soap.Element)12 SoapHttpTransport (com.zimbra.common.soap.SoapHttpTransport)12 DeployZimletRequest (com.zimbra.soap.admin.message.DeployZimletRequest)12 AttachmentIdAttrib (com.zimbra.soap.admin.type.AttachmentIdAttrib)12 Test (org.junit.Test)12 SoapFaultException (com.zimbra.common.soap.SoapFaultException)9 DeployZimletResponse (com.zimbra.soap.admin.message.DeployZimletResponse)4 UndeployZimletRequest (com.zimbra.soap.admin.message.UndeployZimletRequest)1 UndeployZimletResponse (com.zimbra.soap.admin.message.UndeployZimletResponse)1 File (java.io.File)1