/// <summary> /// Builds an ItemOperations request to fetch the whole content of the tasks. /// </summary> /// <param name="collectionId">Specify the tasks folder.</param> /// <param name="serverIds">Specify a unique identifier that is assigned by the server for the tasks.</param> /// <param name="longIds">Specifies a unique identifier that was assigned by the server to each result returned by a previous Search response.</param> /// <param name="bodyPreference">Sets preference information related to the type and size of the body.</param> /// <param name="schema">Specifies the schema of the item to be fetched.</param> /// <returns>Returns the ItemOperationsRequest instance</returns> internal static ItemOperationsRequest CreateItemOperationsFetchRequest( string collectionId, List<string> serverIds, List<string> longIds, Request.BodyPreference bodyPreference, Request.Schema schema) { Request.ItemOperationsFetchOptions fetchOptions = new Request.ItemOperationsFetchOptions(); List<object> fetchOptionItems = new List<object>(); List<Request.ItemsChoiceType5> fetchOptionItemsName = new List<Request.ItemsChoiceType5>(); if (null != bodyPreference) { fetchOptionItemsName.Add(Request.ItemsChoiceType5.BodyPreference); fetchOptionItems.Add(bodyPreference); } if (null != schema) { fetchOptionItemsName.Add(Request.ItemsChoiceType5.Schema); fetchOptionItems.Add(schema); } fetchOptions.Items = fetchOptionItems.ToArray(); fetchOptions.ItemsElementName = fetchOptionItemsName.ToArray(); List<Request.ItemOperationsFetch> fetchElements = new List<Request.ItemOperationsFetch>(); if (serverIds != null) { foreach (string serverId in serverIds) { Request.ItemOperationsFetch fetchElement = new Request.ItemOperationsFetch() { CollectionId = collectionId, ServerId = serverId, Store = SearchName.Mailbox.ToString(), Options = fetchOptions }; fetchElements.Add(fetchElement); } } if (longIds != null) { foreach (string longId in longIds) { Request.ItemOperationsFetch fetchElement = new Request.ItemOperationsFetch() { LongId = longId, Store = SearchName.Mailbox.ToString(), Options = fetchOptions }; fetchElements.Add(fetchElement); } } return Common.CreateItemOperationsRequest(fetchElements.ToArray()); }
/// <summary> /// Builds a ItemOperations request to fetch the whole content of the notes /// </summary> /// <param name="collectionId">Specifies the notes folder</param> /// <param name="serverIds">Specifies a unique identifier that is assigned by the server for the notes</param> /// <param name="longIds">Specifies a unique identifier that is assigned by the server to each result returned by a previous Search response.</param> /// <param name="bodyPreference">Sets preference information related to the type and size of the body.</param> /// <param name="schema">Specifies the schema of the item to be fetched.</param> /// <returns>Returns the ItemOperationsRequest instance</returns> internal static ItemOperationsRequest CreateItemOperationsFetchRequest( string collectionId, List <string> serverIds, List <string> longIds, Request.BodyPreference bodyPreference, Request.Schema schema) { Request.ItemOperationsFetchOptions fetchOptions = new Request.ItemOperationsFetchOptions(); List <object> fetchOptionItems = new List <object>(); List <Request.ItemsChoiceType5> fetchOptionItemsName = new List <Request.ItemsChoiceType5>(); if (null != bodyPreference) { fetchOptionItemsName.Add(Request.ItemsChoiceType5.BodyPreference); fetchOptionItems.Add(bodyPreference); } if (null != schema) { fetchOptionItemsName.Add(Request.ItemsChoiceType5.Schema); fetchOptionItems.Add(schema); } fetchOptions.Items = fetchOptionItems.ToArray(); fetchOptions.ItemsElementName = fetchOptionItemsName.ToArray(); List <Request.ItemOperationsFetch> fetchElements = new List <Request.ItemOperationsFetch>(); if (serverIds != null) { foreach (string serverId in serverIds) { Request.ItemOperationsFetch fetchElement = new Request.ItemOperationsFetch() { CollectionId = collectionId, ServerId = serverId, Store = SearchName.Mailbox.ToString(), Options = fetchOptions }; fetchElements.Add(fetchElement); } } if (longIds != null) { foreach (string longId in longIds) { Request.ItemOperationsFetch fetchElement = new Request.ItemOperationsFetch() { LongId = longId, Store = SearchName.Mailbox.ToString(), Options = fetchOptions }; fetchElements.Add(fetchElement); } } return(Common.CreateItemOperationsRequest(fetchElements.ToArray())); }
/// <summary> /// Builds a ItemOperations request to fetch the whole content of a single mail item /// by using the specified collectionId, emailServerId,bodyPreference and bodyPartPreference /// In general, returns the XML formatted ItemOperations request as follows: /// <!-- /// <?xml version="1.0" encoding="utf-8"?> /// <ItemOperations xmlns="ItemOperations" xmlns:airsync="AirSync" xmlns:airsyncbase="AirSyncBase"> /// <Fetch> /// <Store>Mailbox</Store> /// <airsync:CollectionId>5</airsync:CollectionId> /// <airsync:ServerId>5:1</airsync:ServerId> /// <Options> /// <airsync:MIMESupport>2</airsync:MIMESupport> /// <airsyncbase:BodyPreference> /// <airsyncbase:Type>4</airsyncbase:Type> /// </airsyncbase:BodyPreference> /// <airsyncbase:BodyPreference> /// <airsyncbase:Type>2</airsyncbase:Type> /// </airsyncbase:BodyPreference> /// </Options> /// </Fetch> /// </ItemOperations> /// --> /// </summary> /// <param name="collectionId">Specify the folder of mailItem, which can be returned by ActiveSync FolderSync command(Refer to [MS-ASCMD]2.2.3.30.2)</param> /// <param name="serverIds">Specify a unique identifier that was assigned by the server for a mailItem, which can be returned by ActiveSync Sync command(Refer to [MS-ASCMD]2.2.3.151.5)</param> /// <param name="schema">Sets the schema information</param> /// <returns>Returns the ItemOperationsRequest instance</returns> internal static ItemOperationsRequest CreateItemOperationsFetchRequest(string collectionId, List <string> serverIds, Request.Schema schema) { Request.ItemOperations itemOperations = new Request.ItemOperations(); List <object> items = new List <object>(); Request.ItemOperationsFetch fetchElement = new Request.ItemOperationsFetch(); if (serverIds != null) { foreach (string item in serverIds) { fetchElement.CollectionId = collectionId; fetchElement.ServerId = item; items.Add(fetchElement); } } itemOperations.Items = items.ToArray(); foreach (object item in itemOperations.Items) { Request.ItemOperationsFetch fetch = item as Request.ItemOperationsFetch; if (fetch != null) { fetch.Store = SearchName.Mailbox.ToString(); Request.ItemOperationsFetchOptions fetchOptions = new Request.ItemOperationsFetchOptions(); List <object> fetchOptionItems = new List <object>(); List <Request.ItemsChoiceType5> fetchOptionItemsName = new List <Request.ItemsChoiceType5> { Request.ItemsChoiceType5.BodyPreference, Request.ItemsChoiceType5.Schema }; fetchOptionItems.Add( new Request.BodyPreference() { AllOrNone = false, AllOrNoneSpecified = false, TruncationSize = 0, TruncationSizeSpecified = false, Preview = 0, PreviewSpecified = false, Type = 2, }); fetchOptionItems.Add(schema); fetchOptions.Items = fetchOptionItems.ToArray(); fetchOptions.ItemsElementName = fetchOptionItemsName.ToArray(); fetch.Options = fetchOptions; } } return(Common.CreateItemOperationsRequest(itemOperations.Items)); }
/// <summary> /// Builds a ItemOperations request to fetch the whole content of a single mail item /// by using the specified collectionId, emailServerId,bodyPreference and bodyPartPreference /// In general, returns the XML formatted ItemOperations request as follows: /// <!-- /// <?xml version="1.0" encoding="utf-8"?> /// <ItemOperations xmlns="ItemOperations" xmlns:airsync="AirSync" xmlns:airsyncbase="AirSyncBase"> /// <Fetch> /// <Store>Mailbox</Store> /// <airsync:CollectionId>5</airsync:CollectionId> /// <airsync:ServerId>5:1</airsync:ServerId> /// <Options> /// <airsync:MIMESupport>2</airsync:MIMESupport> /// <airsyncbase:BodyPreference> /// <airsyncbase:Type>4</airsyncbase:Type> /// </airsyncbase:BodyPreference> /// <airsyncbase:BodyPreference> /// <airsyncbase:Type>2</airsyncbase:Type> /// </airsyncbase:BodyPreference> /// </Options> /// </Fetch> /// </ItemOperations> /// --> /// </summary> /// <param name="collectionId">Specify the folder of mailItem, which can be returned by ActiveSync FolderSync command(Refer to [MS-ASCMD]2.2.3.30.2)</param> /// <param name="serverIds">Specify a unique identifier that was assigned by the server for a mailItem, which can be returned by ActiveSync Sync command(Refer to [MS-ASCMD]2.2.3.151.5)</param> /// <param name="schema">Sets the schema information</param> /// <returns>Returns the ItemOperationsRequest instance</returns> internal static ItemOperationsRequest CreateItemOperationsFetchRequest(string collectionId, List<string> serverIds, Request.Schema schema) { Request.ItemOperations itemOperations = new Request.ItemOperations(); List<object> items = new List<object>(); Request.ItemOperationsFetch fetchElement = new Request.ItemOperationsFetch(); if (serverIds != null) { foreach (string item in serverIds) { fetchElement.CollectionId = collectionId; fetchElement.ServerId = item; items.Add(fetchElement); } } itemOperations.Items = items.ToArray(); foreach (object item in itemOperations.Items) { Request.ItemOperationsFetch fetch = item as Request.ItemOperationsFetch; if (fetch != null) { fetch.Store = SearchName.Mailbox.ToString(); Request.ItemOperationsFetchOptions fetchOptions = new Request.ItemOperationsFetchOptions(); List<object> fetchOptionItems = new List<object>(); List<Request.ItemsChoiceType5> fetchOptionItemsName = new List<Request.ItemsChoiceType5> { Request.ItemsChoiceType5.BodyPreference, Request.ItemsChoiceType5.Schema }; fetchOptionItems.Add( new Request.BodyPreference() { AllOrNone = false, AllOrNoneSpecified = false, TruncationSize = 0, TruncationSizeSpecified = false, Preview = 0, PreviewSpecified = false, Type = 2, }); fetchOptionItems.Add(schema); fetchOptions.Items = fetchOptionItems.ToArray(); fetchOptions.ItemsElementName = fetchOptionItemsName.ToArray(); fetch.Options = fetchOptions; } } return Common.CreateItemOperationsRequest(itemOperations.Items); }
/// <summary> /// Builds a ItemOperations request to fetch the whole content of a single mail item /// by using the specified collectionId, emailServerId,bodyPreference and bodyPartPreference /// In general, returns the XML formatted ItemOperations request as follows: /// <!-- /// <?xml version="1.0" encoding="utf-8"?> /// <ItemOperations xmlns="ItemOperations" xmlns:airsync="AirSync" xmlns:airsyncbase="AirSyncBase"> /// <Fetch> /// <Store>Mailbox</Store> /// <airsync:CollectionId>5</airsync:CollectionId> /// <airsync:ServerId>5:1</airsync:ServerId> /// <Options> /// <airsync:MIMESupport>2</airsync:MIMESupport> /// <airsyncbase:BodyPreference> /// <airsyncbase:Type>4</airsyncbase:Type> /// </airsyncbase:BodyPreference> /// <airsyncbase:BodyPreference> /// <airsyncbase:Type>2</airsyncbase:Type> /// </airsyncbase:BodyPreference> /// </Options> /// </Fetch> /// </ItemOperations> /// --> /// </summary> /// <param name="collectionId">Specify the folder of mailItem, which can be returned by ActiveSync FolderSync command(Refer to [MS-ASCMD]2.2.3.30.2)</param> /// <param name="serverId">Specify a unique identifier that is assigned by the server for a mailItem, which can be returned by ActiveSync Sync command(Refer to [MS-ASCMD]2.2.3.151.5)</param> /// <param name="bodyPreference">Sets preference information related to the type and size of information for body (Refer to [MS-ASAIRS] 2.2.2.7)</param> /// <param name="bodyPartPreference">Sets preference information related to the type and size of information for a message part (Refer to [MS-ASAIRS] 2.2.2.6)</param> /// <param name="schema">Sets the schema information.</param> /// <returns>Returns the ItemOperationsRequest instance</returns> internal static ItemOperationsRequest CreateItemOperationsFetchRequest( string collectionId, string serverId, Request.BodyPreference bodyPreference, Request.BodyPartPreference bodyPartPreference, Request.Schema schema) { // Set the ItemOperations:Fetch Options (See [MS-ASCMD] 2.2.3.115.2 Options) // :: To get the whole content of the specified mail item, just ignore Fetch and Range element. // See [MS-ASCMD] 2.2.3.145 Schema and 2.2.3.130.1 Range // :: UserName, Password is not required by MS-ASEMAIl test case Request.ItemOperationsFetchOptions fetchOptions = new Request.ItemOperationsFetchOptions(); List<object> fetchOptionItems = new List<object>(); List<Request.ItemsChoiceType5> fetchOptionItemsName = new List<Request.ItemsChoiceType5>(); if (null != bodyPreference) { fetchOptionItemsName.Add(Request.ItemsChoiceType5.BodyPreference); fetchOptionItems.Add(bodyPreference); // when body format is mime (Refer to [MS-ASAIRS] 2.2.2.22 Type) if (bodyPreference.Type == 0x4) { fetchOptionItemsName.Add(Request.ItemsChoiceType5.MIMESupport); // Magic number '2' indicate server send MIME data for all messages but not S/MIME messages only // (Refer to [MS-ASCMD] 2.2.3.100.1 MIMESupport) fetchOptionItems.Add((byte)0x2); } } if (null != bodyPartPreference) { fetchOptionItemsName.Add(Request.ItemsChoiceType5.BodyPartPreference); fetchOptionItems.Add(bodyPartPreference); } if (null != schema) { fetchOptionItemsName.Add(Request.ItemsChoiceType5.Schema); fetchOptionItems.Add(schema); } fetchOptions.Items = fetchOptionItems.ToArray(); fetchOptions.ItemsElementName = fetchOptionItemsName.ToArray(); // *Only to fetch email item in mailbox* by using airsync:CollectionId & ServerId // So ignore LongId/LinkId/FileReference/RemoveRightsManagementProtection Request.ItemOperationsFetch fetchElement = new Request.ItemOperationsFetch() { CollectionId = collectionId, ServerId = serverId, Store = SearchName.Mailbox.ToString(), Options = fetchOptions }; return Common.CreateItemOperationsRequest(new object[] { fetchElement }); }
public void MSASCMD_S08_TC08_ItemOperations_Fetch_MIMESupport() { #region User2 sends mail to User1 and does FolderSync in User1's mailbox. string subject = this.SendMailAndFolderSync(); #endregion #region Call method Sync to synchronize changes of Inbox folder in User1's mailbox between the client and the server. SyncResponse syncResponse = this.GetMailItem(this.User1Information.InboxCollectionId, subject); string serverId = TestSuiteBase.FindServerId(syncResponse, "Subject", subject); #endregion #region Call method ItemOperations which contains the Fetch element with inline method and MIMESupport setting to 0. Request.ItemOperationsFetchOptions options = new Request.ItemOperationsFetchOptions(); Request.BodyPreference bodyPreference = new Request.BodyPreference { Type = 4 }; // Set the value of MIMESupport element to 0, which indicates never to send MIME data. options.Items = new object[] { (byte)0, bodyPreference }; options.ItemsElementName = new Request.ItemsChoiceType5[] { Request.ItemsChoiceType5.MIMESupport, Request.ItemsChoiceType5.BodyPreference }; ItemOperationsRequest itemOperationsRequest = CreateItemOperationsRequestWithFetchElement(this.User1Information.InboxCollectionId, SearchName.Mailbox.ToString(), serverId, options); ItemOperationsResponse itemOperationsResponse = this.CMDAdapter.ItemOperations(itemOperationsRequest, DeliveryMethodForFetch.Inline); Response.Body body = this.GetBodyElement(itemOperationsResponse); Site.Assert.IsNull(body.Data, "There should be no MIME data returned when MIMESupport setting to 0."); #endregion #region Call method ItemOperations which contains the Fetch element with inline method and MIMESupport setting to 1. // Set the value of MIMESupport element to 1, which indicates to send MIME data for S/MIME messages only, and send regular body for all other messages. // In this case, the response of this step contains no MIME data. options.Items = new object[] { (byte)1, bodyPreference }; itemOperationsRequest = CreateItemOperationsRequestWithFetchElement(this.User1Information.InboxCollectionId, SearchName.Mailbox.ToString(), serverId, options); itemOperationsResponse = this.CMDAdapter.ItemOperations(itemOperationsRequest, DeliveryMethodForFetch.Inline); body = this.GetBodyElement(itemOperationsResponse); Site.Assert.IsNull(body.Data, "There should be no MIME data returned for normal message when MIMESupport setting to 1."); #endregion #region Call method ItemOperations which contains the Fetch element with inline method and MIMESupport setting to 2. // Set the value of MIMESupport element to 2, which indicates to send MIME data for all messages. options.Items = new object[] { (byte)2, bodyPreference }; itemOperationsRequest = CreateItemOperationsRequestWithFetchElement(this.User1Information.InboxCollectionId, SearchName.Mailbox.ToString(), serverId, options); itemOperationsResponse = this.CMDAdapter.ItemOperations(itemOperationsRequest, DeliveryMethodForFetch.Inline); body = this.GetBodyElement(itemOperationsResponse); Site.Assert.IsNotNull(body.Data, "There should be MIME data returned for normal message when MIMESupport setting to 2."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R3366"); // Verify MS-ASCMD requirement: MS-ASCMD_R3366 Site.CaptureRequirementIfAreEqual<byte>( 4, body.Type, 3366, @"[In MIMESupport(ItemOperations)] The airsyncbase:Type element ([MS-ASAIRS] section 2.2.2.22.1) with a value of 4 to inform the device that the data is a MIME BLOB."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R3367"); Site.Assert.IsTrue(body.EstimatedDataSizeSpecified, "The EstimatedDataSize element should be specified in response when MIMESupport setting to 2."); XmlElement lastRawResponse = (XmlElement)this.CMDAdapter.LastRawResponseXml; string data = GetElementInnerText(lastRawResponse, "Body", "Data", subject); // Verify MS-ASCMD requirement: MS-ASCMD_R3367 Site.CaptureRequirementIfAreEqual<uint>( (uint)data.Length, body.EstimatedDataSize, 3367, @"[In MIMESupport(ItemOperations)] The airsyncbase:EstimatedDataSize element ([MS-ASAIRS] section 2.2.2.12.2) to specify the rough total size of the data."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R3368"); // Verify MS-ASCMD requirement: MS-ASCMD_R3368 // If response Body element contains data element, that means response contains full MIME BLOB data then MS-ASCMD_R3368 is verified. Site.CaptureRequirementIfIsNotNull( body.Data, 3368, @"[In MIMESupport(ItemOperations)] The airsyncbase:Data element ([MS-ASAIRS] section 2.2.2.10.1) that contains the full MIME BLOB."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R3360"); // Verify MS-ASCMD requirement: MS-ASCMD_R3360 // This requirement can be capture after above steps. Site.CaptureRequirement( 3360, @"[In MIMESupport(ItemOperations)] [To support fetching of the full S/MIME message, the Fetch (section 2.2.3.63.1) request MUST include] The airsync:MIMESupport element (section 2.2.3.100.3) to indicate to the server to return MIME for S/MIME-only messages, all messages, or no messages."); #endregion #region Call method SendStringRequest to call ItemOperations command without specifying delivery method and with MIMESupport setting to 2. string request = itemOperationsRequest.GetRequestDataSerializedXML(); SendStringResponse sendStringResponse = this.CMDAdapter.SendStringRequest(CommandName.ItemOperations, null, request); Site.Assert.IsNotNull(sendStringResponse.ResponseDataXML, "The XML data in response should not be null."); XmlDocument doc = new XmlDocument(); doc.LoadXml(sendStringResponse.ResponseDataXML); XmlElement xmlElement = (XmlElement)doc.DocumentElement; string defaultData = GetElementInnerText(xmlElement, "Body", "Data", subject); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R5503"); // Verify MS-ASCMD requirement: MS-ASCMD_R5503 // If the data gotten by ItemOperations command with inline method is equal to the data got by ItemOperations without specifying delivery method, this requirement can be captured. Site.CaptureRequirementIfAreEqual<string>( defaultData, data, 5503, @"[In Delivery of Content Requested by Fetch] The inline method is the default method for ItemOperations responses."); #endregion #region Call method ItemOperations which contains the Fetch element with MultiPart method and MIMESupport setting to 2. itemOperationsResponse = this.CMDAdapter.ItemOperations(itemOperationsRequest, DeliveryMethodForFetch.MultiPart); body = this.GetBodyElement(itemOperationsResponse); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R5366"); // When the item being fetched is located in a mailbox, server returns the Part element as a child of the airsyncbase:Body. // Verify MS-ASCMD requirement: MS-ASCMD_R5366 Site.CaptureRequirementIfIsNotNull( body.Part, 5366, @"[In Part] It [Part element] is a child of the airsyncbase:Body element if the item being fetched is located in a mailbox."); #endregion }
public void MSASCMD_S08_TC02_ItemOperations_Status2() { #region Call method ItemOperations which contains the Fetch element, with an invalid option in Options element. Request.ItemOperationsFetchOptions options = new Request.ItemOperationsFetchOptions { Items = new object[] { string.Empty }, ItemsElementName = new Request.ItemsChoiceType5[] { Request.ItemsChoiceType5.Range } }; // Set the Range element to empty string as the child element of option element in Fetch element, to trigger the status code 2. options.Items = new object[] { string.Empty }; options.ItemsElementName = new Request.ItemsChoiceType5[] { Request.ItemsChoiceType5.Range }; ItemOperationsRequest itemOperationsRequest = CreateItemOperationsRequestWithFetchElement(this.User1Information.InboxCollectionId, SearchName.Mailbox.ToString(), string.Empty, options); ItemOperationsResponse itemOperationsResponse = this.CMDAdapter.ItemOperations(itemOperationsRequest, DeliveryMethodForFetch.Inline); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R3547"); // Verify MS-ASCMD requirement: MS-ASCMD_R3547 Site.CaptureRequirementIfAreEqual<string>( "2", itemOperationsResponse.ResponseData.Status, 3547, @"[In Options(ItemOperations)] If the client specifies an option that is invalid for the parent element, the server returns a Status element (section 2.2.3.162.7) value of 2."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R4154"); // Verify MS-ASCMD requirement: MS-ASCMD_R4154 Site.CaptureRequirementIfAreEqual<string>( "2", itemOperationsResponse.ResponseData.Status, 4154, @"[In Status(ItemOperations)] [The meaning of the status value] 2 [is] Protocol error - protocol violation/XML validation error."); #endregion }