Search in sources :

Example 71 with SoapTransport

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);
}
Also used : Element(com.zimbra.common.soap.Element) SoapTransport(com.zimbra.common.soap.SoapTransport) Test(org.junit.Test)

Example 72 with SoapTransport

use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.

the class TestAuthentication method testAdminAuthViaSOAPToken.

/**
     * test admin auth request with authtoken in SOAP instead of login/password
     * @throws Exception
     */
public void testAdminAuthViaSOAPToken() throws Exception {
    AuthToken at = AuthProvider.getAdminAuthToken();
    SoapTransport transport = TestUtil.getAdminSoapTransport();
    com.zimbra.soap.admin.message.AuthRequest req = new com.zimbra.soap.admin.message.AuthRequest();
    req.setAuthToken(at.getEncoded());
    Element resp = transport.invoke(JaxbUtil.jaxbToElement(req, SoapProtocol.SoapJS.getFactory()));
    com.zimbra.soap.admin.message.AuthResponse authResp = JaxbUtil.elementToJaxb(resp);
    String newAuthToken = authResp.getAuthToken();
    assertNotNull("should have received a new authtoken", newAuthToken);
    at = ZimbraAuthToken.getAuthToken(newAuthToken);
    assertTrue("new auth token should be registered", at.isRegistered());
    assertFalse("new auth token should not be expired yet", at.isExpired());
}
Also used : AuthRequest(com.zimbra.soap.account.message.AuthRequest) Element(com.zimbra.common.soap.Element) ZimbraAuthToken(com.zimbra.cs.account.ZimbraAuthToken) AuthToken(com.zimbra.cs.account.AuthToken) SoapTransport(com.zimbra.common.soap.SoapTransport)

Example 73 with SoapTransport

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);
}
Also used : Account(com.zimbra.cs.account.Account) DiscoverRightsRequest(com.zimbra.soap.account.message.DiscoverRightsRequest) DiscoverRightsInfo(com.zimbra.soap.account.type.DiscoverRightsInfo) DiscoverRightsResponse(com.zimbra.soap.account.message.DiscoverRightsResponse) DiscoverRightsTarget(com.zimbra.soap.account.type.DiscoverRightsTarget) Domain(com.zimbra.cs.account.Domain) SoapTransport(com.zimbra.common.soap.SoapTransport) Test(org.junit.Test)

Example 74 with SoapTransport

use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.

the class TestExpandGroupInfo method searchConversation.

@Test
public void searchConversation() throws Exception {
    // send a to acct, recipient is a group
    String SUBJECT = getTestName();
    sendMsg(acct, group.getName(), SUBJECT, "blah");
    SoapTransport transport = authUser(acct.getName());
    SearchRequest searchReq = new SearchRequest();
    searchReq.setSearchTypes(MailItem.Type.CONVERSATION.toString());
    searchReq.setQuery(String.format("in:inbox and subject:%s", SUBJECT));
    SearchResponse searchResp = invokeJaxb(transport, searchReq);
    List<SearchHit> searchHits = searchResp.getSearchHits();
    assertEquals(1, searchHits.size());
    SearchHit searchHit = searchHits.get(0);
    String convId = searchHit.getId();
    SearchConvRequest searchConvReq = new SearchConvRequest(convId);
    searchConvReq.setNeedCanExpand(Boolean.TRUE);
    searchConvReq.setFetch(SearchParams.ExpandResults.ALL.toString());
    SearchConvResponse searchConvResp = invokeJaxb(transport, searchConvReq);
    List<MessageHitInfo> hits = searchConvResp.getMessages();
    // 2 - one in inbox, one in sent folder
    assertEquals(2, hits.size());
    verifyGroupInfo(hits.get(0), Boolean.TRUE, Boolean.TRUE);
    verifyGroupInfo(hits.get(1), Boolean.TRUE, Boolean.TRUE);
}
Also used : SearchConvResponse(com.zimbra.soap.mail.message.SearchConvResponse) SearchRequest(com.zimbra.soap.mail.message.SearchRequest) SearchHit(com.zimbra.soap.type.SearchHit) SearchConvRequest(com.zimbra.soap.mail.message.SearchConvRequest) MessageHitInfo(com.zimbra.soap.mail.type.MessageHitInfo) SoapTransport(com.zimbra.common.soap.SoapTransport) SearchResponse(com.zimbra.soap.mail.message.SearchResponse) Test(org.junit.Test)

