/// <summary>
        /// Builds a Sync change request by using the specified sync key, folder collection ID and change application data.
        /// </summary>
        /// <param name="syncKey">Specifies the sync key obtained from the last sync response.</param>
        /// <param name="collectionId">Specifies the server ID of the folder to be synchronized.</param>
        /// <param name="data">Contains the data used to specify the Change element for Sync command.</param>
        /// <returns>Returns the SyncRequest instance</returns>
        internal static SyncRequest CreateSyncRequest(string syncKey, string collectionId, List <object> data)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                SyncKey                 = syncKey,
                GetChanges              = true,
                GetChangesSpecified     = true,
                DeletesAsMoves          = false,
                DeletesAsMovesSpecified = true,
                CollectionId            = collectionId
            };

            Request.Options        option     = new Request.Options();
            Request.BodyPreference preference = new Request.BodyPreference
            {
                Type             = 2,
                Preview          = 0,
                PreviewSpecified = true
            };

            option.Items            = new object[] { preference };
            option.ItemsElementName = new Request.ItemsChoiceType1[]
            {
                Request.ItemsChoiceType1.BodyPreference,
            };

            syncCollection.Options    = new Request.Options[1];
            syncCollection.Options[0] = option;

            syncCollection.WindowSize = "512";
            syncCollection.Commands   = data.ToArray();

            return(Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection }));
        }
        /// <summary>
        /// Create a generic Sync request without command references by using the specified sync key, folder collectionId and body preference option.
        /// </summary>
        /// <param name="syncKey">Specify the sync key obtained from the last Sync response.</param>
        /// <param name="collectionId">Specify the serverId of the folder to be synchronized.</param>
        /// <param name="bodyPreference">Sets preference information related to the type and size of information for body.</param>
        /// <returns>The SyncRequest instance.</returns>
        internal static SyncRequest CreateSyncRequest(string syncKey, string collectionId, Request.BodyPreference bodyPreference)
        {
            Request.SyncCollection syncCollection = CreateSyncCollection(syncKey, collectionId);

            Request.Options syncOptions     = new Request.Options();
            List <object>   syncOptionItems = new List <object>();
            List <Request.ItemsChoiceType1> syncOptionItemsName = new List <Request.ItemsChoiceType1>();

            if (null != bodyPreference)
            {
                syncOptionItemsName.Add(Request.ItemsChoiceType1.BodyPreference);
                syncOptionItems.Add(bodyPreference);

                // when body format is mime (Refer to  [MS-ASAIRS] 2.2.2.22 Type)
                if (bodyPreference.Type == 0x4)
                {
                    syncOptionItemsName.Add(Request.ItemsChoiceType1.MIMESupport);

                    // '2' indicates server sends MIME data for all messages but not S/MIME messages only.
                    syncOptionItems.Add((byte)0x2);
                }
            }

            syncOptions.Items            = syncOptionItems.ToArray();
            syncOptions.ItemsElementName = syncOptionItemsName.ToArray();
            syncCollection.Options       = new Request.Options[] { syncOptions };

            return(Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection }));
        }
        /// <summary>
        /// Builds a generic Sync request without command references by using the specified sync key, folder collection ID and body preference option.
        /// </summary>
        /// <param name="syncKey">Specifies the sync key obtained from the last sync response.</param>
        /// <param name="collectionId">Specifies the server ID of the folder to be synchronized.</param>
        /// <param name="bodyPreference">Sets preference information related to the type and size of information for body.</param>
        /// <returns>Returns the SyncRequest instance</returns>
        internal static SyncRequest CreateSyncRequest(string syncKey, string collectionId, Request.BodyPreference bodyPreference)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                SyncKey      = syncKey,
                CollectionId = collectionId
            };

            // Sets Getchanges only if SyncKey != 0 since fail response is returned when the SyncKey element value is 0.
            if (syncKey != "0")
            {
                syncCollection.GetChanges          = true;
                syncCollection.GetChangesSpecified = true;
            }

            syncCollection.WindowSize = "512";

            Request.Options syncOptions     = new Request.Options();
            List <object>   syncOptionItems = new List <object>();
            List <Request.ItemsChoiceType1> syncOptionItemsName = new List <Request.ItemsChoiceType1>();

            if (null != bodyPreference)
            {
                syncOptionItemsName.Add(Request.ItemsChoiceType1.BodyPreference);
                syncOptionItems.Add(bodyPreference);
            }

            syncOptions.Items            = syncOptionItems.ToArray();
            syncOptions.ItemsElementName = syncOptionItemsName.ToArray();
            syncCollection.Options       = new Request.Options[] { syncOptions };

            return(Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection }));
        }
        /// <summary>
        /// Builds a generic Sync request without command references by using the specified sync key, folder collection ID and body preference option.
        /// </summary>
        /// <param name="syncKey">Specify the sync key obtained from the last sync response</param>
        /// <param name="collectionId">Specify the server ID of the folder to be synchronized, which can be returned by ActiveSync FolderSync command</param>
        /// <param name="rightsManagementSupport">A boolean value specifies whether the server will decompress and decrypt rights-managed email messages before sending them to the client or not</param>
        /// <returns>Returns the Sync request instance</returns>
        internal static SyncRequest CreateSyncRequest(string syncKey, string collectionId, bool?rightsManagementSupport)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                SyncKey      = syncKey,
                CollectionId = collectionId
            };

            if (syncKey != "0")
            {
                syncCollection.GetChanges          = true;
                syncCollection.GetChangesSpecified = true;
            }

            syncCollection.WindowSize = "100";

            Request.BodyPreference bodyPreference = new Request.BodyPreference {
                Type = 1
            };

            Request.Options syncOptions     = new Request.Options();
            List <object>   syncOptionItems = new List <object> {
                bodyPreference
            };

            List <Request.ItemsChoiceType1> syncOptionItemsName = new List <Request.ItemsChoiceType1>
            {
                Request.ItemsChoiceType1.BodyPreference
            };

            if (rightsManagementSupport != null)
            {
                syncOptionItems.Add(rightsManagementSupport);
                syncOptionItemsName.Add(Request.ItemsChoiceType1.RightsManagementSupport);
            }

            syncOptions.Items            = syncOptionItems.ToArray();
            syncOptions.ItemsElementName = syncOptionItemsName.ToArray();
            syncCollection.Options       = new Request.Options[] { syncOptions };
            return(Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection }));
        }
