示例#1
0
        public void MSASHTTP_S03_TC02_SetUserAgentRequestHeader()
        {
            #region Call ConfigureRequestPrefixFields to add the User-Agent header.
            string folderSyncRequestBody = Common.CreateFolderSyncRequest("0").GetRequestDataSerializedXML();
            Dictionary <HTTPPOSTRequestPrefixField, string> requestPrefixFields = new Dictionary <HTTPPOSTRequestPrefixField, string>
            {
                {
                    HTTPPOSTRequestPrefixField.UserAgent, "ASOM"
                }
            };

            this.HTTPAdapter.ConfigureRequestPrefixFields(requestPrefixFields);
            #endregion

            #region Call FolderSync command.
            SendStringResponse folderSyncResponse = HTTPAdapter.HTTPPOST(CommandName.FolderSync, null, folderSyncRequestBody);

            // Check the command is executed successfully.
            this.CheckResponseStatus(folderSyncResponse.ResponseDataXML);
            #endregion

            #region Reset the User-Agent header.
            requestPrefixFields[HTTPPOSTRequestPrefixField.UserAgent] = null;
            this.HTTPAdapter.ConfigureRequestPrefixFields(requestPrefixFields);
            #endregion
        }
        public void MSASHTTP_S01_TC14_CommandCode_ValidateCert()
        {
            #region Call ValidateCert command.
            ValidateCertRequest validateCertRequest  = Common.CreateValidateCertRequest();
            SendStringResponse  validateCertResponse = HTTPAdapter.HTTPPOST(CommandName.ValidateCert, null, validateCertRequest.GetRequestDataSerializedXML());

            // Check the command is executed successfully.
            this.CheckResponseStatus(validateCertResponse.ResponseDataXML);
            #endregion
        }
        public void MSASHTTP_S01_TC13_CommandCode_UserRelatedCommands()
        {
            #region Call ResolveRecipients command.
            object[] items = new object[] { Common.GetConfigurationPropertyValue("User1Name", Site) };
            ResolveRecipientsRequest resolveRecipientsRequest  = Common.CreateResolveRecipientsRequest(items);
            SendStringResponse       resolveRecipientsResponse = HTTPAdapter.HTTPPOST(CommandName.ResolveRecipients, null, resolveRecipientsRequest.GetRequestDataSerializedXML());

            // Check the command is executed successfully.
            this.CheckResponseStatus(resolveRecipientsResponse.ResponseDataXML);
            #endregion

            #region Call Settings command.
            SettingsRequest    settingsRequest  = Common.CreateSettingsRequest();
            SendStringResponse settingsResponse = HTTPAdapter.HTTPPOST(CommandName.Settings, null, settingsRequest.GetRequestDataSerializedXML());

            // Check the command is executed successfully.
            this.CheckResponseStatus(settingsResponse.ResponseDataXML);
            #endregion
        }