Example 75 with SoapTransport

use of com.zimbra.common.soap.SoapTransport in project zm-mailbox by Zimbra.

the class TestExpandGroupInfo method createAppt.

private String createAppt(Account authAcct, String toAddress, String subject, String content) throws Exception {
    SoapTransport transport = authUser(authAcct.getName());
    Msg msg = new Msg();
    EmailAddrInfo toAddr = new EmailAddrInfo(toAddress);
    toAddr.setAddressType(EmailType.TO.toString());
    msg.addEmailAddress(toAddr);
    msg.setSubject(subject);
    MimePartInfo mp = new MimePartInfo();
    mp.setContentType("multipart/alternative");
    MimePartInfo mpSub = new MimePartInfo();
    mpSub.setContent(content);
    mp.addMimePart(mpSub);
    msg.setMimePart(mp);
    InvitationInfo invite = new InvitationInfo();
    InviteComponent invComp = new InviteComponent(ZCalendar.ICalTok.REQUEST.name(), 0, false);
    CalOrganizer organizer = new CalOrganizer();
    organizer.setAddress(authAcct.getName());
    CalendarAttendee attendee = new CalendarAttendee();
    attendee.setAddress(toAddress);
    invComp.setOrganizer(organizer);
    invComp.addAttendee(attendee);
    invComp.setDtStart(new DtTimeInfo("20120101"));
    invComp.setDtEnd(new DtTimeInfo("20120102"));
    invite.setInviteComponent(invComp);
    msg.setInvite(invite);
    CreateAppointmentRequest req = new CreateAppointmentRequest();
    req.setMsg(msg);
    CreateAppointmentResponse resp = invokeJaxb(transport, req);
    /*
        String calItemId = resp.getCalItemId();
        return calItemId;
        */
    String invId = resp.getCalInvId();
    return invId;
/*
           <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
           <soap:Header>
               <context xmlns="urn:zimbra">
               <userAgent xmlns="" name="ZimbraWebClient - FF10 (Mac)" version="0.0"/>
               <session xmlns="" id="14"/>
               <account xmlns="" by="name">user1@phoebe.mbp</account>
               <format xmlns="" type="js"/>
               </context>
           </soap:Header>

           <soap:Body>
           <CreateAppointmentRequest xmlns="urn:zimbraMail">
               <m xmlns="" l="10">
                   <inv>
                       <comp status="CONF" fb="B" class="PUB" transp="O" draft="0" allDay="0" name="test" loc="">
                           <at role="REQ" ptst="NE" rsvp="1" a="user2@phoebe.mbp"/>
                           <at role="REQ" ptst="NE" rsvp="1" a="user3@phoebe.mbp"/>
                           <s tz="America/Los_Angeles" d="20120227T080000"/>
                           <e tz="America/Los_Angeles" d="20120227T083000"/>
                           <or a="user1@phoebe.mbp" d="Demo User One"/>
                           <alarm action="DISPLAY">
                               <trigger>
                                   <rel m="5" related="START" neg="1"/>
                               </trigger>
                           </alarm>
                       </comp>
                   </inv>

                   <e a="user2@phoebe.mbp" t="t"/>
                   <e a="user3@phoebe.mbp" t="t"/>

                   <su>test</su>

                   <mp ct="multipart/alternative">
                       <mp ct="text/plain">
                           <content>The following is a new meeting request: Subject: test Organizer: "Demo User One" &lt;user1@phoebe.mbp&gt; Time: Monday, February 27, 2012, 8:00:00 AM - 8:30:00 AM GMT -08:00 US/Canada Pacific Invitees: user2@phoebe.mbp; user3@phoebe.mbp *~*~*~*~*~*~*~*~*~* </content></mp><mp ct="text/html"><content>&lt;html&gt;&lt;body&gt;&lt;h3&gt;The following is a new meeting request:&lt;/h3&gt; &lt;p&gt; &lt;table border='0'&gt; &lt;tr&gt;&lt;th align=left&gt;Subject:&lt;/th&gt;&lt;td&gt;test &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;th align=left&gt;Organizer:&lt;/th&gt;&lt;td&gt;"Demo User One" &amp;lt;user1@phoebe.mbp&amp;gt; &lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;p&gt; &lt;table border='0'&gt; &lt;tr&gt;&lt;th align=left&gt;Time:&lt;/th&gt;&lt;td&gt;Monday, February 27, 2012, 8:00:00 AM - 8:30:00 AM GMT -08:00 US/Canada Pacific &lt;/td&gt;&lt;/tr&gt;&lt;/table&gt; &lt;p&gt; &lt;table border='0'&gt; &lt;tr&gt;&lt;th align=left&gt;Invitees:&lt;/th&gt;&lt;td&gt;user2@phoebe.mbp; user3@phoebe.mbp &lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;div&gt;*~*~*~*~*~*~*~*~*~*&lt;/div&gt;&lt;br&gt;&lt;/body&gt;&lt;/html&gt;</content>
                       </mp>
                   </mp>
               </m>
           </CreateAppointmentRequest>
           </soap:Body></soap:Envelope>

         */
}
Also used : Msg(com.zimbra.soap.mail.type.Msg) CreateAppointmentRequest(com.zimbra.soap.mail.message.CreateAppointmentRequest) InvitationInfo(com.zimbra.soap.mail.type.InvitationInfo) CalendarAttendee(com.zimbra.soap.mail.type.CalendarAttendee) EmailAddrInfo(com.zimbra.soap.mail.type.EmailAddrInfo) CreateAppointmentResponse(com.zimbra.soap.mail.message.CreateAppointmentResponse) MimePartInfo(com.zimbra.soap.mail.type.MimePartInfo) CalOrganizer(com.zimbra.soap.mail.type.CalOrganizer) DtTimeInfo(com.zimbra.soap.mail.type.DtTimeInfo) SoapTransport(com.zimbra.common.soap.SoapTransport) InviteComponent(com.zimbra.soap.mail.type.InviteComponent)