Esempio n. 5
0
        /// <summary>
        /// Build a generic Sync request without command references by using the specified sync key, folder collection ID and body preference option.
        /// If syncKey is
        /// In general, returns the XML formatted Sync request as follows:
        /// <!--
        /// <?xml version="1.0" encoding="utf-8"?>
        /// <Sync xmlns="AirSync">
        ///   <Collections>
        ///     <Collection>
        ///       <SyncKey>0</SyncKey>
        ///       <CollectionId>5</CollectionId>
        ///       <DeletesAsMoves>1</DeletesAsMoves>
        ///       <GetChanges>1</GetChanges>
        ///       <WindowSize>100</WindowSize>
        ///       <Options>
        ///         <MIMESupport>0</MIMESupport>
        ///         <airsyncbase:BodyPreference>
        ///           <airsyncbase:Type>2</airsyncbase:Type>
        ///           <airsyncbase:TruncationSize>5120</airsyncbase:TruncationSize>
        ///         </airsyncbase:BodyPreference>
        ///       </Options>
        ///     </Collection>
        ///   </Collections>
        /// </Sync>
        /// -->
        /// </summary>
        /// <param name="syncKey">Specify the sync key obtained from the last sync response(Refer to [MS-ASCMD]2.2.3.166.4)</param>
        /// <param name="collectionId">Specify the server ID of the folder to be synchronized, which can be returned by ActiveSync FolderSync command(Refer to [MS-ASCMD]2.2.3.30.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>
        /// <returns>Returns the SyncRequest instance</returns>
        internal static SyncRequest CreateSyncRequest(string syncKey, string collectionId, Request.BodyPreference bodyPreference)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                SyncKey      = syncKey,
                CollectionId = collectionId
            };

            if (syncKey != "0")
            {
                syncCollection.GetChanges          = true;
                syncCollection.GetChangesSpecified = true;
            }

            syncCollection.WindowSize = "100";

            Request.Options syncOptions     = new Request.Options();
            List <object>   syncOptionItems = new List <object>();
            List <Request.ItemsChoiceType1> syncOptionItemsName = new List <Request.ItemsChoiceType1>();

            if (null != bodyPreference)
            {
                syncOptionItemsName.Add(Request.ItemsChoiceType1.BodyPreference);
                syncOptionItems.Add(bodyPreference);

                // when body format is mime (Refer to [MS-ASAIRS] 2.2.2.22 Type)
                if (bodyPreference.Type == 0x4)
                {
                    syncOptionItemsName.Add(Request.ItemsChoiceType1.MIMESupport);

                    // Magic number '2' indicate server send MIME data for all messages but not S/MIME messages only
                    syncOptionItems.Add((byte)0x2);
                }
            }

            syncOptions.Items            = syncOptionItems.ToArray();
            syncOptions.ItemsElementName = syncOptionItemsName.ToArray();
            syncCollection.Options       = new Request.Options[] { syncOptions };

            return(Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection }));
        }
        public void MSASCMD_S21_TC05_CommonStatusCode_164()
        {
            Site.Assume.AreNotEqual <string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "Status value 164 is not returned when the MS-ASProtocolVersion header is set to 12.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");
            Site.Assume.AreNotEqual <string>("14.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "Status value 164 is not returned when the MS-ASProtocolVersion header is set to 14.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region User calls Sync command with option element

            // Set an unsupported Type element value in the BodyPartPreference node
            Request.Options option = new Request.Options
            {
                Items = new object[]
                {
                    new Request.BodyPartPreference()
                    {
                        // As specified in [MS-ASAIRS] section 2.2.2.22.3, only a value of 2 (HTML) SHOULD be used in the Type element of a BodyPartPreference element.
                        // Then '3' is an unsupported Type element value.
                        Type = 3
                    }
                },
                ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.BodyPartPreference }
            };

            SyncRequest syncRequest = TestSuiteBase.CreateEmptySyncRequest(this.User1Information.InboxCollectionId);
            this.Sync(syncRequest);

            syncRequest.RequestData.Collections[0].Options = new Request.Options[] { option };
            syncRequest.RequestData.Collections[0].SyncKey = this.LastSyncKey;
            SyncResponse syncResponse = this.Sync(syncRequest);

            #endregion

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R5412
            Site.CaptureRequirementIfAreEqual <int>(
                164,
                int.Parse(syncResponse.ResponseData.Status),
                5412,
                @"[In Common Status Codes] [The meaning of the status value 164 is] The BodyPartPreference node (as specified in [MS-ASAIRS] section 2.2.2.7) has an unsupported Type element (as specified in [MS-ASAIRS] section 2.2.2.22.4) value.<98>");
        }
        /// <summary>
        /// Builds a initial Sync request by using the specified collection Id.
        /// In order to sync the content of a folder, an initial sync key for the folder MUST be obtained from the server.
        /// The client obtains the key by sending an initial Sync request with a SyncKey element value of zero and the CollectionId element
        /// In general, returns the XML formatted Sync request as follows:
        /// <!--
        /// <?xml version="1.0" encoding="utf-8"?>
        /// <Sync xmlns="AirSync">
        ///   <Collections>
        ///     <Collection>
        ///       <SyncKey>0</SyncKey>
        ///       <CollectionId>5</CollectionId>
        ///     </Collection>
        ///   </Collections>
        /// </Sync>
        /// -->
        /// </summary>
        /// <param name="collectionId">Identify the folder as the collection being synchronized, which can be returned by ActiveSync FolderSync command(Refer to [MS-ASCMD]2.2.3.30.5)</param>
        /// <param name="supported">Specifies which contact and calendar elements in a Sync request are managed by the client and therefore not ghosted.</param>
        /// <returns>Returns the SyncRequest instance</returns>
        internal static SyncRequest InitializeSyncRequest(string collectionId, Request.Supported supported)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                Supported    = supported,
                WindowSize   = "512",
                CollectionId = collectionId,
                SyncKey      = "0"
            };

            List <object> items = new List <object>();
            List <Request.ItemsChoiceType1> itemsElementName = new List <Request.ItemsChoiceType1>
            {
                Request.ItemsChoiceType1.BodyPreference
            };

            items.Add(
                new Request.BodyPreference()
            {
                TruncationSize          = 0,
                TruncationSizeSpecified = false,
                Type             = 2,
                Preview          = 0,
                PreviewSpecified = false,
            });

            Request.Options option = new Request.Options
            {
                Items            = items.ToArray(),
                ItemsElementName = itemsElementName.ToArray()
            };

            syncCollection.Options = new Request.Options[] { option };

            SyncRequest request = Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });

            return(request);
        }
        /// <summary>
        /// Build a generic Sync request without command references by using the specified sync key, folder collection ID and body preference option.
        /// In general, returns the XML formatted Sync request as follows:
        /// <!--
        /// <?xml version="1.0" encoding="utf-8"?>
        /// <Sync xmlns="AirSync">
        ///   <Collections>
        ///     <Collection>
        ///       <SyncKey>0</SyncKey>
        ///       <CollectionId>5</CollectionId>
        ///       <DeletesAsMoves>1</DeletesAsMoves>
        ///       <GetChanges>1</GetChanges>
        ///       <WindowSize>152</WindowSize>
        ///       <Options>
        ///         <MIMESupport>0</MIMESupport>
        ///         <airsyncbase:BodyPreference>
        ///           <airsyncbase:Type>2</airsyncbase:Type>
        ///         </airsyncbase:BodyPreference>
        ///       </Options>
        ///     </Collection>
        ///   </Collections>
        /// </Sync>
        /// -->
        /// </summary>
        /// <param name="collectionId">Specify the server ID of the folder to be synchronized, which can be returned by ActiveSync FolderSync command(Refer to [MS-ASCMD]2.2.3.30.5)</param>
        /// <param name="syncKey">Specify the sync key obtained from the last sync response(Refer to [MS-ASCMD]2.2.3.166.4)</param>
        /// <param name="getChanges">Sets sync collection information related to the GetChanges</param>
        /// <returns>Returns the SyncRequest instance</returns>
        internal static SyncRequest CreateSyncRequest(string collectionId, string syncKey, bool getChanges)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                WindowSize   = "512",
                SyncKey      = syncKey,
                CollectionId = collectionId,
                Supported    = null
            };

            if (getChanges)
            {
                syncCollection.GetChanges          = true;
                syncCollection.GetChangesSpecified = true;
            }

            Request.Options syncOptions     = new Request.Options();
            List <object>   syncOptionItems = new List <object>();
            List <Request.ItemsChoiceType1> syncOptionItemsName = new List <Request.ItemsChoiceType1>
            {
                Request.ItemsChoiceType1.BodyPreference
            };

            syncOptionItems.Add(
                new Request.BodyPreference()
            {
                Type                    = 2,
                TruncationSize          = 0,
                TruncationSizeSpecified = false,
                Preview                 = 0,
                PreviewSpecified        = false
            });
            syncOptions.Items            = syncOptionItems.ToArray();
            syncOptions.ItemsElementName = syncOptionItemsName.ToArray();
            syncCollection.Options       = new Request.Options[] { syncOptions };

            return(Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection }));
        }
        /// <summary>
        /// Creates a Sync change request by using the specified sync key, folder collection ID and change application data.
        /// </summary>
        /// <param name="syncKey">Specify the sync key obtained from the last sync response.</param>
        /// <param name="collectionId">Specify the server ID of the folder to be synchronized.</param>
        /// <param name="data">Contains the data used to specify the Change element for Sync command.</param>
        /// <returns>Returns the SyncRequest instance.</returns>
        internal static SyncRequest CreateSyncRequest(string syncKey, string collectionId, List<object> data)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                SyncKey = syncKey,
                GetChanges = true,
                GetChangesSpecified = true,
                DeletesAsMoves = false,
                DeletesAsMovesSpecified = true,
                CollectionId = collectionId
            };

            Request.Options option = new Request.Options();
            Request.BodyPreference preference = new Request.BodyPreference
            {
                Type = 2,
                Preview = 0,
                PreviewSpecified = false
            };

            option.Items = new object[] { preference };
            option.ItemsElementName = new Request.ItemsChoiceType1[]
            {
                Request.ItemsChoiceType1.BodyPreference,
            };

            syncCollection.Options = new Request.Options[1];
            syncCollection.Options[0] = option;

            syncCollection.WindowSize = "512";

            if (data != null)
            {
                syncCollection.Commands = data.ToArray();
            }

            return Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
        }
        /// <summary>
        /// Builds a generic Sync request without command references by using the specified sync key, folder collection ID and body preference option.
        /// </summary>
        /// <param name="syncKey">Specify the sync key obtained from the last sync response</param>
        /// <param name="collectionId">Specify the server ID of the folder to be synchronized, which can be returned by ActiveSync FolderSync command</param>
        /// <param name="rightsManagementSupport">A boolean value specifies whether the server will decompress and decrypt rights-managed email messages before sending them to the client or not</param>
        /// <returns>Returns the Sync request instance</returns>
        internal static SyncRequest CreateSyncRequest(string syncKey, string collectionId, bool? rightsManagementSupport)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                SyncKey = syncKey,
                CollectionId = collectionId
            };

            if (syncKey != "0")
            {
                syncCollection.GetChanges = true;
                syncCollection.GetChangesSpecified = true;
            }

            syncCollection.WindowSize = "100";

            Request.BodyPreference bodyPreference = new Request.BodyPreference { Type = 1 };

            Request.Options syncOptions = new Request.Options();
            List<object> syncOptionItems = new List<object> { bodyPreference };

            List<Request.ItemsChoiceType1> syncOptionItemsName = new List<Request.ItemsChoiceType1>
            {
                Request.ItemsChoiceType1.BodyPreference
            };

            if (rightsManagementSupport != null)
            {
                syncOptionItems.Add(rightsManagementSupport);
                syncOptionItemsName.Add(Request.ItemsChoiceType1.RightsManagementSupport);
            }

            syncOptions.Items = syncOptionItems.ToArray();
            syncOptions.ItemsElementName = syncOptionItemsName.ToArray();
            syncCollection.Options = new Request.Options[] { syncOptions };
            return Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
        }
        /// <summary>
        /// Builds a generic Sync request without command references by using the specified sync key, folder collection ID and body preference option.
        /// </summary>
        /// <param name="syncKey">Specifies the sync key obtained from the last sync response.</param>
        /// <param name="collectionId">Specifies the server ID of the folder to be synchronized.</param>
        /// <param name="bodyPreference">Sets preference information related to the type and size of information for body.</param>
        /// <returns>Returns the SyncRequest instance</returns>
        internal static SyncRequest CreateSyncRequest(string syncKey, string collectionId, Request.BodyPreference bodyPreference)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                SyncKey = syncKey,
                CollectionId = collectionId
            };

            // Sets Getchanges only if SyncKey != 0 since fail response is returned when the SyncKey element value is 0.
            if (syncKey != "0")
            {
                syncCollection.GetChanges = true;
                syncCollection.GetChangesSpecified = true;
            }

            syncCollection.WindowSize = "512";

            Request.Options syncOptions = new Request.Options();
            List<object> syncOptionItems = new List<object>();
            List<Request.ItemsChoiceType1> syncOptionItemsName = new List<Request.ItemsChoiceType1>();

            if (null != bodyPreference)
            {
                syncOptionItemsName.Add(Request.ItemsChoiceType1.BodyPreference);
                syncOptionItems.Add(bodyPreference);
            }

            syncOptions.Items = syncOptionItems.ToArray();
            syncOptions.ItemsElementName = syncOptionItemsName.ToArray();
            syncCollection.Options = new Request.Options[] { syncOptions };

            return Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
        }
        /// <summary>
        /// Builds a initial Sync request by using the specified collection Id.
        /// In order to sync the content of a folder, an initial sync key for the folder MUST be obtained from the server.
        /// The client obtains the key by sending an initial Sync request with a SyncKey element value of zero and the CollectionId element
        /// In general, returns the XML formatted Sync request as follows:
        /// <!--
        /// <?xml version="1.0" encoding="utf-8"?>
        /// <Sync xmlns="AirSync">
        ///   <Collections>
        ///     <Collection>
        ///       <SyncKey>0</SyncKey>
        ///       <CollectionId>5</CollectionId>
        ///     </Collection>
        ///   </Collections>
        /// </Sync>
        /// -->
        /// </summary>
        /// <param name="collectionId">Identify the folder as the collection being synchronized, which can be returned by ActiveSync FolderSync command(Refer to [MS-ASCMD]2.2.3.30.5)</param>
        /// <param name="supported">Specifies which contact and calendar elements in a Sync request are managed by the client and therefore not ghosted.</param>
        /// <returns>Returns the SyncRequest instance</returns>
        internal static SyncRequest InitializeSyncRequest(string collectionId, Request.Supported supported)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                Supported = supported,
                WindowSize = "512",
                CollectionId = collectionId,
                SyncKey = "0"
            };

            List<object> items = new List<object>();
            List<Request.ItemsChoiceType1> itemsElementName = new List<Request.ItemsChoiceType1>
            {
                Request.ItemsChoiceType1.BodyPreference
            };

            items.Add(
                new Request.BodyPreference()
                {
                    TruncationSize = 0,
                    TruncationSizeSpecified = false,
                    Type = 2,
                    Preview = 0,
                    PreviewSpecified = false,
                });

            Request.Options option = new Request.Options
            {
                Items = items.ToArray(),
                ItemsElementName = itemsElementName.ToArray()
            };

            syncCollection.Options = new Request.Options[] { option };

            SyncRequest request = Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });

            return request;
        }
        public void MSASCMD_S07_TC01_GetItemEstimate_Success()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Options element is not supported when the MS-ASProtocolVersion header is set to 12.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region Send a MIME-formatted email from User1 to User2.
            string emailSubject = Common.GenerateResourceName(Site, "subject");
            this.SendPlainTextEmail(null, emailSubject, this.User1Information.UserName, this.User2Information.UserName, null);
            #endregion

            this.SwitchUser(this.User2Information);
            TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, emailSubject);
            this.CheckEmail(this.User2Information.InboxCollectionId, emailSubject, null);

            #region Call method GetItemEstimate to get an estimate of the number of items in the Inbox folder.
            this.Sync(TestSuiteBase.CreateEmptySyncRequest(this.User2Information.InboxCollectionId), false);

            Request.Options option = new Request.Options
            {
                Items = new object[] { "Email" },
                ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.Class }
            };

            GetItemEstimateRequest getItemEstimateRequest = TestSuiteBase.CreateGetItemEstimateRequest(this.LastSyncKey, this.User2Information.InboxCollectionId, new Request.Options[] { option });
            GetItemEstimateResponse getItemEstimateResponse = this.CMDAdapter.GetItemEstimate(getItemEstimateRequest);
            Site.Assert.IsNotNull(getItemEstimateResponse.ResponseData.Response, "The Response element in the GetItemEstimate command response should not be null.");
            #endregion

            #region Call Sync command to get all items in the Inbox folder.
            SyncRequest syncRequest = TestSuiteBase.CreateEmptySyncRequest(this.User2Information.InboxCollectionId);
            this.Sync(syncRequest, false);
            syncRequest.RequestData.Collections[0].SyncKey = this.LastSyncKey;
            SyncResponse syncResponse = this.Sync(syncRequest, false);

            Response.SyncCollectionsCollectionCommands commands = TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Commands) as Response.SyncCollectionsCollectionCommands;
            Site.Assert.IsNotNull(commands, "The Commands element in the Sync command response should not be null.");
            Site.Assert.IsNotNull(commands.Add, "The Add element of the Commands element in the Sync command response should not be null.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R4134
            Site.CaptureRequirementIfAreEqual<string>(
                "1",
                getItemEstimateResponse.ResponseData.Response[0].Status,
                4134,
                @"[In Status(GetItemEstimate)] [When the scope is Global], [the cause of the status value 1 is] Server successfully completed command.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R171
            Site.CaptureRequirementIfAreEqual<int>(
                commands.Add.Length,
                Convert.ToInt32(getItemEstimateResponse.ResponseData.Response[0].Collection.Estimate),
                171,
                @"[In GetItemEstimate] The GetItemEstimate command gets an estimate of the number of items in a collection or folder on the server that have to be synchronized.");

            // If R171 has been verified, then the GetItemEstimate command gets an estimate of the number of items in a collection or folder. 
            // So R5056 will be verified.
            this.Site.CaptureRequirement(
                5056,
                @"[In Synchronizing Inbox, Calendar, Contacts, and Tasks Folders] [Command sequence for folder synchronization, order [3]:] The server responds to indicate how many items will be added, changed, or deleted, for each collection.");
            #endregion
        }
        public void MSASCMD_S07_TC10_GetItemEstimate_Status3()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Options element is not supported when the MS-ASProtocolVersion header is set to 12.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region Call method GetItemEstimate without priming the synchronization state.
            Request.Options option = new Request.Options
            {
                Items = new object[] { "Email" },
                ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.Class }
            };

            GetItemEstimateRequest getItemEstimateRequest = TestSuiteBase.CreateGetItemEstimateRequest("0", this.User1Information.InboxCollectionId, new Request.Options[] { option });
            GetItemEstimateResponse getItemEstimateResponse = CMDAdapter.GetItemEstimate(getItemEstimateRequest);
            Site.Assert.IsNotNull(getItemEstimateResponse.ResponseData.Response, "The response of GetItemEstimate command should not be null.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R4139
            // When the Status value is 3, it means the synchronization state has not been primed.
            Site.CaptureRequirementIfAreEqual<int>(
                3,
                int.Parse(getItemEstimateResponse.ResponseData.Response[0].Status),
                4139,
                @"[In Status(GetItemEstimate)] [When the scope is] Item, [the meaning of the status value] 3 [is] The synchronization state has not been primed.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R4140
            // When the Status value is 3, it means the issued GetItemEstimate command without first issuing a Sync command request with a SyncKey value of 0.
            Site.CaptureRequirementIfAreEqual<int>(
                3,
                int.Parse(getItemEstimateResponse.ResponseData.Response[0].Status),
                4140,
                @"[In Status(GetItemEstimate)] [When the scope is Item], [the cause of the status value 3 is] The client has issued a GetItemEstimate command without first issuing a Sync command request (section 2.2.2.19) with an airsync:SyncKey element (section 2.2.3.156.4) value of zero (0).");
            #endregion
        }
        /// <summary>
        /// Create an empty Sync request with filter type.
        /// </summary>
        /// <param name="collectionId">The value of the folder collectionId.</param>
        /// <param name="filterType">The value of the FilterType.</param>
        /// <returns>The empty Sync request.</returns>
        protected static SyncRequest CreateEmptySyncRequest(string collectionId, int filterType)
        {
            Request.SyncCollection collection = new Request.SyncCollection
            {
                SyncKey = "0",
                CollectionId = collectionId,
                Commands = null
            };

            if (0 <= filterType && filterType <= 8)
            {
                Request.Options option = new Request.Options
                {
                    Items = new object[] { (byte)filterType },
                    ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.FilterType }
                };
                collection.Options = new Request.Options[] { option };
            }

            return Common.CreateSyncRequest(new Request.SyncCollection[] { collection });
        }
