A static class contains all helper methods used in test cases.
Ejemplo n.º 1
0
        public void MSASAIRS_S03_TC01_FileReference_ZeroLengthString()
        {
            #region Send a mail with normal attachment.
            string subject = Common.GenerateResourceName(Site, "Subject");
            string body    = Common.GenerateResourceName(Site, "Body");
            this.SendEmail(EmailType.NormalAttachment, subject, body);
            #endregion

            #region Send an ItemOperations request with the value of FileReference element as a zero-length string.
            DataStructures.Sync syncItem = this.GetSyncResult(subject, this.User2Information.InboxCollectionId, null, null, null);

            // Send an ItemOperations request with the value of FileReference element as a zero-length string.
            ItemOperationsRequest request = TestSuiteHelper.CreateItemOperationsRequest(this.User2Information.InboxCollectionId, syncItem.ServerId, string.Empty, null, null);

            DataStructures.ItemOperationsStore itemOperationsStore = this.ASAIRSAdapter.ItemOperations(request, DeliveryMethodForFetch.Inline);

            Site.Assert.AreEqual <int>(
                1,
                itemOperationsStore.Items.Count,
                "There should be 1 item in ItemOperations response.");
            #endregion

            #region Verify requirements
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASAIRS_R214");

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R214
            Site.CaptureRequirementIfAreEqual <string>(
                "15",
                itemOperationsStore.Items[0].Status,
                214,
                @"[In FileReference (Fetch)] If the client includes a zero-length string for the value of this element [the FileReference (Fetch) element] in an ItemOperations command request, the server responds with a protocol status error of 15.");
            #endregion
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Send a meeting request email.
        /// </summary>
        /// <param name="subject">The subject of email</param>
        /// <param name="calendar">The meeting calendar</param>
        private void SendMeetingRequest(string subject, Calendar calendar)
        {
            string emailBody = Common.GenerateResourceName(Site, "content");
            string icalendarFormatContent = TestSuiteHelper.CreateiCalendarFormatContent(calendar);

            string meetingEmailMime = TestSuiteHelper.CreateMeetingRequestMime(
                calendar.OrganizerEmail,
                calendar.Attendees.Attendee[0].Email,
                subject,
                emailBody,
                icalendarFormatContent);

            Request.SendMail sendMail = new Request.SendMail();

            sendMail.ClientId = Guid.NewGuid().ToString("N");
            sendMail.Mime     = meetingEmailMime;

            SendMailRequest sendMailRequest = Common.CreateSendMailRequest();

            sendMailRequest.RequestData = sendMail;

            this.SwitchUser(this.User1Information, false);
            SendMailResponse response = this.ASAIRSAdapter.SendMail(sendMailRequest);

            Site.Assert.AreEqual <string>(
                string.Empty,
                response.ResponseDataXML,
                "The server should return an empty xml response data to indicate SendMail command success.");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get the specified email item.
        /// </summary>
        /// <param name="emailSubject">The subject of the email item.</param>
        /// <param name="folderCollectionId">The serverId of the default folder.</param>
        /// <param name="bodyPreference">The preference information related to the type and size of information that is returned from fetching.</param>
        /// <returns>The result of getting the specified email item.</returns>
        private SyncStore GetSyncResult(string emailSubject, string folderCollectionId, Request.BodyPreference bodyPreference)
        {
            SyncStore syncItemResult;

            Microsoft.Protocols.TestSuites.Common.DataStructures.Sync item = null;
            int counter    = 0;
            int waitTime   = int.Parse(Common.GetConfigurationPropertyValue("WaitTime", this.Site));
            int retryCount = int.Parse(Common.GetConfigurationPropertyValue("RetryCount", this.Site));

            do
            {
                Thread.Sleep(waitTime);

                // Get the new added email item
                syncItemResult = this.SyncChanges(this.GetInitialSyncKey(folderCollectionId), folderCollectionId, bodyPreference);
                if (syncItemResult != null && syncItemResult.CollectionStatus == 1)
                {
                    item = TestSuiteHelper.GetSyncAddItem(syncItemResult, emailSubject);
                }

                counter++;
            }while ((syncItemResult == null || item == null) && counter < retryCount);

            Site.Assert.IsNotNull(item, "The email item with subject {0} should be found. Retry count: {1}", emailSubject, counter);

            // Verify sync result
            Site.Assert.AreEqual <byte>(
                1,
                syncItemResult.CollectionStatus,
                "If the Sync command executes successfully, the status in response should be 1.");

            return(syncItemResult);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Synchronize item with specified subject.
        /// </summary>
        /// <param name="subject">The subject of the item.</param>
        /// <param name="collectionId">The collection id which to sync with.</param>
        /// <param name="commands">The sync commands.</param>
        /// <param name="bodyPreferences">The bodyPreference in the options element.</param>
        /// <param name="bodyPartPreferences">The bodyPartPreference in the options element.</param>
        /// <returns>The item with specified subject.</returns>
        protected DataStructures.Sync GetSyncResult(string subject, string collectionId, object[] commands, Request.BodyPreference[] bodyPreferences, Request.BodyPartPreference[] bodyPartPreferences)
        {
            DataStructures.SyncStore syncStore;
            DataStructures.Sync      item = null;
            SyncRequest request           = TestSuiteHelper.CreateSyncRequest(this.GetInitialSyncKey(collectionId), collectionId, commands, bodyPreferences, bodyPartPreferences);

            int counter    = 0;
            int waitTime   = int.Parse(Common.GetConfigurationPropertyValue("WaitTime", this.Site));
            int retryCount = int.Parse(Common.GetConfigurationPropertyValue("RetryCount", this.Site));

            do
            {
                Thread.Sleep(waitTime);
                syncStore = this.ASAIRSAdapter.Sync(request);
                if (syncStore != null && syncStore.CollectionStatus == 1)
                {
                    item = TestSuiteHelper.GetSyncAddItem(syncStore, subject);
                }

                counter++;
            }while ((syncStore == null || item == null) && counter < retryCount);

            this.Site.Assert.IsNotNull(item, "The email item with subject {0} should be found, retry count: {1}.", subject, counter);

            this.SyncKey = syncStore.SyncKey;

            return(item);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// The method is used to send a mail
        /// </summary>
        /// <param name="emailType">The type of the email.</param>
        /// <param name="subject">The subject of the mail.</param>
        /// <param name="body">The body of the item.</param>
        protected void SendEmail(EmailType emailType, string subject, string body)
        {
            SendMailRequest request = new SendMailRequest
            {
                RequestData =
                {
                    ClientId = Guid.NewGuid().ToString("N"),
                    Mime     = TestSuiteHelper.CreateMIME(
                        emailType,
                        Common.GetMailAddress(this.User1Information.UserName, this.User1Information.UserDomain),
                        Common.GetMailAddress(this.User2Information.UserName, this.User2Information.UserDomain),
                        subject,
                        body)
                }
            };

            SendMailResponse sendMailResponse = this.ASAIRSAdapter.SendMail(request);

            this.Site.Assert.AreEqual <string>(
                string.Empty,
                sendMailResponse.ResponseDataXML,
                "The server should return an empty XML body to indicate SendMail command is executed successfully.");

            this.SwitchUser(this.User2Information, true);
            this.RecordCaseRelativeItems(this.User2Information.UserName, this.User2Information.InboxCollectionId, subject);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Fetch item with specified ServerID on the server.
        /// </summary>
        /// <param name="collectionId">The collection id.</param>
        /// <param name="serverId">The server id of the mail.</param>
        /// <param name="fileReference">The file reference of the attachment.</param>
        /// <param name="bodyPreferences">The bodyPreference in the options element.</param>
        /// <param name="bodyPartPreferences">The bodyPartPreference in the options element.</param>
        /// <param name="deliveryMethod">Indicate whether use multipart or inline method to send the request.</param>
        /// <returns>The item with specified ServerID.</returns>
        protected DataStructures.ItemOperations GetItemOperationsResult(string collectionId, string serverId, string fileReference, Request.BodyPreference[] bodyPreferences, Request.BodyPartPreference[] bodyPartPreferences, DeliveryMethodForFetch?deliveryMethod)
        {
            DataStructures.ItemOperations item    = null;
            ItemOperationsRequest         request = TestSuiteHelper.CreateItemOperationsRequest(collectionId, serverId, fileReference, bodyPreferences, bodyPartPreferences);

            int counter    = 0;
            int waitTime   = int.Parse(Common.GetConfigurationPropertyValue("WaitTime", this.Site));
            int retryCount = int.Parse(Common.GetConfigurationPropertyValue("RetryCount", this.Site));

            do
            {
                Thread.Sleep(waitTime);
                DataStructures.ItemOperationsStore itemOperationsStore = this.ASAIRSAdapter.ItemOperations(request, deliveryMethod ?? DeliveryMethodForFetch.Inline);

                // Since the item serverId or attachment fileReference is unique, there should be only one item in response
                this.Site.Assert.AreEqual <int>(
                    1,
                    itemOperationsStore.Items.Count,
                    "The count of Items in ItemOperations command response should be 1.");

                if (itemOperationsStore.Items[0].Email != null)
                {
                    item = itemOperationsStore.Items[0];
                }
            }while (item == null && counter < retryCount);

            this.Site.Assert.IsNotNull(item, "The item should be found, retry count: {0}.", counter);

            return(item);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Sync changes between client and server
        /// </summary>
        /// <param name="syncKey">The synchronization key returned by last request.</param>
        /// <param name="collectionId">Identify the folder as the collection being synchronized.</param>
        /// <param name="bodyPreference">Sets preference information related to the type and size of information for body</param>
        /// <returns>Return change result</returns>
        private SyncStore SyncChanges(string syncKey, string collectionId, Request.BodyPreference bodyPreference)
        {
            // Get changes from server use initial syncKey
            SyncRequest syncRequest = TestSuiteHelper.CreateSyncRequest(syncKey, collectionId, bodyPreference);
            SyncStore   syncResult  = this.ASAIRSAdapter.Sync(syncRequest);

            return(syncResult);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Delete all the items in a folder.
        /// </summary>
        /// <param name="createdItemsCollection">The created items collection which should be deleted.</param>
        private void DeleteItemsInFolder(Collection <CreatedItems> createdItemsCollection)
        {
            foreach (CreatedItems createdItems in createdItemsCollection)
            {
                string      syncKey             = this.GetInitialSyncKey(createdItems.CollectionId);
                SyncRequest request             = TestSuiteHelper.CreateSyncRequest(syncKey, createdItems.CollectionId, null, null, null);
                DataStructures.SyncStore result = this.ASAIRSAdapter.Sync(request);

                List <Request.SyncCollectionDelete> deleteData = new List <Request.SyncCollectionDelete>();
                foreach (string subject in createdItems.ItemSubject)
                {
                    string serverId = null;
                    if (result != null)
                    {
                        foreach (DataStructures.Sync item in result.AddElements)
                        {
                            if (item.Email.Subject != null && item.Email.Subject.Equals(subject, StringComparison.CurrentCulture))
                            {
                                serverId = item.ServerId;
                                break;
                            }

                            if (item.Contact.FileAs != null && item.Contact.FileAs.Equals(subject, StringComparison.CurrentCulture))
                            {
                                serverId = item.ServerId;
                                break;
                            }

                            if (item.Calendar.Subject != null && item.Calendar.Subject.Equals(subject, StringComparison.CurrentCulture))
                            {
                                serverId = item.ServerId;
                                break;
                            }
                        }
                    }

                    this.Site.Assert.IsNotNull(serverId, "The item with subject '{0}' should be found!", subject);
                    deleteData.Add(new Request.SyncCollectionDelete()
                    {
                        ServerId = serverId
                    });
                }

                Request.SyncCollection syncCollection = TestSuiteHelper.CreateSyncCollection(result.SyncKey, createdItems.CollectionId);
                syncCollection.Commands                = deleteData.ToArray();
                syncCollection.DeletesAsMoves          = false;
                syncCollection.DeletesAsMovesSpecified = true;

                SyncRequest syncRequest = Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
                DataStructures.SyncStore deleteResult = this.ASAIRSAdapter.Sync(syncRequest);
                this.Site.Assert.AreEqual <byte>(
                    1,
                    deleteResult.CollectionStatus,
                    "The value of Status should be 1 to indicate the Sync command executes successfully.");
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Search item with specified criteria on the server.
        /// </summary>
        /// <param name="subject">The subject of the item.</param>
        /// <param name="collectionId">The collection id.</param>
        /// <param name="conversationId">The conversation for which to search.</param>
        /// <param name="bodyPreferences">The bodyPreference in the options element.</param>
        /// <param name="bodyPartPreferences">The bodyPartPreference in the options element.</param>
        /// <returns>The server response.</returns>
        protected DataStructures.Search GetSearchResult(string subject, string collectionId, string conversationId, Request.BodyPreference[] bodyPreferences, Request.BodyPartPreference[] bodyPartPreferences)
        {
            SearchRequest request = TestSuiteHelper.CreateSearchRequest(subject, collectionId, conversationId, bodyPreferences, bodyPartPreferences);

            DataStructures.SearchStore searchStore = this.ASAIRSAdapter.Search(request);
            DataStructures.Search      searchItem  = null;
            if (searchStore.Results.Count != 0)
            {
                searchItem = TestSuiteHelper.GetSearchItem(searchStore, subject);
            }

            this.Site.Assert.IsNotNull(searchItem, "The email message with subject {0} should be found.", subject);

            return(searchItem);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Create a sync add request.
        /// </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="applicationData">Contains the data used to specify the Add element for Sync command.</param>
        /// <returns>Returns the SyncRequest instance.</returns>
        internal static SyncRequest CreateSyncAddRequest(string syncKey, string collectionId, Request.SyncCollectionAddApplicationData applicationData)
        {
            SyncRequest syncAddRequest = TestSuiteHelper.CreateSyncRequest(syncKey, collectionId, null);

            Request.SyncCollectionAdd add = new Request.SyncCollectionAdd
            {
                ClientId        = GetClientId(),
                ApplicationData = applicationData
            };

            List <object> commandList = new List <object> {
                add
            };

            syncAddRequest.RequestData.Collections[0].Commands = commandList.ToArray();

            return(syncAddRequest);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Set the value of common meeting properties
        /// </summary>
        /// <param name="subject">The subject of the meeting.</param>
        /// <param name="attendeeEmailAddress">The email address of attendee.</param>
        /// <returns>The key and value pairs of common meeting properties.</returns>
        internal static Dictionary <Request.ItemsChoiceType8, object> SetMeetingProperties(string subject, string attendeeEmailAddress, ITestSite testSite)
        {
            Dictionary <Request.ItemsChoiceType8, object> propertiesToValueMap = new Dictionary <Request.ItemsChoiceType8, object>
            {
                {
                    Request.ItemsChoiceType8.Subject, subject
                }
            };

            // Set the subject element.

            // MeetingStauts is set to 1, which means it is a meeting and the user is the meeting organizer.
            byte meetingStatus = 1;

            propertiesToValueMap.Add(Request.ItemsChoiceType8.MeetingStatus, meetingStatus);

            // Set the UID
            string uID = Guid.NewGuid().ToString();

            if (Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", testSite).Equals("16.0") || Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", testSite).Equals("16.1"))
            {
                propertiesToValueMap.Add(Request.ItemsChoiceType8.ClientUid, uID);
            }
            else
            {
                propertiesToValueMap.Add(Request.ItemsChoiceType8.UID, uID);
            }

            // Set the TimeZone
            string timeZone = Common.GetTimeZone("(UTC) Coordinated Universal Time", 0);

            propertiesToValueMap.Add(Request.ItemsChoiceType8.Timezone, timeZone);

            // Set the attendee to user2
            Request.Attendees attendees = TestSuiteHelper.CreateAttendees(attendeeEmailAddress);
            propertiesToValueMap.Add(Request.ItemsChoiceType8.Attendees, attendees);

            return(propertiesToValueMap);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Add a meeting to the server.
        /// </summary>
        /// <param name="calendarCollectionId">The collectionId of the folder which the item should be added.</param>
        /// <param name="elementsToValueMap">The key and value pairs of common meeting properties.</param>
        private void SyncAddMeeting(string calendarCollectionId, Dictionary <Request.ItemsChoiceType8, object> elementsToValueMap)
        {
            Request.SyncCollectionAddApplicationData applicationData = new Request.SyncCollectionAddApplicationData
            {
                Items            = new object[elementsToValueMap.Count],
                ItemsElementName = new Request.ItemsChoiceType8[elementsToValueMap.Count]
            };

            if (elementsToValueMap.Count > 0)
            {
                elementsToValueMap.Values.CopyTo(applicationData.Items, 0);
                elementsToValueMap.Keys.CopyTo(applicationData.ItemsElementName, 0);
            }

            string      iniSyncKey     = this.GetInitialSyncKey(calendarCollectionId);
            SyncRequest syncAddRequest = TestSuiteHelper.CreateSyncAddRequest(iniSyncKey, calendarCollectionId, applicationData);

            SyncStore syncAddResponse = this.ASAIRSAdapter.Sync(syncAddRequest);

            Site.Assert.AreEqual <int>(
                1,
                int.Parse(syncAddResponse.AddResponses[0].Status),
                "The sync add operation should be successful.");
        }
Ejemplo n.º 13
0
        public void MSASAIRS_S06_TC01_MeetingResponseWithPlainTextBody()
        {
            Site.Assume.AreNotEqual <string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Body element under meetingresponse:SendResponse element is supported when the MS-ASProtocolVersion header is set to 16.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");
            Site.Assume.AreNotEqual <string>("14.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Body element under meetingresponse:SendResponse element is supported when the MS-ASProtocolVersion header is set to 16.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");
            Site.Assume.AreNotEqual <string>("14.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Body element under meetingresponse:SendResponse element is supported when the MS-ASProtocolVersion header is set to 16.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region Call Sync command with Add element to add a no recurrence meeting to the server.
            string subject       = Common.GenerateResourceName(Site, "Subject");
            string attendeeEmail = Common.GetMailAddress(this.User2Information.UserName, this.User2Information.UserDomain);

            Dictionary <Request.ItemsChoiceType8, object> elementsToValueMap = TestSuiteHelper.SetMeetingProperties(subject, attendeeEmail, this.Site);
            DateTime startTime = DateTime.Now.AddMinutes(-5);
            DateTime endTime   = startTime.AddHours(1);
            elementsToValueMap.Add(Request.ItemsChoiceType8.StartTime, startTime.ToString("yyyyMMddTHHmmssZ"));
            elementsToValueMap.Add(Request.ItemsChoiceType8.EndTime, endTime.ToString("yyyyMMddTHHmmssZ"));

            this.SyncAddMeeting(this.User1Information.CalendarCollectionId, elementsToValueMap);

            this.RecordCaseRelativeItems(this.User1Information.UserName, this.User1Information.CalendarCollectionId, subject);
            #endregion

            #region Call Sync command to get the added calendar item.
            SyncStore getChangeResult = this.GetSyncResult(subject, this.User1Information.CalendarCollectionId, null);
            Microsoft.Protocols.TestSuites.Common.DataStructures.Sync resultItem = TestSuiteHelper.GetSyncAddItem(getChangeResult, subject);
            #endregion

            #region Call SendMail command to send the meeting request to attendee without setting BusyStatus.
            Calendar calendarItem = resultItem.Calendar;
            calendarItem.BusyStatus = null;
            this.SendMeetingRequest(subject, calendarItem);
            #endregion

            #region Call Sync command to get the meeting request and accept it.
            this.SwitchUser(this.User2Information, true);

            // Sync mailbox changes
            SyncStore syncChangeResult = this.GetSyncResult(subject, this.User2Information.InboxCollectionId, null);
            Microsoft.Protocols.TestSuites.Common.DataStructures.Sync meetingRequestEmail = TestSuiteHelper.GetSyncAddItem(syncChangeResult, subject);

            Request.MeetingResponseRequestSendResponse sendResoponse = new Request.MeetingResponseRequestSendResponse()
            {
                Body = new Request.Body()
                {
                    Type = 1,
                    Data = "Accept this meeting."
                }
            };

            // Accept the meeting request
            // Create a meeting response request item
            Request.MeetingResponseRequest meetingResponseRequestItem = new Request.MeetingResponseRequest
            {
                UserResponse = 1,
                CollectionId = this.User2Information.InboxCollectionId,
                RequestId    = meetingRequestEmail.ServerId,
                SendResponse = sendResoponse,
            };

            // Create a meeting response request
            MeetingResponseRequest  meetingRequest = Common.CreateMeetingResponseRequest(new Request.MeetingResponseRequest[] { meetingResponseRequestItem });
            MeetingResponseResponse response       = this.ASAIRSAdapter.MeetingResponse(meetingRequest);

            this.Site.CaptureRequirementIfAreEqual <int>(
                1,
                int.Parse(response.ResponseData.Result[0].Status),
                1331,
                @"[In Body] When the Body element is a child of the meetingresponse:SendResponse element [or the composemail:SmartForward element], it has only the child elements Type and Data.");

            this.Site.CaptureRequirementIfAreEqual <int>(
                1,
                int.Parse(response.ResponseData.Result[0].Status),
                1333,
                @"[In Body] The Body element is a child of the meetingresponse:SendResponse element and the composemail:SmartForward element only when protocol version 16.0 is used.");

            // Because the Type element is 1 and client call the MeetingResponse command successful.
            // So R1400 will be verified.
            this.Site.CaptureRequirementIfAreEqual <int>(
                1,
                int.Parse(response.ResponseData.Result[0].Status),
                1400,
                @"[In Type (Body)] For calendar items in protocol version 16.0, the only valid values for this element [Type] is 1 (plain text).");
            #endregion

            #region Call Sync command to get the calendar item.
            SyncStore getCalendarItemsResult = this.GetSyncResult(subject, this.User2Information.CalendarCollectionId, null);
            Microsoft.Protocols.TestSuites.Common.DataStructures.Sync calendarResult = TestSuiteHelper.GetSyncAddItem(getCalendarItemsResult, subject);
            Site.Assert.IsNotNull(calendarResult.Calendar.BusyStatus, "Element BusyStatus should be present.");
            #endregion
        }
Ejemplo n.º 14
0
        public void MSASAIRS_S04_TC06_MultipleBodyPreferenceHaveSameTypeValue()
        {
            #region Send a plain text email
            string subject = Common.GenerateResourceName(Site, "Subject");
            string body    = Common.GenerateResourceName(Site, "Body");
            this.SendEmail(EmailType.Plaintext, subject, body);

            // Make sure the email has reached the inbox folder of the recipient
            this.GetSyncResult(subject, this.User2Information.InboxCollectionId, null, null, null);
            #endregion

            #region Set two BodyPreference elements with same type value
            Request.BodyPreference[] bodyPreference = new Request.BodyPreference[]
            {
                new Request.BodyPreference()
                {
                    Type                    = 1,
                    TruncationSize          = 100,
                    TruncationSizeSpecified = true,
                    AllOrNone               = true,
                    AllOrNoneSpecified      = true
                },

                new Request.BodyPreference()
                {
                    Type                    = 1,
                    TruncationSize          = 100,
                    TruncationSizeSpecified = true,
                    AllOrNone               = true,
                    AllOrNoneSpecified      = true
                }
            };
            #endregion

            #region Verify multiple BodyPreference elements with same type value in Sync for related requirements
            SyncRequest request = TestSuiteHelper.CreateSyncRequest(this.GetInitialSyncKey(this.User2Information.InboxCollectionId), this.User2Information.InboxCollectionId, null, bodyPreference, null);

            if (Common.IsRequirementEnabled(10015, this.Site))
            {
                try
                {
                    this.ASAIRSAdapter.Sync(request);

                    Site.Assert.Fail("The server should return an HTTP error 500 if multiple BodyPreference elements are present with the same value in the Type child element.");
                }
                catch (WebException exception)
                {
                    int errorCode = ((HttpWebResponse)exception.Response).StatusCode.GetHashCode();

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

                    // Verify MS-ASAIRS requirement: MS-ASAIRS_R10015
                    Site.CaptureRequirementIfAreEqual <int>(
                        500,
                        errorCode,
                        10015,
                        @"[In Appendix B: Product Behavior] Implementation does return an HTTP error 500 instead of a Status value of 4 when multiple BodyPreference elements are present with the same value in the Type child element. (<1> Section 3.2.5.1:  Exchange 2007 SP1 returns an HTTP error 500 instead of a Status value of 4 when multiple BodyPreference elements are present with the same value in the Type child element.)");
                }
            }

            if (Common.IsRequirementEnabled(10016, this.Site))
            {
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(request.GetRequestDataSerializedXML());

                SendStringResponse syncAddResponse = this.ASAIRSAdapter.Sync(doc.OuterXml);

                string status = this.GetStatusCodeFromXPath(syncAddResponse, "/a:Sync/a:Status");

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

                // Verify MS-ASAIRS requirement: MS-ASAIRS_R10016
                Site.CaptureRequirementIfAreEqual(
                    "4",
                    status,
                    10016,
                    @"[In Appendix B: Product Behavior] Implementation does return 4 (for Sync command) if multiple BodyPreference elements are present with the same value in the Type child element. (Exchange Server 2010 and above follow this behavior.)");
            }
            #endregion
        }
Ejemplo n.º 15
0
        public void MSASAIRS_S04_TC05_IncorrectPlacement()
        {
            #region Send a plain text email
            string subject = Common.GenerateResourceName(Site, "Subject");
            string body    = Common.GenerateResourceName(Site, "Body");
            this.SendEmail(EmailType.Plaintext, subject, body);
            #endregion

            #region Set BodyPreference element
            Request.BodyPreference[] bodyPreference = new Request.BodyPreference[]
            {
                new Request.BodyPreference()
                {
                    Type                    = 1,
                    TruncationSize          = 100,
                    TruncationSizeSpecified = true,
                    AllOrNone               = true,
                    AllOrNoneSpecified      = true
                }
            };
            #endregion

            #region Call ItemOperations command with incorrect placement of BodyPreference element.
            DataStructures.Sync syncItem = this.GetSyncResult(subject, this.User2Information.InboxCollectionId, null, bodyPreference, null);

            if (Common.IsRequirementEnabled(10032, this.Site))
            {
                ItemOperationsRequest itemOperationRequest = TestSuiteHelper.CreateItemOperationsRequest(this.User2Information.InboxCollectionId, syncItem.ServerId, null, bodyPreference, null);

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(itemOperationRequest.GetRequestDataSerializedXML());
                XmlNode bodyPreferenceNode = doc.SelectSingleNode("//*[name()='BodyPreference']");

                // Add another BodyPreference element in the BodyPreference element, the placement is invalid.
                XmlNode temp = bodyPreferenceNode.Clone();
                temp.SelectSingleNode("//*[name()='Type']").InnerText = "2";
                bodyPreferenceNode.AppendChild(temp);

                SendStringResponse itemOperationResponse = this.ASAIRSAdapter.ItemOperations(doc.OuterXml);

                string status = this.GetStatusCodeFromXPath(itemOperationResponse, "/i:ItemOperations/i:Status");

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

                // Verify MS-ASAIRS requirement: MS-ASAIRS_R10032
                Site.CaptureRequirementIfAreEqual(
                    "2",
                    status,
                    10032,
                    @"[In Appendix B: Product Behavior] Implementation does return protocol status error 2 for an ItemOperations command (as specified in [MS-ASCMD] section 2.2.2.8), if an element does not meet the requirements[any of the XML elements specified in section 2.2.2 that are present in the command's XML body to ensure they comply with the requirements regarding placement] specified for that element, unless specified in the following table[section 3.2.5.1]. (Exchange Server 2007 SP1 and above follow this behavior.)");
            }
            #endregion

            #region Call Search command with incorrect placement of BodyPreference element.
            if (Common.IsRequirementEnabled(10036, this.Site))
            {
                SearchRequest searchRequest = TestSuiteHelper.CreateSearchRequest(subject, this.User2Information.InboxCollectionId, null, bodyPreference, null);
                XmlDocument   doc           = new XmlDocument();
                doc.LoadXml(searchRequest.GetRequestDataSerializedXML());
                XmlNode bodyPreferenceNode = doc.SelectSingleNode("//*[name()='BodyPreference']");

                // Add another BodyPreference element in the BodyPreference element, the placement is invalid.
                XmlNode temp = bodyPreferenceNode.Clone();
                temp.SelectSingleNode("//*[name()='Type']").InnerText = "2";
                bodyPreferenceNode.AppendChild(temp);

                SendStringResponse searchResponse = this.ASAIRSAdapter.Search(doc.OuterXml);
                string             searchStatus   = this.GetStatusCodeFromXPath(searchResponse, "/s:Search/s:Status");
                int retryCount = int.Parse(Common.GetConfigurationPropertyValue("RetryCount", this.Site));
                int waitTime   = int.Parse(Common.GetConfigurationPropertyValue("WaitTime", this.Site));
                int counter    = 1;

                while (counter < retryCount && searchStatus.Equals("10"))
                {
                    Thread.Sleep(waitTime);
                    searchResponse = this.ASAIRSAdapter.Search(doc.OuterXml);
                    searchStatus   = this.GetStatusCodeFromXPath(searchResponse, "/s:Search/s:Status");
                    counter++;
                }

                string status = this.GetStatusCodeFromXPath(searchResponse, "/s:Search/s:Response/s:Store/s:Status");

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

                // Verify MS-ASAIRS requirement: MS-ASAIRS_R10036
                Site.CaptureRequirementIfAreEqual(
                    "2",
                    status,
                    10036,
                    @"[In Appendix B: Product Behavior] Implementation does return protocol status error 2 for a Search command (as specified in [MS-ASCMD] section 2.2.2.14), if an element does not meet the requirements[any of the XML elements specified in section 2.2.2 that are present in the command's XML body to ensure they comply with the requirements regarding placement] specified for that element, unless specified in the following table[section 3.2.5.1]. (Exchange Server 2007 SP1 and above follow this behavior.)");
            }
            #endregion

            #region Call Sync add command with incorrect placement of Type element.
            if (Common.IsRequirementEnabled(10039, this.Site))
            {
                SyncRequest syncAddRequest = TestSuiteHelper.CreateSyncRequest(this.GetInitialSyncKey(this.User2Information.InboxCollectionId), this.User2Information.InboxCollectionId, CreateSyncAddCommands(), null, null);
                XmlDocument doc            = new XmlDocument();
                doc.LoadXml(syncAddRequest.GetRequestDataSerializedXML());
                XmlNode bodyNode = doc.SelectSingleNode("//*[name()='Body']");

                // Add another body element in the body element, the placement is invalid.
                XmlNode temp = bodyNode.Clone();
                temp.SelectSingleNode("//*[name()='Type']").InnerText = "2";
                bodyNode.AppendChild(temp);

                SendStringResponse syncAddResponse = this.ASAIRSAdapter.Sync(doc.OuterXml);

                string status = this.GetStatusCodeFromXPath(syncAddResponse, "/a:Sync/a:Collections/a:Collection/a:Responses/a:Add/a:Status");

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

                // Verify MS-ASAIRS requirement: MS-ASAIRS_R10039
                Site.CaptureRequirementIfAreEqual(
                    "6",
                    status,
                    10039,
                    @"[In Appendix B: Product Behavior] Implementation does return protocol status error 6 for a Sync command (as specified in [MS-ASCMD] section 2.2.2.19), if an element does not meet the requirements[any of the XML elements specified in section 2.2.2 that are present in the command's XML body to ensure they comply with the requirements regarding placement] specified for that element, unless specified in the following table[section 3.2.5.1]. (Exchange Server 2007 SP1 and above follow this behavior.)");
            }
            #endregion
        }
Ejemplo n.º 16
0
        public void MSASAIRS_S04_TC01_Sync_Status4()
        {
            #region Send a plain text email
            string subject = Common.GenerateResourceName(Site, "Subject");
            string body    = Common.GenerateResourceName(Site, "Body");
            this.SendEmail(EmailType.Plaintext, subject, body);

            // Make sure the email has reached the inbox folder of the recipient
            this.GetSyncResult(subject, this.User2Information.InboxCollectionId, null, null, null);
            #endregion

            #region Set BodyPreference element
            Request.BodyPreference[] bodyPreference = new Request.BodyPreference[]
            {
                new Request.BodyPreference()
                {
                    Type                    = 1,
                    TruncationSize          = 100,
                    TruncationSizeSpecified = true,
                    AllOrNone               = true,
                    AllOrNoneSpecified      = true
                }
            };
            #endregion

            #region Call Sync command with incorrect order of child elements of BodyPreference
            SyncRequest request = TestSuiteHelper.CreateSyncRequest(this.GetInitialSyncKey(this.User2Information.InboxCollectionId), this.User2Information.InboxCollectionId, null, bodyPreference, null);
            XmlDocument doc     = new XmlDocument();
            doc.LoadXml(request.GetRequestDataSerializedXML());
            XmlNode bodyPreferenceNode = doc.SelectSingleNode("//*[name()='BodyPreference']");

            // Put the first node to the end.
            XmlNode temp = bodyPreferenceNode.ChildNodes[0];
            bodyPreferenceNode.RemoveChild(temp);
            bodyPreferenceNode.AppendChild(temp);

            SendStringResponse response = this.ASAIRSAdapter.Sync(doc.OuterXml);

            string status = this.GetStatusCodeFromXPath(response, "/a:Sync/a:Status");

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R348
            Site.CaptureRequirementIfAreEqual(
                "4",
                status,
                348,
                @"[In Validating XML] If the child elements of BodyPreference (section 2.2.2.12) are not in the correct order, the server returns protocol status error 4 (for a Sync command).");
            #endregion

            #region Call Sync command with a non-boolean value of AllOrNone element
            doc.LoadXml(request.GetRequestDataSerializedXML());
            XmlNode allOrNoneNode = doc.SelectSingleNode("//*[name()='AllOrNone']");

            // Set the AllOrNone element value to non-boolean.
            allOrNoneNode.InnerText = "a";

            response = this.ASAIRSAdapter.Sync(doc.OuterXml);

            status = this.GetStatusCodeFromXPath(response, "/a:Sync/a:Status");

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R350
            Site.CaptureRequirementIfAreEqual(
                "4",
                status,
                350,
                @"[In Validating XML] If the AllOrNone (section 2.2.2.3.2) element is not of type boolean, the server returns protocol status error 4 (for Sync command).");
            #endregion

            #region Call Sync command with multiple AllOrNone elements in a single BodyPreference element
            doc.LoadXml(request.GetRequestDataSerializedXML());
            bodyPreferenceNode = doc.SelectSingleNode("//*[name()='BodyPreference']");
            allOrNoneNode      = doc.SelectSingleNode("//*[name()='AllOrNone']");
            temp = allOrNoneNode.Clone();
            bodyPreferenceNode.AppendChild(temp);

            response = this.ASAIRSAdapter.Sync(doc.OuterXml);

            status = this.GetStatusCodeFromXPath(response, "/a:Sync/a:Status");

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R351
            Site.CaptureRequirementIfAreEqual(
                "4",
                status,
                351,
                @"[In Validating XML] If multiple AllOrNone elements are in a single BodyPreference element, the server returns protocol status error 4 (for Sync command).");
            #endregion
        }
Ejemplo n.º 17
0
        public void MSASAIRS_S05_TC01_Location()
        {
            Site.Assume.AreNotEqual <string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Location element is supported when the MS-ASProtocolVersion header is set to 16.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");
            Site.Assume.AreNotEqual <string>("14.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Location element is supported when the MS-ASProtocolVersion header is set to 16.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");
            Site.Assume.AreNotEqual <string>("14.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Location element is supported when the MS-ASProtocolVersion header is set to 16.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region Call Sync command with Add element to add an appointment to the server
            Request.SyncCollectionAddApplicationData applicationData = new Request.SyncCollectionAddApplicationData();

            List <object> items = new List <object>();
            List <Request.ItemsChoiceType8> itemsElementName = new List <Request.ItemsChoiceType8>();

            string subject = Common.GenerateResourceName(Site, "Subject");
            items.Add(subject);
            itemsElementName.Add(Request.ItemsChoiceType8.Subject);

            // MeetingStauts is set to 0, which means it is an appointment with no attendees.
            byte meetingStatus = 0;
            items.Add(meetingStatus);
            itemsElementName.Add(Request.ItemsChoiceType8.MeetingStatus);

            Request.Location location = new Request.Location();
            location.Accuracy                  = (double)1;
            location.AccuracySpecified         = true;
            location.Altitude                  = (double)55.46;
            location.AltitudeAccuracy          = (double)1;
            location.AltitudeAccuracySpecified = true;
            location.AltitudeSpecified         = true;
            location.Annotation                = "Location sample annotation";
            location.City               = "Location sample city";
            location.Country            = "Location sample country";
            location.DisplayName        = "Location sample dislay name";
            location.Latitude           = (double)11.56;
            location.LatitudeSpecified  = true;
            location.LocationUri        = "Location Uri";
            location.Longitude          = (double)1.9;
            location.LongitudeSpecified = true;
            location.PostalCode         = "Location sample postal code";
            location.State              = "Location sample state";
            location.Street             = "Location sample street";
            items.Add(location);
            itemsElementName.Add(Request.ItemsChoiceType8.Location1);

            applicationData.Items            = items.ToArray();
            applicationData.ItemsElementName = itemsElementName.ToArray();
            SyncRequest syncAddRequest = TestSuiteHelper.CreateSyncAddRequest(this.GetInitialSyncKey(this.User1Information.CalendarCollectionId), this.User1Information.CalendarCollectionId, applicationData);

            DataStructures.SyncStore syncAddResponse = this.ASAIRSAdapter.Sync(syncAddRequest);
            Site.Assert.IsTrue(syncAddResponse.AddResponses[0].Status.Equals("1"), "The sync add operation should be success; It is:{0} actually", syncAddResponse.AddResponses[0].Status);

            // Add the appointment to clean up list.
            this.RecordCaseRelativeItems(this.User1Information.UserName, this.User1Information.CalendarCollectionId, subject);
            #endregion

            #region Call Sync command to get the new added calendar item.
            DataStructures.Sync syncItem = this.GetSyncResult(subject, this.User1Information.CalendarCollectionId, null, null, null);
            #endregion

            #region Call ItemOperations command to reterive the added calendar item.
            this.GetItemOperationsResult(this.User1Information.CalendarCollectionId, syncItem.ServerId, null, null, null, null);
            #endregion

            #region Call Search command to search the added calendar item.
            this.GetSearchResult(subject, this.User1Information.CalendarCollectionId, null, null, null);
            #endregion
        }
Ejemplo n.º 18
0
        public void MSASAIRS_S05_TC01_Location()
        {
            Site.Assume.AreNotEqual <string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Location element is supported when the MS-ASProtocolVersion header is set to 16.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");
            Site.Assume.AreNotEqual <string>("14.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Location element is supported when the MS-ASProtocolVersion header is set to 16.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");
            Site.Assume.AreNotEqual <string>("14.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Location element is supported when the MS-ASProtocolVersion header is set to 16.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region Call Sync command with Add element to add an appointment to the server
            Request.SyncCollectionAddApplicationData applicationData = new Request.SyncCollectionAddApplicationData();

            List <object> items = new List <object>();
            List <Request.ItemsChoiceType8> itemsElementName = new List <Request.ItemsChoiceType8>();

            string subject = Common.GenerateResourceName(Site, "Subject");
            items.Add(subject);
            itemsElementName.Add(Request.ItemsChoiceType8.Subject);

            // MeetingStauts is set to 0, which means it is an appointment with no attendees.
            byte meetingStatus = 0;
            items.Add(meetingStatus);
            itemsElementName.Add(Request.ItemsChoiceType8.MeetingStatus);

            Request.Location location = new Request.Location();
            location.Accuracy                  = (double)1;
            location.AccuracySpecified         = true;
            location.Altitude                  = (double)55.46;
            location.AltitudeAccuracy          = (double)1;
            location.AltitudeAccuracySpecified = true;
            location.AltitudeSpecified         = true;
            location.Annotation                = "Location sample annotation";
            location.City               = "Location sample city";
            location.Country            = "Location sample country";
            location.DisplayName        = "Location sample dislay name";
            location.Latitude           = (double)11.56;
            location.LatitudeSpecified  = true;
            location.LocationUri        = "Location Uri";
            location.Longitude          = (double)1.9;
            location.LongitudeSpecified = true;
            location.PostalCode         = "Location sample postal code";
            location.State              = "Location sample state";
            location.Street             = "Location sample street";
            items.Add(location);
            itemsElementName.Add(Request.ItemsChoiceType8.Location);

            applicationData.Items            = items.ToArray();
            applicationData.ItemsElementName = itemsElementName.ToArray();
            SyncRequest syncAddRequest = TestSuiteHelper.CreateSyncAddRequest(this.GetInitialSyncKey(this.User1Information.CalendarCollectionId), this.User1Information.CalendarCollectionId, applicationData);

            DataStructures.SyncStore syncAddResponse = this.ASAIRSAdapter.Sync(syncAddRequest);
            Site.Assert.IsTrue(syncAddResponse.AddResponses[0].Status.Equals("1"), "The sync add operation should be success; It is:{0} actually", syncAddResponse.AddResponses[0].Status);

            // Add the appointment to clean up list.
            this.RecordCaseRelativeItems(this.User1Information.UserName, this.User1Information.CalendarCollectionId, subject);
            #endregion

            #region Call Sync command to get the new added calendar item.
            DataStructures.Sync syncItem = this.GetSyncResult(subject, this.User1Information.CalendarCollectionId, null, null, null);
            #endregion

            #region Call ItemOperations command to reterive the added calendar item.
            this.GetItemOperationsResult(this.User1Information.CalendarCollectionId, syncItem.ServerId, null, null, null, null);
            #endregion

            #region Call Sync command to remove the location of the added calender item.
            // Create empty change items list.
            List <object> changeItems = new List <object>();
            List <Request.ItemsChoiceType7> changeItemsElementName = new List <Request.ItemsChoiceType7>();

            // Create an empty location.
            location = new Request.Location();

            // Add the location field name into the change items element name list.
            changeItemsElementName.Add(Request.ItemsChoiceType7.Location);
            // Add the empty location value to the change items value list.
            changeItems.Add(location);

            // Create sync collection change.
            Request.SyncCollectionChange collectionChange = new Request.SyncCollectionChange
            {
                ServerId        = syncItem.ServerId,
                ApplicationData = new Request.SyncCollectionChangeApplicationData
                {
                    ItemsElementName = changeItemsElementName.ToArray(),
                    Items            = changeItems.ToArray()
                }
            };

            // Create change sync collection
            Request.SyncCollection collection = new Request.SyncCollection
            {
                SyncKey      = this.SyncKey,
                CollectionId = this.User1Information.CalendarCollectionId,
                Commands     = new object[] { collectionChange }
            };

            // Create change sync request.
            SyncRequest syncChangeRequest = Common.CreateSyncRequest(new Request.SyncCollection[] { collection });

            // Change the location of the added calender by Sync request.
            DataStructures.SyncStore syncChangeResponse = this.ASAIRSAdapter.Sync(syncChangeRequest);
            Site.Assert.IsTrue(syncChangeResponse.CollectionStatus.Equals(1), "The sync change operation should be success; It is:{0} actually", syncChangeResponse.CollectionStatus);

            #region Call Sync command to get the new changed calendar item that removed the location.
            syncItem = this.GetSyncResult(subject, this.User1Information.CalendarCollectionId, null, null, null);
            #endregion

            #region Call ItemOperations command to reterive the changed calendar item that removed the location.
            DataStructures.ItemOperations itemOperations = this.GetItemOperationsResult(this.User1Information.CalendarCollectionId, syncItem.ServerId, null, null, null, null);
            #endregion
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASAIRS_R1001013");

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R1001013
            Site.CaptureRequirementIfIsNull(
                itemOperations.Calendar.Location1.DisplayName,
                1001013,
                @"[In Location] The client's request can include an empty Location element to remove the location from an item.");
            #endregion

            if (Common.IsRequirementEnabled(53, this.Site))
            {
                #region Call Search command to search the added calendar item.
                this.GetSearchResult(subject, this.User1Information.CalendarCollectionId, null, null, null);
                #endregion
            }
        }