Aggregations

SoapTransport (com.zimbra.common.soap.SoapTransport)85 Test (org.junit.Test)66 Account (com.zimbra.cs.account.Account)38 Element (com.zimbra.common.soap.Element)24 Group (com.zimbra.cs.account.Group)23 ServiceException (com.zimbra.common.service.ServiceException)16 SoapFaultException (com.zimbra.common.soap.SoapFaultException)15 DistributionListActionRequest (com.zimbra.soap.account.message.DistributionListActionRequest)12 DistributionListAction (com.zimbra.soap.account.type.DistributionListAction)12 AccountServiceException (com.zimbra.cs.account.AccountServiceException)11 DistributionListActionResponse (com.zimbra.soap.account.message.DistributionListActionResponse)11 ArrayList (java.util.ArrayList)10 SoapProtocol (com.zimbra.common.soap.SoapProtocol)9 Bug (com.zimbra.qa.QA.Bug)9 SoapTest (com.zimbra.qa.unittest.prov.soap.SoapTest)9 CreateSignatureRequest (com.zimbra.soap.account.message.CreateSignatureRequest)9 Signature (com.zimbra.soap.account.type.Signature)9 Domain (com.zimbra.cs.account.Domain)8 GetDistributionListRequest (com.zimbra.soap.account.message.GetDistributionListRequest)8 GetDistributionListResponse (com.zimbra.soap.account.message.GetDistributionListResponse)6