Esempio n. 16
0
        public void MSASCMD_S19_TC41_Sync_MoreThanOneConflicts()
        {
            Request.Options option = new Request.Options
            {
                Items = new object[] { (byte)1, (byte)1 },
                ItemsElementName =
                    new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.Conflict, Request.ItemsChoiceType1.Conflict }
            };

            Request.SyncCollection collection = new Request.SyncCollection
            {
                Options = new Request.Options[] { option },
                SyncKey = "0",
                CollectionId = this.User1Information.ContactsCollectionId
            };

            Request.Sync syncRequestData = new Request.Sync { Collections = new Request.SyncCollection[] { collection } };

            SyncRequest syncRequest = new SyncRequest { RequestData = syncRequestData };
            SyncResponse syncResponse = this.Sync(syncRequest);

            if (Common.IsRequirementEnabled(2075, this.Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R2075");

                // Verify MS-ASCMD requirement: MS-ASCMD_R2075
                Site.CaptureRequirementIfAreEqual<uint>(
                    1,
                    Convert.ToUInt32(TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Status)),
                    2075,
                    @"[In Appendix A: Product Behavior] The implementation does not return a protocol status error in response to such a command request [more than one Conflict element as the child of an Options element]. (Exchange 2007 and above follow this behavior.)");
            }
        }
