Ejemplo n.º 1
0
        internal static ItemOperationsRequest CreateItemOpsRequest(string messageId, string folderId)
        {
            BodyPreference bodyPreference = new BodyPreference
            {
                Type = new byte?(4)
            };

            Microsoft.Exchange.Connections.Eas.Model.Request.ItemOperations.Options options = new Microsoft.Exchange.Connections.Eas.Model.Request.ItemOperations.Options
            {
                MimeSupport    = new byte?(2),
                BodyPreference = bodyPreference
            };
            Fetch fetch = new Fetch
            {
                Store        = Store.Mailbox,
                CollectionId = folderId,
                ServerId     = messageId,
                Options      = options
            };

            return(new ItemOperationsRequest
            {
                Fetches = new Fetch[]
                {
                    fetch
                }
            });
        }
Ejemplo n.º 2
0
        public void MSASCON_S03_TC08_ItemOperations_MessagePart()
        {
            this.CheckActiveSyncVersionIsNot140();

            #region User2 sends an email to User1
            this.SwitchUser(this.User2Information, true);

            string subject             = Common.GenerateResourceName(Site, "Subject");
            string body                = Common.GenerateResourceName(Site, "Body");
            string user1MailboxAddress = Common.GetMailAddress(User1Information.UserName, User1Information.UserDomain);
            string user2MailboxAddress = Common.GetMailAddress(User2Information.UserName, User2Information.UserDomain);
            this.CallSendMailCommand(user2MailboxAddress, user1MailboxAddress, subject, body);
            TestSuiteBase.RecordCaseRelativeItems(this.User1Information, User1Information.InboxCollectionId, subject, false);
            #endregion

            #region Call ItemOperations command without BodyPreference or BodyPartPreference element.
            this.SwitchUser(this.User1Information, false);

            // Get all of the email BodyPart data.
            BodyPartPreference bodyPartPreference = new BodyPartPreference()
            {
                Type = 2,
            };

            DataStructures.Sync syncItem        = this.SyncEmail(subject, User1Information.InboxCollectionId, true, bodyPartPreference, null);
            XmlElement          lastRawResponse = (XmlElement)this.CONAdapter.LastRawResponseXml;
            string allData = TestSuiteHelper.GetDataInnerText(lastRawResponse, "BodyPart", "Data", subject);

            DataStructures.Email email = this.ItemOperationsFetch(User1Information.InboxCollectionId, syncItem.ServerId, null, null);
            this.VerifyMessagePartWithoutPreference(email);

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCON_R340");

            // Verify MS-ASCON requirement: MS-ASCON_R340
            Site.CaptureRequirementIfIsNull(
                email.BodyPart,
                340,
                @"[In Sending a Message Part] The airsyncbase:BodyPart element is not present in the [ItemOperations command] response if the client did not request the message part, as specified in section 3.1.4.10.");
            #endregion

            #region Call ItemOperations command with only BodyPreference element.
            BodyPreference bodyPreference = new BodyPreference()
            {
                Type = 2,
            };

            email = this.ItemOperationsFetch(User1Information.InboxCollectionId, syncItem.ServerId, null, bodyPreference);
            this.VerifyMessagePartWithBodyPreference(email);
            #endregion

            #region Call ItemOperations command with only BodyPartPreference element.
            bodyPartPreference = new BodyPartPreference()
            {
                Type                    = 2,
                TruncationSize          = 12,
                TruncationSizeSpecified = true,
            };

            email           = this.ItemOperationsFetch(User1Information.InboxCollectionId, syncItem.ServerId, bodyPartPreference, null);
            lastRawResponse = (XmlElement)this.CONAdapter.LastRawResponseXml;
            string truncatedData = TestSuiteHelper.GetDataInnerText(lastRawResponse, "BodyPart", "Data", subject);
            this.VerifyMessagePartWithBodyPartPreference(email, truncatedData, allData, (int)bodyPartPreference.TruncationSize);

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCON_R236");

            // Verify MS-ASCON requirement: MS-ASCON_R236
            Site.CaptureRequirementIfIsNotNull(
                email.BodyPart,
                236,
                @"[In Sending a Message Part] If the client [Sync command request ([MS-ASCMD] section 2.2.1.21), Search command request ([MS-ASCMD] section 2.2.1.16) or] ItemOperations command request 9([MS-ASCMD] section 2.2.1.10) includes the airsyncbase:BodyPartPreference element (section 2.2.2.2), then the server uses the airsyncbase:BodyPart element (section 2.2.2.1) to encapsulate the message part in the response.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCON_R39");

            // A message part and its meta-data are encapsulated by BodyPart element in the ItemOperation response, so this requirement can be captured.
            Site.CaptureRequirement(
                39,
                @"[In BodyPart] The airsyncbase:BodyPart element ([MS-ASAIRS] section 2.2.2.10) encapsulates a message part and its meta-data in [a Sync command response ([MS-ASCMD] section 2.2.1.21),] an ItemOperations command response ([MS-ASCMD] section 2.2.1.10) [or a Search command response ([MS-ASCMD] section 2.2.1.16)].");
            #endregion

            #region Call ItemOperations command with both BodyPreference and BodyPartPreference elements.
            email = this.ItemOperationsFetch(User1Information.InboxCollectionId, syncItem.ServerId, bodyPartPreference, bodyPreference);
            this.VerifyMessagePartWithBothPreference(email);
            #endregion
        }
 public void Parse(XmlNode parentNode)
 {
     bool[] bodyTypeSet  = new bool[256];
     bool[] bodyTypeSet2 = new bool[256];
     foreach (object obj in parentNode.ChildNodes)
     {
         XmlNode xmlNode = (XmlNode)obj;
         string  namespaceURI;
         if ("Schema" == xmlNode.Name)
         {
             this.ParseSchemaTags(xmlNode);
         }
         else if ((namespaceURI = xmlNode.NamespaceURI) != null)
         {
             string localName3;
             if (!(namespaceURI == "AirSync:"))
             {
                 string localName2;
                 if (!(namespaceURI == "AirSyncBase:"))
                 {
                     if (namespaceURI == "RightsManagement:")
                     {
                         string localName;
                         if ((localName = xmlNode.LocalName) != null && localName == "RightsManagementSupport")
                         {
                             string innerText;
                             if ((innerText = xmlNode.InnerText) != null)
                             {
                                 if (innerText == "0")
                                 {
                                     this.rightsManagementSupport = false;
                                     continue;
                                 }
                                 if (innerText == "1")
                                 {
                                     this.rightsManagementSupport = true;
                                     continue;
                                 }
                             }
                             throw new AirSyncPermanentException(StatusCode.Sync_ProtocolError, false)
                                   {
                                       ErrorStringForProtocolLogger = "InvalidValueRightsManagementSupport"
                                   };
                         }
                     }
                 }
                 else if ((localName2 = xmlNode.LocalName) != null)
                 {
                     if (!(localName2 == "BodyPreference"))
                     {
                         if (localName2 == "BodyPartPreference")
                         {
                             BodyPartPreference bodyPartPreference = MailboxSchemaOptionsParser.ParsePreference <BodyPartPreference>(xmlNode, bodyTypeSet2, () => new BodyPartPreference());
                             if (bodyPartPreference != null)
                             {
                                 this.bodyPartPreferences.Add(bodyPartPreference);
                             }
                         }
                     }
                     else
                     {
                         BodyPreference bodyPreference = MailboxSchemaOptionsParser.ParsePreference <BodyPreference>(xmlNode, bodyTypeSet, () => new BodyPreference());
                         if (bodyPreference != null)
                         {
                             this.bodyPreferences.Add(bodyPreference);
                         }
                     }
                 }
             }
             else if ((localName3 = xmlNode.LocalName) != null)
             {
                 if (!(localName3 == "Truncation"))
                 {
                     if (!(localName3 == "RTFTruncation"))
                     {
                         if (!(localName3 == "MIMETruncation"))
                         {
                             if (localName3 == "MIMESupport")
                             {
                                 this.ParseMIMESupport(xmlNode.InnerText);
                             }
                         }
                         else
                         {
                             this.ParseMIMETruncation(xmlNode.InnerText);
                         }
                     }
                     else
                     {
                         this.ParseRtfTruncationSetting(xmlNode.InnerText);
                     }
                 }
                 else
                 {
                     this.ParseTextTruncationSetting(xmlNode.InnerText);
                 }
             }
         }
     }
 }