示例#4
0
        public void MSASHTTP_S03_TC04_LimitChangesToUserAgentHeader()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(456, this.Site), "Exchange server 2013 and above support using different values for the number of User-Agent changes or the time period.");
            Site.Assume.IsTrue(Common.IsRequirementEnabled(457, this.Site), "Exchange server 2013 and above support blocking clients for a different amount of time.");

            #region Call FolderSync command for the first time with User-Agent header.
            // Wait for 1 minute
            System.Threading.Thread.Sleep(new TimeSpan(0, 1, 0));

            DateTime startTime             = DateTime.Now;
            string   folderSyncRequestBody = Common.CreateFolderSyncRequest("0").GetRequestDataSerializedXML();
            Dictionary <HTTPPOSTRequestPrefixField, string> requestPrefixFields = new Dictionary <HTTPPOSTRequestPrefixField, string>
            {
                {
                    HTTPPOSTRequestPrefixField.UserAgent, Common.GenerateResourceName(this.Site, "ASOM", 1)
                }
            };

            this.HTTPAdapter.ConfigureRequestPrefixFields(requestPrefixFields);
            SendStringResponse folderSyncResponse = HTTPAdapter.HTTPPOST(CommandName.FolderSync, null, folderSyncRequestBody);

            // Check the command is executed successfully.
            this.CheckResponseStatus(folderSyncResponse.ResponseDataXML);

            #endregion

            #region Call FolderSync command for the second time with updated User-Agent header.

            requestPrefixFields[HTTPPOSTRequestPrefixField.UserAgent] = Common.GenerateResourceName(this.Site, "ASOM", 2);
            this.HTTPAdapter.ConfigureRequestPrefixFields(requestPrefixFields);
            folderSyncResponse = HTTPAdapter.HTTPPOST(CommandName.FolderSync, null, folderSyncRequestBody);

            // Check the command is executed successfully.
            this.CheckResponseStatus(folderSyncResponse.ResponseDataXML);

            #endregion

            #region Call FolderSync command for third time with updated User-Agent header.

            requestPrefixFields[HTTPPOSTRequestPrefixField.UserAgent] = Common.GenerateResourceName(this.Site, "ASOM", 3);
            this.HTTPAdapter.ConfigureRequestPrefixFields(requestPrefixFields);

            try
            {
                folderSyncResponse = HTTPAdapter.HTTPPOST(CommandName.FolderSync, null, folderSyncRequestBody);
                Site.Assert.Fail("HTTP error 503 should be returned if server blocks a client from changing its User-Agent header value.");
            }
            catch (System.Net.WebException exception)
            {
                int statusCode = ((System.Net.HttpWebResponse)exception.Response).StatusCode.GetHashCode();

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

                    // Verify MS-ASHTTP requirement: MS-ASHTTP_R456
                    // Server configures the number of changes and the time period, and expected HTTP error is returned, this requirement can be captured.
                    Site.CaptureRequirementIfAreEqual <int>(
                        503,
                        statusCode,
                        456,
                        @"[In Appendix A: Product Behavior] Implementation can be configured to use different values for the allowed number of changes and the time period. (<9> Section 3.2.5.1.1:  Exchange 2013 , Exchange 2016, and Exchange 2019 can be configured to use different values for the allowed number of changes and the time period.)");
                }
            }

            #endregion

            #region Call FolderSync command after server blocks client from changing its User-Agent header value.
            requestPrefixFields[HTTPPOSTRequestPrefixField.UserAgent] = Common.GenerateResourceName(this.Site, "ASOM", 4);
            this.HTTPAdapter.ConfigureRequestPrefixFields(requestPrefixFields);

            bool isCorrectBlocked = false;
            try
            {
                folderSyncResponse = HTTPAdapter.HTTPPOST(CommandName.FolderSync, null, folderSyncRequestBody);
            }
            catch (System.Net.WebException)
            {
                // HTTP error returns indicates server blocks client.
                isCorrectBlocked = true;
            }

            // Server sets blocking client for 1 minute, wait for 1 minute for un-blocking.
            System.Threading.Thread.Sleep(new TimeSpan(0, 1, 0));

            requestPrefixFields[HTTPPOSTRequestPrefixField.UserAgent] = Common.GenerateResourceName(this.Site, "ASOM", 5);
            this.HTTPAdapter.ConfigureRequestPrefixFields(requestPrefixFields);
            try
            {
                folderSyncResponse = HTTPAdapter.HTTPPOST(CommandName.FolderSync, null, folderSyncRequestBody);
                isCorrectBlocked   = isCorrectBlocked && true;
            }
            catch (System.Net.WebException)
            {
                // HTTP error returns indicates server still blocks client.
                isCorrectBlocked = false;
            }

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

                // Verify MS-ASHTTP requirement: MS-ASHTTP_R457
                // FolderSync command runs successfully after the blocking time period, and it runs with exception during the time period,
                // this requirement can be captured.
                Site.CaptureRequirementIfIsTrue(
                    isCorrectBlocked,
                    457,
                    @"[In Appendix A: Product Behavior] Implementation can be configured to block clients for an amount of time other than 14 hours. (<10> Section 3.2.5.1.1:  Exchange 2013, Exchange 2016, and Exchange 2019 can be configured to block clients for an amount of time other than 14 hours.)");
            }

            // Wait for 1 minute
            System.Threading.Thread.Sleep(new TimeSpan(0, 1, 0));

            #endregion

            #region Reset the User-Agent header.
            requestPrefixFields[HTTPPOSTRequestPrefixField.UserAgent] = null;
            this.HTTPAdapter.ConfigureRequestPrefixFields(requestPrefixFields);
            #endregion
        }
        public void MSASHTTP_S01_TC10_CommandParameter_Occurrence_PlainText()
        {
            #region User3 calls SendMail to send a meeting request to User2
            IDictionary <HTTPPOSTRequestPrefixField, string> requestPrefix = new Dictionary <HTTPPOSTRequestPrefixField, string>();
            string sendMailSubject   = Common.GenerateResourceName(this.Site, "SendMail");
            string smartReplySubject = Common.GenerateResourceName(this.Site, "SmartReply");

            // Call ConfigureRequestPrefixFields to change the QueryValueType.
            requestPrefix.Add(HTTPPOSTRequestPrefixField.QueryValueType, QueryValueType.PlainText.ToString());
            this.HTTPAdapter.ConfigureRequestPrefixFields(requestPrefix);

            // Switch the current user to user3 and synchronize the collection hierarchy.
            this.SwitchUser(this.UserThreeInformation, true);

            // Call SendMail command to send the meeting request to User2.
            this.SendMeetingRequest(sendMailSubject);
            #endregion

            #region User2 calls SmartReply command to reply the request to User3 with Occurrence command parameter
            // Call ConfigureRequestPrefixFields to switch the credential to User2 and synchronize the collection hierarchy.
            this.SwitchUser(this.UserTwoInformation, true);

            // Call Sync command to get the ServerId of the received meeting request.
            string itemServerId = this.LoopToSyncItem(this.UserTwoInformation.InboxCollectionId, sendMailSubject, true);

            // Add the received item to the item collection of User2.
            CreatedItems inboxItemForUserTwo = new CreatedItems
            {
                CollectionId = this.UserTwoInformation.InboxCollectionId
            };
            inboxItemForUserTwo.ItemSubject.Add(sendMailSubject);
            this.UserTwoInformation.UserCreatedItems.Add(inboxItemForUserTwo);

            // Call Sync command to get the ServerId of the calendar item.
            string calendarItemServerId = this.LoopToSyncItem(this.UserTwoInformation.CalendarCollectionId, sendMailSubject, true);

            CreatedItems calendarItemForUserTwo = new CreatedItems
            {
                CollectionId = this.UserTwoInformation.CalendarCollectionId
            };
            calendarItemForUserTwo.ItemSubject.Add(sendMailSubject);
            this.UserTwoInformation.UserCreatedItems.Add(calendarItemForUserTwo);

            // Call SmartReply command with the Occurrence command parameter.
            string startTime               = (string)this.GetElementValueFromSyncResponse(this.UserTwoInformation.CalendarCollectionId, calendarItemServerId, Response.ItemsChoiceType8.StartTime);
            string occurrence              = TestSuiteHelper.ConvertInstanceIdFormat(startTime);
            string userTwoMailboxAddress   = Common.GetMailAddress(this.UserTwoInformation.UserName, this.UserTwoInformation.UserDomain);
            string userThreeMailboxAddress = Common.GetMailAddress(this.UserThreeInformation.UserName, this.UserThreeInformation.UserDomain);
            this.CallSmartReplyCommand(userTwoMailboxAddress, userThreeMailboxAddress, itemServerId, smartReplySubject, null, null, occurrence);

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

            // Verify MS-ASHTTP requirement: MS-ASHTTP_R513
            // SmartReply command executed successfully with setting Occurrence command parameter, so this requirement can be captured.
            Site.CaptureRequirement(
                513,
                @"[In Command-Specific URI Parameters] [Parameter] Occurrence [is described as] A string that specifies the ID of a particular occurrence in a recurring meeting.");

            #endregion

            #region User3 gets the reply mail
            // Call ConfigureRequestPrefixFields to switch the credential to User3 and synchronize the collection hierarchy.
            this.SwitchUser(this.UserThreeInformation, false);

            // Call Sync command to get the ServerId of the received the reply.
            this.LoopToSyncItem(this.UserThreeInformation.InboxCollectionId, smartReplySubject, true);
            this.AddCreatedItemToCollection("User3", this.UserThreeInformation.InboxCollectionId, smartReplySubject);

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

            // Verify MS-ASHTTP requirement: MS-ASHTTP_R529
            // SmartReply command executed successfully with setting Occurrence command parameter, so this requirement can be captured.
            Site.CaptureRequirement(
                529,
                @"[In Command-Specific URI Parameters] [Parameter] Occurrence [is used by] SmartReply.");
            #endregion

            #region Reset the query value type and user credential.
            requestPrefix[HTTPPOSTRequestPrefixField.QueryValueType] = Common.GetConfigurationPropertyValue("HeaderEncodingType", this.Site);
            HTTPAdapter.ConfigureRequestPrefixFields(requestPrefix);
            this.SwitchUser(this.UserOneInformation, false);
            #endregion
        }
        public void MSASHTTP_S01_TC09_CommandParameter_Occurrence_Base64()
        {
            #region User3 calls SendMail to send a meeting request to User2.
            IDictionary <HTTPPOSTRequestPrefixField, string> requestPrefix = new Dictionary <HTTPPOSTRequestPrefixField, string>();
            string sendMailSubject     = Common.GenerateResourceName(this.Site, "SendMail");
            string smartForwardSubject = Common.GenerateResourceName(this.Site, "SmartForward");

            // Call ConfigureRequestPrefixFields to change the QueryValueType to Base64.
            requestPrefix.Add(HTTPPOSTRequestPrefixField.QueryValueType, QueryValueType.Base64.ToString());
            this.HTTPAdapter.ConfigureRequestPrefixFields(requestPrefix);

            // Switch the current user to user3 and synchronize the collection hierarchy.
            this.SwitchUser(this.UserThreeInformation, true);

            // Call SendMail command to send the meeting request to User2.
            this.SendMeetingRequest(sendMailSubject);
            #endregion

            #region User2 calls MeetingResponse command to accept the received meeting request and forward it to User1.
            // Call ConfigureRequestPrefixFields to switch the credential to User2 and synchronize the collection hierarchy.
            this.SwitchUser(this.UserTwoInformation, true);

            // Call Sync command to get the ServerId of the received meeting request.
            string itemServerId = this.LoopToSyncItem(this.UserTwoInformation.InboxCollectionId, sendMailSubject, true);

            // Add the received item to the item collection of User2.
            CreatedItems inboxItemForUserTwo = new CreatedItems
            {
                CollectionId = this.UserTwoInformation.InboxCollectionId
            };
            inboxItemForUserTwo.ItemSubject.Add(sendMailSubject);
            this.UserTwoInformation.UserCreatedItems.Add(inboxItemForUserTwo);

            // Check the calendar item if is exist.
            string calendarItemServerId = this.LoopToSyncItem(this.UserTwoInformation.CalendarCollectionId, sendMailSubject, true);

            CreatedItems calendarItemForUserTwo = new CreatedItems
            {
                CollectionId = this.UserTwoInformation.CalendarCollectionId
            };
            calendarItemForUserTwo.ItemSubject.Add(sendMailSubject);
            this.UserTwoInformation.UserCreatedItems.Add(calendarItemForUserTwo);

            // Call MeetingResponse command to accept the received meeting request.
            this.CallMeetingResponseCommand(this.UserTwoInformation.InboxCollectionId, itemServerId);

            // The accepted meeting request will be moved to Delete Items folder.
            itemServerId = this.LoopToSyncItem(this.UserTwoInformation.DeletedItemsCollectionId, sendMailSubject, true);

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

            // Verify MS-ASHTTP requirement: MS-ASHTTP_R432
            // MeetingResponse command is executed successfully, so this requirement can be captured.
            Site.CaptureRequirementIfIsNotNull(
                itemServerId,
                432,
                @"[In Command Codes] [Command] MeetingResponse [is] used to accept [, tentatively accept , or decline] a meeting request in the user's Inbox folder.");

            // Remove the inboxItemForUserTwo object from the clean up list since it has been moved to Delete Items folder.
            this.UserTwoInformation.UserCreatedItems.Remove(inboxItemForUserTwo);
            this.AddCreatedItemToCollection("User2", this.UserTwoInformation.DeletedItemsCollectionId, sendMailSubject);

            // Call SmartForward command to forward the meeting to User1
            string startTime             = (string)this.GetElementValueFromSyncResponse(this.UserTwoInformation.CalendarCollectionId, calendarItemServerId, Response.ItemsChoiceType8.StartTime);
            string occurrence            = TestSuiteHelper.ConvertInstanceIdFormat(startTime);
            string userOneMailboxAddress = Common.GetMailAddress(this.UserOneInformation.UserName, this.UserOneInformation.UserDomain);
            string userTwoMailboxAddress = Common.GetMailAddress(this.UserTwoInformation.UserName, this.UserTwoInformation.UserDomain);
            this.CallSmartForwardCommand(userTwoMailboxAddress, userOneMailboxAddress, itemServerId, smartForwardSubject, null, null, occurrence);

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

            // Verify MS-ASHTTP requirement: MS-ASHTTP_R513
            // SmartForward command executed successfully with setting Occurrence command parameter, so this requirement can be captured.
            Site.CaptureRequirement(
                513,
                @"[In Command-Specific URI Parameters] [Parameter] Occurrence [is described as] A string that specifies the ID of a particular occurrence in a recurring meeting.");

            this.AddCreatedItemToCollection("User3", this.UserThreeInformation.DeletedItemsCollectionId, "Meeting Forward Notification: " + smartForwardSubject);
            #endregion

            #region User1 gets the forwarded meeting request
            // Call ConfigureRequestPrefixFields to switch the credential to User1 and synchronize the collection hierarchy.
            this.SwitchUser(this.UserOneInformation, true);

            this.AddCreatedItemToCollection("User1", this.UserOneInformation.InboxCollectionId, smartForwardSubject);
            this.AddCreatedItemToCollection("User1", this.UserOneInformation.CalendarCollectionId, smartForwardSubject);

            // Call Sync command to get the ServerId of the received meeting request.
            this.LoopToSyncItem(this.UserOneInformation.InboxCollectionId, smartForwardSubject, true);

            // Call Sync command to get the ServerId of the calendar item.
            this.LoopToSyncItem(this.UserOneInformation.CalendarCollectionId, smartForwardSubject, true);
            #endregion

            #region User3 gets the Meeting Forward Notification email in the Deleted Items folder.
            // Call ConfigureRequestPrefixFields to switch the credential to User3 and synchronize the collection hierarchy.
            this.SwitchUser(this.UserThreeInformation, false);

            // Call Sync command to get the ServerId of the received meeting request and the notification email.
            this.LoopToSyncItem(this.UserThreeInformation.DeletedItemsCollectionId, "Meeting Forward Notification: " + smartForwardSubject, true);

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

            // Verify MS-ASHTTP requirement: MS-ASHTTP_R119
            // SmartForward command executed successfully with setting Occurrence command parameter, so this requirement can be captured.
            Site.CaptureRequirement(
                119,
                @"[In Command-Specific URI Parameters] [Parameter] Occurrence [is used by] SmartForward.");
            #endregion

            #region Reset the query value type.
            requestPrefix[HTTPPOSTRequestPrefixField.QueryValueType] = Common.GetConfigurationPropertyValue("HeaderEncodingType", this.Site);
            HTTPAdapter.ConfigureRequestPrefixFields(requestPrefix);
            #endregion
        }