Esempio n. 17
0
        public void MSASCMD_S19_TC09_Sync_Class_Redefined()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Class element is not supported as a child element of the Options element when the MS-ASProtocolVersion header is set to 12.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            this.Sync(TestSuiteBase.CreateEmptySyncRequest(this.User1Information.CalendarCollectionId));

            // Add a calendar item
            string calendarSubject = Common.GenerateResourceName(Site, "canlendarSubject");
            string calendarTo = Common.GetMailAddress(this.User1Information.UserName, this.User1Information.UserDomain);
            string location = Common.GenerateResourceName(Site, "Room11");
            Request.SyncCollectionAdd addData = this.CreateAddCalendarCommand(calendarTo, calendarSubject, location, string.Empty);

            Request.Options firstOption = new Request.Options
            {
                Items = new object[] { "Calendar" },
                ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.Class }
            };

            Request.Options secondOption = new Request.Options
            {
                Items = new object[] { "Calendar" },
                ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.Class }
            };

            SyncRequest syncRequest = TestSuiteBase.CreateSyncAddRequest(this.LastSyncKey, this.User1Information.CalendarCollectionId, addData);
            syncRequest.RequestData.Collections[0].Options = new Request.Options[] { firstOption, secondOption };
            SyncResponse syncResponse = this.Sync(syncRequest);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R930
            Site.CaptureRequirementIfAreEqual<int>(
                4,
                int.Parse(syncResponse.ResponseData.Status),
                930,
                @"[In Class(Sync)] A Status element (section 2.2.3.162.16) value of 4 is returned if options for the same Class within the same Collection are redefined.");
        }
 /// <summary>
 /// Synchronize the changes from last synchronization in specific folder.
 /// </summary>
 /// <param name="syncKey">The sync key.</param>
 /// <param name="collectionID">Folder's collectionID.</param>
 /// <param name="isResyncNeeded">A boolean value indicate whether need to re-sync when the response contains MoreAvailable.</param>
 /// <returns>Sync response from the server.</returns>
 protected SyncResponse SyncChanges(string syncKey, string collectionID, bool isResyncNeeded = true)
 {
     SyncRequest syncRequest = TestSuiteBase.CreateEmptySyncRequest(collectionID);
     syncRequest.RequestData.Collections[0].SyncKey = syncKey;
     Request.Options options = new Request.Options();
     Request.BodyPreference bodyPreference = new Request.BodyPreference { Type = 1 };
     options.Items = new object[] { bodyPreference };
     options.ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.BodyPreference };
     syncRequest.RequestData.Collections[0].Options = new Request.Options[] { options };
     syncRequest.RequestData.Collections[0].GetChanges = true;
     syncRequest.RequestData.Collections[0].GetChangesSpecified = true;
     SyncResponse syncResponse = this.Sync(syncRequest, isResyncNeeded);
     return syncResponse;
 }
Esempio n. 19
0
        public void MSASCMD_S19_TC08_Sync_ConversationMode_Status4()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The ConversationMode element is not supported when the MS-ASProtocolVersion header is set to 12.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            SyncRequest syncRequest = TestSuiteBase.CreateEmptySyncRequest(this.User1Information.ContactsCollectionId);
            this.Sync(syncRequest);

            Request.Options option = new Request.Options
            {
                Items = new object[] { (byte)1 },
                ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.FilterType }
            };

            Request.SyncCollection collection = new Request.SyncCollection
            {
                SyncKey = this.LastSyncKey,
                Options = new Request.Options[] { option },
                CollectionId = this.User1Information.ContactsCollectionId,
                Commands = null,
                GetChanges = true,
                GetChangesSpecified = true,
                ConversationMode = true,
                ConversationModeSpecified = true
            };

            syncRequest.RequestData.Collections = new Request.SyncCollection[] { collection };
            SyncResponse syncResponse = this.Sync(syncRequest);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R2117
            Site.CaptureRequirementIfAreEqual<int>(
                4,
                int.Parse(syncResponse.ResponseData.Status),
                2117,
                @"[In ConversationMode(Sync)] Specifying the ConversationMode element for collections that do not store emails results in an invalid XML error, Status element (section 2.2.3.162.16) value 4.");
        }
Esempio n. 20
0
        /// <summary>
        /// Get the size of the Data of an email's Body.
        /// </summary>
        /// <param name="emailSubject">The email's subject.</param>
        /// <param name="valueOfMIMETruncation">The value of MIMETruncation, which is in the range of [1,7].</param>
        /// <returns>The size of the Data of the email's Body.</returns>
        private int GetEmailBodyDataSize(string emailSubject, byte valueOfMIMETruncation)
        {
            Site.Assert.IsTrue(!string.IsNullOrEmpty(emailSubject), "The email subject should not be null or empty.");
            Site.Assert.IsTrue(0 < valueOfMIMETruncation && valueOfMIMETruncation < 8, "The value of MIMETruncation should be in the range of [1,7]");

            Request.BodyPreference bodyPreference = new Request.BodyPreference { Type = 4 };

            Request.Options option = new Request.Options
            {
                Items = new object[] { (byte)2, bodyPreference, valueOfMIMETruncation },
                ItemsElementName =
                    new Request.ItemsChoiceType1[]
                    {
                        Request.ItemsChoiceType1.MIMESupport, Request.ItemsChoiceType1.BodyPreference,
                        Request.ItemsChoiceType1.MIMETruncation
                    }
            };

            SyncResponse syncResponse = this.CheckEmail(this.User2Information.InboxCollectionId, emailSubject, new Request.Options[] { option });

            Response.Body mailBody = GetMailBody(syncResponse, emailSubject);
            Site.Assert.IsNotNull(mailBody, "The body of the received email should not be null.");
            Site.Assert.IsNotNull(mailBody.Data, "The Data of the received email's body should not be null.");

            return mailBody.Data.Length;
        }
Esempio n. 21
0
        public void MSASCMD_S19_TC44_Sync_MIMESupport()
        {
            #region Send an email to User2.
            string emailSubject = Common.GenerateResourceName(Site, "subject");
            string emailContent = new string('X', 102500);
            this.SendPlainTextEmail(null, emailSubject, this.User1Information.UserName, this.User2Information.UserName, emailContent);
            #endregion

            this.SwitchUser(this.User2Information);
            TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, emailSubject);
            this.CheckEmail(this.User2Information.InboxCollectionId, emailSubject, null);

            Request.BodyPreference bodyPreference = new Request.BodyPreference { Type = 4 };

            Request.Options option = new Request.Options
            {
                Items = new object[] { (byte)2, bodyPreference, (byte)1 },
                ItemsElementName =
                    new Request.ItemsChoiceType1[]
                    {
                        Request.ItemsChoiceType1.MIMESupport, Request.ItemsChoiceType1.BodyPreference,
                        Request.ItemsChoiceType1.MIMETruncation
                    }
            };

            SyncResponse syncResponse = this.CheckEmail(this.User2Information.InboxCollectionId, emailSubject, new Request.Options[] { option });
            Site.Assert.AreEqual<uint>(1, Convert.ToUInt32(TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Status)), "The Status of the Sync command response should be 1.");
            Response.Body mailBody = GetMailBody(syncResponse, emailSubject);
            Site.Assert.IsNotNull(mailBody, "The body of the received email should not be null.");
            Site.Assert.AreEqual<byte>(4, mailBody.Type, "The type of the Body should be 4.");
            Site.Assert.IsTrue(mailBody.EstimatedDataSizeSpecified, "The EstimatedDataSize element should be present.");
            Site.Assert.IsTrue(mailBody.TruncatedSpecified, "The Truncated element should be present.");
            Site.Assert.IsNotNull(mailBody.Data, "The Data element of the Body should not be null.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R3409
            // When the Assert statements above are passed, the requirement is captured.
            Site.CaptureRequirement(
                3409,
                @"[In MIMESupport(Sync)] [The airsyncbase:Body element] MUST contain the following child elements [the airsyncbase:Type element, the airsyncbase:EstimatedDataSize element, the airsyncbase:Truncated element, the airsyncbase:Data element] in an S/MIME synchronization response.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R3410
            // When the Assert statements above are passed, the requirement is captured.
            Site.CaptureRequirementIfAreEqual<byte>(
                4,
                mailBody.Type,
                3410,
                @"[In MIMESupport(Sync)] 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.");
        }
Esempio n. 22
0
        public void MSASCMD_S19_TC43_Sync_MIMETruncation()
        {
            #region Send a MIME-formatted email to User2.
            string emailSubject = Common.GenerateResourceName(Site, "subject");
            string emailContent = new string('X', 102500);
            this.SendPlainTextEmail(null, emailSubject, this.User1Information.UserName, this.User2Information.UserName, emailContent);
            #endregion

            #region Switch the current user to User2.
            this.SwitchUser(this.User2Information);
            TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, emailSubject);
            #endregion

            #region Call Sync with MIMETruncation set to 8 to get complete MIME data.
            Request.BodyPreference bodyPreference = new Request.BodyPreference { Type = 4 };

            Request.Options option = new Request.Options
            {
                Items = new object[] { (byte)2, bodyPreference, (byte)8 },
                ItemsElementName =
                    new Request.ItemsChoiceType1[]
                    {
                        Request.ItemsChoiceType1.MIMESupport, Request.ItemsChoiceType1.BodyPreference,
                        Request.ItemsChoiceType1.MIMETruncation
                    }
            };

            SyncResponse syncResponse = this.CheckEmail(this.User2Information.InboxCollectionId, emailSubject, new Request.Options[] { option });

            Response.Body mailBody = GetMailBody(syncResponse, emailSubject);
            Site.Assert.IsNotNull(mailBody, "The body of the received email should not be null.");
            int dataLength = mailBody.Data.Length;

            option = new Request.Options
            {
                Items = new object[] { (byte)2, bodyPreference },
                ItemsElementName =
                    new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.MIMESupport, Request.ItemsChoiceType1.BodyPreference }
            };

            syncResponse = this.CheckEmail(this.User2Information.InboxCollectionId, emailSubject, new Request.Options[] { option });

            mailBody = GetMailBody(syncResponse, emailSubject);
            Site.Assert.IsNotNull(mailBody, "The body of the received email should not be null.");
            int original = mailBody.Data.Length;

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R3426
            Site.CaptureRequirementIfAreEqual<int>(
                original,
                dataLength,
                3426,
                @"[In MIMETruncation] Value 8 means Do not truncate; send complete MIME data.");
            #endregion

            #region Call Sync with MIMETruncation set to 0 to truncate all body text.
            option = new Request.Options
            {
                Items = new object[] { (byte)2, bodyPreference, (byte)0 },
                ItemsElementName =
                    new Request.ItemsChoiceType1[]
                    {
                        Request.ItemsChoiceType1.MIMESupport, Request.ItemsChoiceType1.BodyPreference,
                        Request.ItemsChoiceType1.MIMETruncation
                    }
            };

            syncResponse = this.CheckEmail(this.User2Information.InboxCollectionId, emailSubject, new Request.Options[] { option });

            mailBody = GetMailBody(syncResponse, emailSubject);
            Site.Assert.IsNotNull(mailBody, "The body of the received email should not be null.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R3418
            Site.CaptureRequirementIfIsNull(
                mailBody.Data,
                3418,
                @"[In MIMETruncation] Value 0 means Truncate all body text.");
            #endregion

            #region Call Sync with MIMETruncation set to 1 to truncate text over 4096 charaters.
            int dataSize = this.GetEmailBodyDataSize(emailSubject, 1);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R3419
            Site.CaptureRequirementIfAreEqual<int>(
                4096,
                dataSize,
                3419,
                @"[In MIMETruncation] Value 1 means Truncate text over 4,096 characters.");
            #endregion

            #region Call Sync with MIMETruncation set to 2 to truncate text over 5120 charaters.
            dataSize = this.GetEmailBodyDataSize(emailSubject, 2);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R3420
            Site.CaptureRequirementIfAreEqual<int>(
                5120,
                dataSize,
                3420,
                @"[In MIMETruncation] Value 2 means Truncate text over 5,120 characters.");
            #endregion

            #region Call Sync with MIMETruncation set to 3 to truncate text over 7168 charaters.
            dataSize = this.GetEmailBodyDataSize(emailSubject, 3);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R3421
            Site.CaptureRequirementIfAreEqual<int>(
                7168,
                dataSize,
                3421,
                @"[In MIMETruncation] Value 3 means Truncate text over 7,168 characters.");
            #endregion

            #region Call Sync with MIMETruncation set to 4 to truncate text over 10240 charaters.
            dataSize = this.GetEmailBodyDataSize(emailSubject, 4);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R3422
            Site.CaptureRequirementIfAreEqual<int>(
                10240,
                dataSize,
                3422,
                @"[In MIMETruncation] Value 4 means Truncate text over 10,240 characters.");
            #endregion

            #region Call Sync with MIMETruncation set to 5 to truncate text over 20480 charaters.
            dataSize = this.GetEmailBodyDataSize(emailSubject, 5);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R3423
            Site.CaptureRequirementIfAreEqual<int>(
                20480,
                dataSize,
                3423,
                @"[In MIMETruncation] Value 5 means Truncate text over 20,480 characters.");
            #endregion

            #region Call Sync with MIMETruncation set to 6 to truncate text over 51200 charaters.
            dataSize = this.GetEmailBodyDataSize(emailSubject, 6);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R3424
            Site.CaptureRequirementIfAreEqual<int>(
                51200,
                dataSize,
                3424,
                @"[In MIMETruncation] Value 6 means Truncate text over 51,200 characters.");
            #endregion

            #region Call Sync with MIMETruncation set to 7 to truncate text over 102400 charaters.
            dataSize = this.GetEmailBodyDataSize(emailSubject, 7);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R3425
            Site.CaptureRequirementIfAreEqual<int>(
                102400,
                dataSize,
                3425,
                @"[In MIMETruncation] Value 7 means Truncate text over 102,400 characters.");
            #endregion
        }
Esempio n. 23
0
        public void MSASCMD_S19_TC40_Sync_Conflict()
        {
            Site.Assume.AreEqual<string>("Base64", Common.GetConfigurationPropertyValue("HeaderEncodingType", this.Site), "The device ID should be same across all requests, when the HeaderEncodingType is PlainText.");

            // Synchronize the changes in the Contacts folder.
            this.Sync(TestSuiteBase.CreateEmptySyncRequest(this.User1Information.ContactsCollectionId));

            #region Add a new contact item.
            string contactFileAS = Common.GenerateResourceName(Site, "FileAS");
            Request.SyncCollectionAdd addData = this.CreateAddContactCommand("FirstName", "MiddleName", "LastName", contactFileAS, null);

            SyncRequest syncRequest = TestSuiteBase.CreateSyncAddRequest(this.LastSyncKey, this.User1Information.ContactsCollectionId, addData);
            this.Sync(syncRequest, false);
            this.FolderSync();

            SyncResponse syncResponse = this.SyncChanges(this.User1Information.ContactsCollectionId);
            Site.Assert.IsNotNull(syncResponse.ResponseData.Item, "The items returned in the Sync command response should not be null.");
            string serverId = TestSuiteBase.FindServerId(syncResponse, "FileAs", contactFileAS);
            Site.Assert.IsNotNull(serverId, "The contact should exist in the Contact folder.");
            string syncKey = this.LastSyncKey;
            #endregion

            // Changed DeviceID
            CMDAdapter.ChangeDeviceID("Device2");
            this.RecordDeviceInfoChanged();

            #region Change the added contact item.
            this.FolderSync();
            syncResponse = this.SyncChanges(this.User1Information.ContactsCollectionId);

            string updatedContactFileAs = Common.GenerateResourceName(Site, "UpdatedFileAS");
            Request.SyncCollectionChange appDataChange1 = CreateChangedContact(TestSuiteBase.FindServerId(syncResponse, "FileAs", contactFileAS), new Request.ItemsChoiceType7[] { Request.ItemsChoiceType7.FileAs }, new object[] { updatedContactFileAs });
            syncRequest = CreateSyncChangeRequest(this.LastSyncKey, this.User1Information.ContactsCollectionId, appDataChange1);
            syncResponse = this.Sync(syncRequest);
            Site.Assert.AreEqual<uint>(1, Convert.ToUInt32(TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Status)), "The status code of Sync change operation should be 1.");
            TestSuiteBase.RecordCaseRelativeItems(this.User1Information, this.User1Information.ContactsCollectionId, updatedContactFileAs);
            #endregion

            #region Restore DeviceID and change the changed contact item again without Conflict option.
            CMDAdapter.ChangeDeviceID(Common.GetConfigurationPropertyValue("DeviceID", this.Site));
            this.FolderSync();

            string conflictUpdatedFileAs = Common.GenerateResourceName(Site, "ConflictUpdatedFileAS");
            Request.SyncCollectionChange appDataChange2 = CreateChangedContact(serverId, new Request.ItemsChoiceType7[] { Request.ItemsChoiceType7.FileAs }, new object[] { conflictUpdatedFileAs });
            syncRequest = CreateSyncChangeRequest(syncKey, this.User1Information.ContactsCollectionId, appDataChange2);
            syncResponse = this.Sync(syncRequest, false);
            Site.Assert.IsNotNull(syncResponse.ResponseData.Item, "The collections in the Sync response should not be null.");

            bool isReplacedByServerData = false;
            Response.SyncCollectionsCollectionCommands commands = TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Commands) as Response.SyncCollectionsCollectionCommands;
            Site.Assert.IsNotNull(commands.Change, "The Change element should not be null.");
            Site.Assert.IsTrue(commands.Change.Length > 0, "The Change element should contain one item at least.");
            Site.Assert.IsNotNull(commands.Change[0].ApplicationData, "The ApplicationData should not be null.");
            Site.Assert.IsNotNull(commands.Change[0].ApplicationData.ItemsElementName, "The ItemsElementName of the ApplicationData should not be null.");
            Site.Assert.IsTrue(commands.Change[0].ApplicationData.ItemsElementName.Length > 0, "The ItemsElementName should contains one item at least.");
            for (int i = 0; i < commands.Change[0].ApplicationData.ItemsElementName.Length; i++)
            {
                if (commands.Change[0].ApplicationData.ItemsElementName[i].ToString() == "FileAs" && commands.Change[0].ApplicationData.Items[i].ToString() == updatedContactFileAs)
                {
                    isReplacedByServerData = true;
                    break;
                }
            }

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R2066
            Site.CaptureRequirementIfIsTrue(
                isReplacedByServerData,
                2066,
                @"[In Conflict] If the Conflict element is not present, the server object will replace the client object when a conflict occurs.");
            #endregion

            #region Change the changed contact item again with Conflict option of value 1.
            Request.Options option = new Request.Options
            {
                Items = new object[] { (byte)1 },
                ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.Conflict }
            };

            syncRequest.RequestData.Collections[0].Options = new Request.Options[] { option };
            syncResponse = this.Sync(syncRequest, false);
            Site.Assert.IsNotNull(syncResponse.ResponseData.Item, "The collections in the Sync response should not be null.");

            Response.SyncCollectionsCollectionResponses responses = TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Responses) as Response.SyncCollectionsCollectionResponses;
            Site.Assert.IsNotNull(responses, "The Response element should not be null.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R2069
            Site.CaptureRequirementIfAreEqual<int>(
                7,
                int.Parse(responses.Change[0].Status),
                2069,
                @"[In Conflict] If the value is 1 and there is a conflict, a Status element (section 2.2.3.162.16) value of 7 is returned to inform the client that the object that the client sent to the server was discarded.");

            isReplacedByServerData = false;
            commands = TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Commands) as Response.SyncCollectionsCollectionCommands;
            for (int i = 0; i < commands.Change[0].ApplicationData.ItemsElementName.Length; i++)
            {
                if (commands.Change[0].ApplicationData.ItemsElementName[i] == Response.ItemsChoiceType7.FileAs && commands.Change[0].ApplicationData.Items[i].ToString() == updatedContactFileAs)
                {
                    isReplacedByServerData = true;
                    break;
                }
            }

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R4444
            Site.CaptureRequirementIfIsTrue(
                isReplacedByServerData,
                4444,
                @"[In Status(Sync)] [When the scope is Item], [the cause of the status value 7 is] The client has changed an item for which the conflict policy indicates that the server's changes take precedence.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R2068
            Site.CaptureRequirementIfIsTrue(
                isReplacedByServerData,
                2068,
                @"[In Conflict] A value of 1 means to keep the server object.");
            #endregion

            #region Change the changed contact item again with Conflict option of value 0.
            option.Items = new object[] { (byte)0 };
            option.ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.Conflict };

            syncRequest.RequestData.Collections[0].Options = new Request.Options[] { option };
            syncResponse = this.Sync(syncRequest);
            Site.Assert.IsNotNull(syncResponse.ResponseData.Item, "The collections in the Sync response should not be null.");
            Site.Assert.AreEqual<uint>(1, Convert.ToUInt32(TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Status)), "The Sync change operation should be successful.");

            TestSuiteBase.RecordCaseRelativeItems(this.User1Information, this.User1Information.ContactsCollectionId, conflictUpdatedFileAs);

            syncResponse = this.SyncChanges(this.User1Information.ContactsCollectionId);
            Site.Assert.IsNotNull(syncResponse.ResponseData.Item, "The collections in the Sync response should not be null");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R2067
            Site.CaptureRequirementIfIsNotNull(
                TestSuiteBase.FindServerId(syncResponse, "FileAs", conflictUpdatedFileAs),
                2067,
                @"[In Conflict] A value of 0 (zero) means to keep the client object.");
            #endregion
        }
        /// <summary>
        /// Get estimate number of items in specified time window depends on FilterType in a collection.
        /// </summary>
        /// <param name="collectionId">Specifies collection id of the folder.</param>
        /// <param name="filterType">Specifies time window for the objects sent from the server to the client.</param>
        /// <returns>GetItemEstimate command response.</returns>
        private GetItemEstimateResponse GetItemEstimateWithFilterType(string collectionId, byte filterType)
        {
            Request.Options option = new Request.Options
            {
                Items = new object[] { filterType },
                ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.FilterType }
            };

            return this.CMDAdapter.GetItemEstimate(TestSuiteBase.CreateGetItemEstimateRequest(this.LastSyncKey, collectionId, new Request.Options[] { option }));
        }
        /// <summary>
        /// Build a generic Sync request without command references by using the specified sync key, folder collection ID and body preference option.
        /// If syncKey is 
        /// In general, returns the XML formatted Sync request as follows:
        /// <!--
        /// <?xml version="1.0" encoding="utf-8"?>
        /// <Sync xmlns="AirSync">
        ///   <Collections>
        ///     <Collection>
        ///       <SyncKey>0</SyncKey>
        ///       <CollectionId>5</CollectionId>
        ///       <DeletesAsMoves>1</DeletesAsMoves>
        ///       <GetChanges>1</GetChanges>
        ///       <WindowSize>100</WindowSize>
        ///       <Options>
        ///         <MIMESupport>0</MIMESupport>
        ///         <airsyncbase:BodyPreference>
        ///           <airsyncbase:Type>2</airsyncbase:Type>
        ///           <airsyncbase:TruncationSize>5120</airsyncbase:TruncationSize>
        ///         </airsyncbase:BodyPreference>
        ///       </Options>
        ///     </Collection>
        ///   </Collections>
        /// </Sync>
        /// -->
        /// </summary>
        /// <param name="syncKey">Specify the sync key obtained from the last sync response(Refer to [MS-ASCMD]2.2.3.166.4)</param>
        /// <param name="collectionId">Specify the server ID of the folder to be synchronized, which can be returned by ActiveSync FolderSync command(Refer to [MS-ASCMD]2.2.3.30.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>
        /// <returns>Returns the SyncRequest instance</returns>
        internal static SyncRequest CreateSyncRequest(string syncKey, string collectionId, Request.BodyPreference bodyPreference)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                SyncKey = syncKey,
                CollectionId = collectionId
            };

            if (syncKey != "0")
            {
                syncCollection.GetChanges = true;
                syncCollection.GetChangesSpecified = true;
            }

            syncCollection.WindowSize = "100";

            Request.Options syncOptions = new Request.Options();
            List<object> syncOptionItems = new List<object>();
            List<Request.ItemsChoiceType1> syncOptionItemsName = new List<Request.ItemsChoiceType1>();

            if (null != bodyPreference)
            {
                syncOptionItemsName.Add(Request.ItemsChoiceType1.BodyPreference);
                syncOptionItems.Add(bodyPreference);

                // when body format is mime (Refer to [MS-ASAIRS] 2.2.2.22 Type)
                if (bodyPreference.Type == 0x4)
                {
                    syncOptionItemsName.Add(Request.ItemsChoiceType1.MIMESupport);

                    // Magic number '2' indicate server send MIME data for all messages but not S/MIME messages only
                    syncOptionItems.Add((byte)0x2);
                }
            }

            syncOptions.Items = syncOptionItems.ToArray();
            syncOptions.ItemsElementName = syncOptionItemsName.ToArray();
            syncCollection.Options = new Request.Options[] { syncOptions };

            return Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
        }
        public void MSASCMD_S07_TC08_GetItemEstimate_MoreThanOneMaxItems()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Options element is not supported when the MS-ASProtocolVersion header is set to 12.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region Call Sync command with 2 MaxItems elements on RI.
            this.Sync(TestSuiteBase.CreateEmptySyncRequest(this.User1Information.RecipientInformationCacheCollectionId));

            Request.Options option = new Request.Options
            {
                Items = new object[] { "2", "3" },
                ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.MaxItems, Request.ItemsChoiceType1.MaxItems }
            };

            GetItemEstimateRequest getItemEstimateRequest = TestSuiteBase.CreateGetItemEstimateRequest(this.LastSyncKey, this.User1Information.RecipientInformationCacheCollectionId, new Request.Options[] { option });
            GetItemEstimateResponse getItemEstimateResponse = CMDAdapter.GetItemEstimate(getItemEstimateRequest);

            if (Common.IsRequirementEnabled(3272, this.Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R3272");

                // Verify MS-ASCMD requirement: MS-ASCMD_R3272
                Site.CaptureRequirementIfAreEqual<int>(
                    1,
                    int.Parse(getItemEstimateResponse.ResponseData.Response[0].Status),
                    3272,
                    @"[In Appendix A: Product Behavior] The implementation does not return a protocol status error in response to such a command request [more than one airsync:MaxItems element as the child of the airsync:Options element is undefined]. (Exchange 2007 and above follow this behavior.)");
            }
            #endregion
        }
        public void MSASCMD_S07_TC11_GetItemEstimate_Status4_InvalidSyncKey()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Options element is not supported when the MS-ASProtocolVersion header is set to 12.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            this.Sync(TestSuiteBase.CreateEmptySyncRequest(this.User1Information.InboxCollectionId));

            #region Call method GetItemEstimate with an invalid SyncKey.
            string invalidSyncKey = Common.GenerateResourceName(Site, "InvalidSyncKey");

            Request.Options option = new Request.Options
            {
                Items = new object[] { "Email" },
                ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.Class }
            };

            GetItemEstimateRequest getItemEstimateRequest = TestSuiteBase.CreateGetItemEstimateRequest(invalidSyncKey, this.User1Information.InboxCollectionId, new Request.Options[] { option });
            GetItemEstimateResponse getItemEstimateResponse = CMDAdapter.GetItemEstimate(getItemEstimateRequest);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R4142
            Site.CaptureRequirementIfAreEqual<int>(
                4,
                int.Parse(getItemEstimateResponse.ResponseData.Response[0].Status),
                4142,
                @"[In Status(GetItemEstimate)] [When the scope is] Global, [the meaning of the status value] 4 [is] The specified synchronization key was invalid.");
            #endregion
        }
        public void MSASCMD_S20_TC01_ValidateCert_Success()
        {
            #region Switch to User9 mail account, the inbox had received a S/MIME mail.

            this.SwitchUser(this.User9Information);

            #endregion

            #region Call method Sync to synchronize changes of Inbox folder in User9's mailbox between the client and the server, and get the body content of the email item.

            string emailSubject = Common.GetConfigurationPropertyValue("MIMEMailSubject", this.Site);

            Request.BodyPreference bodyPreference = new Request.BodyPreference
            {
                AllOrNone               = false,
                AllOrNoneSpecified      = true,
                TruncationSize          = 4294967295,
                TruncationSizeSpecified = true,
                Type = 4
            };

            Request.Options option = new Request.Options
            {
                Items            = new object[] { (byte)2, bodyPreference, (byte)8 },
                ItemsElementName = new Request.ItemsChoiceType1[]
                {
                    Request.ItemsChoiceType1.MIMESupport,
                    Request.ItemsChoiceType1.BodyPreference, Request.ItemsChoiceType1.MIMETruncation
                }
            };

            SyncResponse  syncResponse = this.CheckEmail(this.User9Information.InboxCollectionId, emailSubject, new Request.Options[] { option });
            Response.Body mailBody     = null;
            Response.SyncCollectionsCollectionCommandsAddApplicationData applicationData = TestSuiteBase.GetAddApplicationData(syncResponse, Response.ItemsChoiceType8.Subject1, emailSubject);
            for (int i = 0; i < applicationData.ItemsElementName.Length; i++)
            {
                if (applicationData.ItemsElementName[i] == Response.ItemsChoiceType8.Body)
                {
                    mailBody = applicationData.Items[i] as Response.Body;
                    break;
                }
            }

            Site.Assert.IsNotNull(mailBody, "The body of the received email should not be null.");

            string specifiedString = "MIME-Version: 1.0";
            string body            = mailBody.Data.Substring(
                mailBody.Data.IndexOf(specifiedString, StringComparison.CurrentCultureIgnoreCase) + specifiedString.Length);
            body = body.Replace("\r", string.Empty);
            body = body.Replace("\n", string.Empty);

            Request.ValidateCert validateCert = new Request.ValidateCert
            {
                CheckCrl     = "1",
                Certificates = new byte[][] { System.Text.Encoding.Default.GetBytes(body) }
            };

            ValidateCertRequest validateRequest = new ValidateCertRequest {
                RequestData = validateCert
            };

            ValidateCertResponse validateResponse = this.CMDAdapter.ValidateCert(validateRequest);

            XmlNodeList status = this.GetValidateCertStatusCode(validateResponse);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R4474
            Site.CaptureRequirementIfAreEqual <string>(
                "1",
                status[0].InnerText,
                4474,
                @"[In Status(ValidateCert)] [When the scope is Global], [the cause of the status value 1 is] Server successfully completed command.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R5387
            Site.CaptureRequirementIfAreEqual <string>(
                "1",
                status[0].InnerText,
                5387,
                @"[In Status(ValidateCert)] A value of 1 indicates success.");
            #endregion
        }
Esempio n. 29
0
        public void MSASCMD_S19_TC18_Sync_SMIME()
        {
            #region Call method SendMail to send MIME-formatted e-mail messages to the server.
            string emailSubject = Common.GenerateResourceName(Site, "subject");
            this.SendPlainTextEmail(null, emailSubject, this.User1Information.UserName, this.User2Information.UserName, null);
            #endregion

            this.SwitchUser(this.User2Information);

            #region Synchronize the changes in the Inbox folder.
            TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, emailSubject);
            SyncRequest syncRequest = TestSuiteBase.CreateEmptySyncRequest(this.User2Information.InboxCollectionId);
            this.Sync(syncRequest);

            Request.BodyPreference bodyPreference = new Request.BodyPreference { Type = 4 };

            Request.Options options = new Request.Options
            {
                Items = new object[] { bodyPreference, (byte)1 },
                ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.BodyPreference, Request.ItemsChoiceType1.MIMESupport }
            };

            syncRequest.RequestData.Collections[0].SyncKey = this.LastSyncKey;
            syncRequest.RequestData.Collections[0].Options = new Request.Options[] { options };
            syncRequest.RequestData.Collections[0].GetChanges = true;
            syncRequest.RequestData.Collections[0].GetChangesSpecified = true;
            SyncResponse syncResponse = this.Sync(syncRequest);

            int counter = 0;
            int retryCount = int.Parse(Common.GetConfigurationPropertyValue("RetryCount", this.Site));
            int waitTime = int.Parse(Common.GetConfigurationPropertyValue("WaitTime", this.Site));
            string serverId = TestSuiteBase.FindServerId(syncResponse, "Subject", emailSubject);
            while ((counter < retryCount) && string.IsNullOrEmpty(serverId))
            {
                System.Threading.Thread.Sleep(waitTime);
                syncResponse = this.Sync(syncRequest);
                serverId = TestSuiteBase.FindServerId(syncResponse, "Subject", emailSubject);
                counter++;
            }

            Site.Assert.IsNotNull(syncResponse.ResponseData.Item, "The items returned in the Sync command response should not be null.");

            Response.SyncCollectionsCollectionCommands syncCollectionsCollectionCommands = TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Commands) as Response.SyncCollectionsCollectionCommands;
            bool isR3408Satisfied = false;
            foreach (Response.ItemsChoiceType8 element in syncCollectionsCollectionCommands.Add[0].ApplicationData.ItemsElementName)
            {
                if (element == Response.ItemsChoiceType8.Body)
                {
                    isR3408Satisfied = true;
                    break;
                }
            }

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R3408
            Site.CaptureRequirementIfIsTrue(
                isR3408Satisfied,
                3408,
                @"[In MIMESupport(Sync)] When handling S/MIME content in the response, the server MUST include the airsyncbase:Body element ([MS-ASAIRS] section 2.2.2.4), which is a child of the ApplicationData element (section 2.2.3.11).");
            #endregion
        }
Esempio n. 30
0
        public void MSASCMD_S19_TC23_Sync_MoreThanOneMIMETruncation()
        {
            #region Send a MIME-formatted email to User2.
            string emailSubject = Common.GenerateResourceName(Site, "subject");
            this.SendPlainTextEmail(null, emailSubject, this.User1Information.UserName, this.User2Information.UserName, null);
            #endregion

            this.SwitchUser(this.User2Information);
            TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, emailSubject);
            this.CheckEmail(this.User2Information.InboxCollectionId, emailSubject, null);

            // Call Sync with two MIMETruncation options
            Request.Options option = new Request.Options
            {
                Items = new object[] { (byte)2, (byte)3 },
                ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.MIMETruncation, Request.ItemsChoiceType1.MIMETruncation }
            };

            SyncResponse syncResponse = this.SyncChangesWithOption(this.User2Information.InboxCollectionId, option);
            Site.Assert.IsNotNull(syncResponse.ResponseData, "The ResponseData should not be null.");
            Site.Assert.IsNotNull(TestSuiteBase.FindServerId(syncResponse, "Subject", emailSubject), "The email should be in the Inbox folder of User2.");

            if (Common.IsRequirementEnabled(3432, this.Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R3432");

                // Verify MS-ASCMD requirement: MS-ASCMD_R3432
                Site.CaptureRequirementIfAreEqual<uint>(
                    1,
                    Convert.ToUInt32(TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Status)),
                    3432,
                    @"[In Appendix A: Product Behavior] The implementation does not return a protocol status error in response to such a command request [more than one MIMETruncation element as the child element of the Options element is undefined]. (Exchange 2007 and above follow this behavior.)");
            }
        }
        public void MSASCMD_S07_TC02_GetItemEstimate_WithoutOptions()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Options element is not supported when the MS-ASProtocolVersion header is set to 12.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region Call method GetItemEstiamte with filters within the airsync:Options container to Email class to get an estimate of the number of the items in the Inbox folder.
            this.Sync(TestSuiteBase.CreateEmptySyncRequest(this.User1Information.InboxCollectionId));
            Request.Options option = new Request.Options
            {
                Items = new object[] { "Email" },
                ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.Class }
            };

            GetItemEstimateRequest getItemEstimateRequest = TestSuiteBase.CreateGetItemEstimateRequest(this.LastSyncKey, this.User1Information.InboxCollectionId, new Request.Options[] { option });
            GetItemEstimateResponse getItemEstimateResponse = CMDAdapter.GetItemEstimate(getItemEstimateRequest);
            #endregion

            #region Call method GetItemEstimate without Options element to get an estimate of the number of items in the Inbox folder on server.
            getItemEstimateRequest = TestSuiteBase.CreateGetItemEstimateRequest(this.LastSyncKey, this.User1Information.InboxCollectionId, null);
            GetItemEstimateResponse getItemEstimateResponseNoOption = CMDAdapter.GetItemEstimate(getItemEstimateRequest);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R3543
            Site.CaptureRequirementIfAreEqual<string>(
                getItemEstimateResponse.ResponseData.Response[0].Collection.Estimate,
                getItemEstimateResponseNoOption.ResponseData.Response[0].Collection.Estimate,
                3543,
                @"[In Options(GetItemEstimate)] If the airsync:Options element is not included in a request, then the GetItemEstimate command (section 2.2.2.7) will enumerate all of the items within the collection, without any filter (up to a maximum of 512 items).");
            #endregion
        }
        /// <summary>
        /// Build a generic Sync request without command references by using the specified sync key, folder collection ID and body preference option.
        /// In general, returns the XML formatted Sync request as follows:
        /// <!--
        /// <?xml version="1.0" encoding="utf-8"?>
        /// <Sync xmlns="AirSync">
        ///   <Collections>
        ///     <Collection>
        ///       <SyncKey>0</SyncKey>
        ///       <CollectionId>5</CollectionId>
        ///       <DeletesAsMoves>1</DeletesAsMoves>
        ///       <GetChanges>1</GetChanges>
        ///       <WindowSize>152</WindowSize>
        ///       <Options>
        ///         <MIMESupport>0</MIMESupport>
        ///         <airsyncbase:BodyPreference>
        ///           <airsyncbase:Type>2</airsyncbase:Type>
        ///         </airsyncbase:BodyPreference>
        ///       </Options>
        ///     </Collection>
        ///   </Collections>
        /// </Sync>
        /// -->
        /// </summary>
        /// <param name="collectionId">Specify the server ID of the folder to be synchronized, which can be returned by ActiveSync FolderSync command(Refer to [MS-ASCMD]2.2.3.30.5)</param>
        /// <param name="syncKey">Specify the sync key obtained from the last sync response(Refer to [MS-ASCMD]2.2.3.166.4)</param>
        /// <param name="getChanges">Sets sync collection information related to the GetChanges</param>
        /// <returns>Returns the SyncRequest instance</returns>
        internal static SyncRequest CreateSyncRequest(string collectionId, string syncKey, bool getChanges)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                WindowSize = "512",
                SyncKey = syncKey,
                CollectionId = collectionId,
                Supported = null
            };

            if (getChanges)
            {
                syncCollection.GetChanges = true;
                syncCollection.GetChangesSpecified = true;
            }

            Request.Options syncOptions = new Request.Options();
            List<object> syncOptionItems = new List<object>();
            List<Request.ItemsChoiceType1> syncOptionItemsName = new List<Request.ItemsChoiceType1>
            {
                Request.ItemsChoiceType1.BodyPreference
            };

            syncOptionItems.Add(
                new Request.BodyPreference()
                {
                    Type = 2,
                    TruncationSize = 0,
                    TruncationSizeSpecified = false,
                    Preview = 0,
                    PreviewSpecified = false
                });
            syncOptions.Items = syncOptionItems.ToArray();
            syncOptions.ItemsElementName = syncOptionItemsName.ToArray();
            syncCollection.Options = new Request.Options[] { syncOptions };

            return Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
        }
        public void MSASCMD_S07_TC14_GetItemEstimate_WithCombinationClasses()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Options element is not supported when the MS-ASProtocolVersion header is set to 12.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            this.Sync(TestSuiteBase.CreateEmptySyncRequest(this.User1Information.InboxCollectionId));

            #region Call GetItemEstimate to get the number of both Email and SMS messages.
            Request.Options option1 = new Request.Options
            {
                Items = new object[] { "Email" },
                ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.Class }
            };

            Request.Options option2 = new Request.Options
            {
                Items = new object[] { "SMS" },
                ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.Class }
            };

            GetItemEstimateRequest getItemEstimateRequest = TestSuiteBase.CreateGetItemEstimateRequest(this.LastSyncKey, this.User1Information.InboxCollectionId, new Request.Options[] { option1, option2 });
            GetItemEstimateResponse getItemEstimateResponse = CMDAdapter.GetItemEstimate(getItemEstimateRequest);
            Site.Assert.IsNotNull(getItemEstimateResponse.ResponseData.Response, "The response of GetItemEstimate command should not be null.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R907
            Site.CaptureRequirementIfAreEqual<int>(
                1,
                int.Parse(getItemEstimateResponse.ResponseData.Response[0].Status),
                907,
                @"[In Class(GetItemEstimate)] Only SMS messages and email messages can be synchronized at the same time.");
            #endregion
        }
Esempio n. 34
0
        public void MSASCMD_S19_TC22_Sync_MoreThanOneMIMESupport()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Options element is not supported when the MS-ASProtocolVersion header is set to 12.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region Send a MIME-formatted email to User2.
            string emailSubject = Common.GenerateResourceName(Site, "subject");
            this.SendPlainTextEmail(null, emailSubject, this.User1Information.UserName, this.User2Information.UserName, null);
            #endregion

            this.SwitchUser(this.User2Information);
            TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, emailSubject);
            this.CheckEmail(this.User2Information.InboxCollectionId, emailSubject, null);

            Request.Options option = new Request.Options
            {
                Items = new object[] { (byte)0, (byte)1 },
                ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.MIMESupport, Request.ItemsChoiceType1.MIMESupport }
            };

            SyncResponse syncResponse = this.SyncChangesWithOption(this.User2Information.InboxCollectionId, option);
            Site.Assert.IsNotNull(syncResponse.ResponseData, "The ResponseData should not be null.");
            Site.Assert.IsNotNull(TestSuiteBase.FindServerId(syncResponse, "Subject", emailSubject), "The email should be in the Inbox folder of User2.");

            if (Common.IsRequirementEnabled(3404, this.Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R3404");

                // Verify MS-ASCMD requirement: MS-ASCMD_R3404
                Site.CaptureRequirementIfAreEqual<uint>(
                    1,
                    Convert.ToUInt32(TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Status)),
                    3404,
                    @"[In Appendix A: Product Behavior] The implementation does not return a protocol status error in response to such a command request [more than one MIMESupport element as the child element of the Options element]. (Exchange 2007 and above follow this behavior.)");
            }
        }
        public void MSASCMD_S07_TC15_GetItemEstimate_Collection_LimitValue()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Options element is not supported when the MS-ASProtocolVersion header is set to 12.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region Send an email from user1 to user2.
            string emailSubject = Common.GenerateResourceName(Site, "subject");
            this.SendPlainTextEmail(null, emailSubject, this.User1Information.UserName, this.User2Information.UserName, null);

            this.SwitchUser(this.User2Information);
            this.CheckEmail(this.User2Information.InboxCollectionId, emailSubject, null);
            TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, emailSubject);
            #endregion

            #region Create 1001 objects of GetItemEstimateCollection type for GetItemEstimate command.
            Request.Options option = new Request.Options
            {
                Items = new object[] { "Email" },
                ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.Class }
            };

            List<Request.GetItemEstimateCollection> collections = new List<Request.GetItemEstimateCollection>();
            for (int i = 0; i <= 1000; i++)
            {
                Request.GetItemEstimateCollection collection = new Request.GetItemEstimateCollection
                {
                    CollectionId = this.User2Information.InboxCollectionId,
                    SyncKey = this.LastSyncKey,
                    Options = new Request.Options[] { option }
                };

                collections.Add(collection);
            }

            GetItemEstimateRequest getItemEstimateRequest = Common.CreateGetItemEstimateRequest(collections.ToArray());
            GetItemEstimateResponse getItemEstimateResponse = this.CMDAdapter.GetItemEstimate(getItemEstimateRequest);
            Site.Assert.IsNotNull(getItemEstimateResponse.ResponseData, "The response data of GetItemEstimate command should not be null.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R5647
            Site.CaptureRequirementIfAreEqual<int>(
                103,
                int.Parse(getItemEstimateResponse.ResponseData.Status),
                5647,
                @"[In Limiting Size of Command Requests] In GetItemEstimate (section 2.2.2.7) command request, when the limit value of Collection element is bigger than 1000 (minimum 30, maximum 5000), the error returned by server is Status element (section 2.2.3.162.6) value of 103.");
            #endregion
        }
Esempio n. 36
0
        public void MSASCMD_S19_TC21_Sync_MoreThanOneMaxItems()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The MaxItems element is not supported when the MS-ASProtocolVersion header is set to 12.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            Request.Options option = new Request.Options
            {
                Items = new object[] { "2", "3" },
                ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.MaxItems, Request.ItemsChoiceType1.MaxItems }
            };

            SyncResponse syncResponse = this.SyncChangesWithOption(this.User1Information.RecipientInformationCacheCollectionId, option);

            if (Common.IsRequirementEnabled(3280, this.Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R3280");

                // Verify MS-ASCMD requirement: MS-ASCMD_R3280
                Site.CaptureRequirementIfAreEqual<uint>(
                    1,
                    Convert.ToUInt32(TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Status)),
                    3280,
                    @"[In Appendix A: Product Behavior] The implementation does not return a protocol status error in response to such a command request [more than one MaxItems element as the child element of the Options element]. (Exchange 2007 and above follow this behavior.)");
            }
        }
        public void MSASCMD_S07_TC16_GetItemEstimate_WithStatusValue4Returned()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Options element is not supported when the MS-ASProtocolVersion header is set to 12.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            this.Sync(TestSuiteBase.CreateEmptySyncRequest(this.User1Information.InboxCollectionId));

            #region Call GetItemEstimate to get the number of both Email and SMS messages.
            Request.Options option1 = new Request.Options
            {
                Items = new object[] { "Tasks" },
                ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.Class }
            };

            Request.Options option2 = new Request.Options
            {
                Items = new object[] { "Contacts" },
                ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.Class }
            };

            GetItemEstimateRequest getItemEstimateRequest = TestSuiteBase.CreateGetItemEstimateRequest(this.LastSyncKey, this.User1Information.InboxCollectionId, new Request.Options[] { option1, option2 });
            GetItemEstimateResponse getItemEstimateResponse = CMDAdapter.GetItemEstimate(getItemEstimateRequest);
            
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R908");

            Site.CaptureRequirementIfAreEqual<int>(
                4,
                int.Parse(getItemEstimateResponse.ResponseData.Status),
                908,
                @"[In Class(GetItemEstimate)] A request for any other combination of classes will fail with a status value of 4.");
            #endregion
        }
        public void MSASCMD_S07_TC12_GetItemEstimate_Status4_MismatchedSyncKey()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Options element is not supported when the MS-ASProtocolVersion header is set to 12.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            this.Sync(TestSuiteBase.CreateEmptySyncRequest(this.User1Information.ContactsCollectionId));
            string unmatchedSyncKey = this.LastSyncKey;

            #region Call Sync command on the Inbox folder.
            SyncRequest syncRequest = TestSuiteBase.CreateEmptySyncRequest(this.User1Information.InboxCollectionId);
            this.Sync(syncRequest);
            #endregion

            #region Call method GetItemEstimate with a SyncKey that does not match the expected value.
            Request.Options option = new Request.Options
            {
                Items = new object[] { "Email" },
                ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.Class }
            };

            GetItemEstimateRequest getItemEstimateRequest = TestSuiteBase.CreateGetItemEstimateRequest(unmatchedSyncKey, this.User1Information.InboxCollectionId, new Request.Options[] { option });
            GetItemEstimateResponse getItemEstimateResponse = CMDAdapter.GetItemEstimate(getItemEstimateRequest);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R4594
            Site.CaptureRequirementIfAreEqual<int>(
                4,
                int.Parse(getItemEstimateResponse.ResponseData.Response[0].Status),
                4594,
                @"[In SyncKey(GetItemEstimate)] The server MUST provide a Status element (section 2.2.3.162.6) value of 4 if the airsync:SyncKey value provided in the GetItemEstimate request does not match those expected within the next Sync command request (section 2.2.2.19).");
            #endregion
        }
Esempio n. 39
0
        public void MSASCMD_S19_TC42_Sync_WithCombinationClasses()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Class element is not supported as a child element of the Options element when the ActiveSyncProtocolVersion is 12.1.");

            #region Send a MIME-formatted email to User2.
            string emailSubject = Common.GenerateResourceName(Site, "subject");
            this.SendPlainTextEmail(null, emailSubject, this.User1Information.UserName, this.User2Information.UserName, null);
            #endregion

            #region Call Sync to get both Email and SMS items
            this.SwitchUser(this.User2Information);
            TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, emailSubject);

            Request.Options option1 = new Request.Options
            {
                Items = new object[] { "Email" },
                ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.Class }
            };

            Request.Options option2 = new Request.Options
            {
                Items = new object[] { "SMS" },
                ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.Class }
            };

            SyncResponse syncResponse = this.CheckEmail(this.User2Information.InboxCollectionId, emailSubject, new Request.Options[] { option1, option2 });
            Site.Assert.IsNotNull(syncResponse.ResponseData.Item, "The items in the Sync response should not be null.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R934
            Site.CaptureRequirementIfAreEqual<uint>(
                1,
                Convert.ToUInt32(TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Status)),
                934,
                @"[In Class(Sync)] Only SMS messages and email messages can be synchronized at the same time.");
            #endregion

            #region Call Sync to get both Calendar and Tasks items
            Request.Options option3 = new Request.Options
            {
                Items = new object[] { "Calendar" },
                ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.Class }
            };

            Request.Options option4 = new Request.Options
            {
                Items = new object[] { "Tasks" },
                ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.Class }
            };

            SyncRequest syncRequest = TestSuiteBase.CreateEmptySyncRequest(this.User2Information.CalendarCollectionId);
            this.Sync(syncRequest);
            syncRequest.RequestData.Collections[0].Options = new Request.Options[] { option3, option4 };
            syncRequest.RequestData.Collections[0].SyncKey = this.LastSyncKey;
            syncResponse = this.Sync(syncRequest);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R935
            Site.CaptureRequirementIfAreEqual<int>(
                4,
                int.Parse(syncResponse.ResponseData.Status),
                935,
                @"[In Class(Sync)] A request for any other combination of classes will fail with a status value of 4.");
            #endregion
        }