Exemplo n.º 1
0
        /// <summary>
        /// This ROP commits the changes made to a message.
        /// </summary>
        /// <param name="handle">The handle to operate.</param>
        /// <param name="needVerify">Whether need to verify the response.</param>
        /// <returns>The response of this ROP.</returns>
        private RopSaveChangesMessageResponse RopSaveChangesMessage(uint handle, bool needVerify)
        {
            this.rawDataValue      = null;
            this.responseValue     = null;
            this.responseSOHsValue = null;

            RopSaveChangesMessageRequest saveChangesMessageRequest = new RopSaveChangesMessageRequest()
            {
                RopId               = (byte)RopId.RopSaveChangesMessage,
                LogonId             = LogonId,
                InputHandleIndex    = (byte)HandleIndex.FirstIndex,
                ResponseHandleIndex = (byte)HandleIndex.SecondIndex,

                // Set the SaveFlags flag to ForceSave, which indicates the client requests server to commit the changes.
                SaveFlags = (byte)SaveFlags.ForceSave,
            };

            this.responseSOHsValue = this.ProcessSingleRop(saveChangesMessageRequest, handle, ref this.responseValue, ref this.rawDataValue, RopResponseType.SuccessResponse);
            RopSaveChangesMessageResponse saveChangesMessageResponse = (RopSaveChangesMessageResponse)this.responseValue;

            if (needVerify)
            {
                this.Site.Assert.AreEqual((uint)RopResponseType.SuccessResponse, saveChangesMessageResponse.ReturnValue, string.Format("RopSaveChangesMessage Failed! Error: 0x{0:X8}", saveChangesMessageResponse.ReturnValue));
            }

            return(saveChangesMessageResponse);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create and save message.
        /// </summary>
        /// <param name="folderHandle">Folder Handle </param>
        /// <param name="folderId">Folder Id  which messages will be create in.</param>
        /// <param name="associatedFlag">Specifies whether the message is a Folder Associated Information message.</param>
        /// <param name="messageId"> Message Id which will be returned by server.</param>
        /// <param name="messageHandle">Message Handle which will be returned by server.</param>
        protected void CreateSaveMessage(uint folderHandle, ulong folderId, byte associatedFlag, ref ulong messageId, ref uint messageHandle)
        {
            // Create a Message.
            RopCreateMessageRequest  createMessageRequest  = new RopCreateMessageRequest();
            RopCreateMessageResponse createMessageResponse = new RopCreateMessageResponse();
            object ropResponse = null;

            createMessageRequest.RopId             = (byte)RopId.RopCreateMessage;
            createMessageRequest.LogonId           = Constants.CommonLogonId;
            createMessageRequest.InputHandleIndex  = Constants.CommonInputHandleIndex;
            createMessageRequest.OutputHandleIndex = Constants.CommonOutputHandleIndex;
            createMessageRequest.CodePageId        = 0x0FFF;
            createMessageRequest.FolderId          = folderId;
            createMessageRequest.AssociatedFlag    = associatedFlag;
            this.Adapter.DoRopCall(createMessageRequest, folderHandle, ref ropResponse, ref this.responseHandles);

            createMessageResponse = (RopCreateMessageResponse)ropResponse;
            Site.Assert.AreEqual <uint>(0, createMessageResponse.ReturnValue, "Creating Message should succeed");
            messageHandle = this.responseHandles[0][createMessageResponse.OutputHandleIndex];

            // Save a Message.
            RopSaveChangesMessageRequest  saveChangesMessageRequest  = new RopSaveChangesMessageRequest();
            RopSaveChangesMessageResponse saveChangesMessageResponse = new RopSaveChangesMessageResponse();

            saveChangesMessageRequest.RopId               = (byte)RopId.RopSaveChangesMessage;
            saveChangesMessageRequest.LogonId             = Constants.CommonLogonId;
            saveChangesMessageRequest.InputHandleIndex    = Constants.CommonInputHandleIndex;
            saveChangesMessageRequest.ResponseHandleIndex = 0x01;
            saveChangesMessageRequest.SaveFlags           = 0x0C;
            this.Adapter.DoRopCall(saveChangesMessageRequest, messageHandle, ref ropResponse, ref this.responseHandles);

            saveChangesMessageResponse = (RopSaveChangesMessageResponse)ropResponse;
            Site.Assert.AreEqual <uint>(
                0,
                createMessageResponse.ReturnValue,
                "Save Messages Success.");
            messageId = saveChangesMessageResponse.MessageId;
        }
        public void MSOXCROPS_S12_TC01_TestRopPending()
        {
            this.CheckTransportIsSupported();

            this.cropsAdapter.RpcConnect(
                Common.GetConfigurationPropertyValue("SutComputerName", this.Site),
                ConnectionType.PrivateMailboxServer,
                Common.GetConfigurationPropertyValue("UserEssdn", this.Site),
                Common.GetConfigurationPropertyValue("Domain", this.Site),
                Common.GetConfigurationPropertyValue("UserName", this.Site),
                Common.GetConfigurationPropertyValue("PassWord", this.Site));

            // Step 1: Send the RopRegisterNotification request and verify the success response.
            #region RopRegisterNotification success response

            // Log on to the private mailbox.
            RopLogonResponse logonResponse = Logon(LogonType.Mailbox, this.userDN, out inputObjHandle);

            RopRegisterNotificationRequest  registerNotificationRequest;
            RopRegisterNotificationResponse registerNotificationResponse;

            registerNotificationRequest.RopId = (byte)RopId.RopRegisterNotification;

            registerNotificationRequest.LogonId           = TestSuiteBase.LogonId;
            registerNotificationRequest.InputHandleIndex  = TestSuiteBase.InputHandleIndex0;
            registerNotificationRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex0;

            // The server MUST send notifications to the client when CriticalError events occur within the scope of interest
            registerNotificationRequest.NotificationTypes = (byte)NotificationTypes.NewMail;
            registerNotificationRequest.Reserved          = TestSuiteBase.Reserved;

            // TRUE: the scope for notifications is the entire database
            registerNotificationRequest.WantWholeStore = TestSuiteBase.NonZero;

            registerNotificationRequest.FolderId  = logonResponse.FolderIds[4];
            registerNotificationRequest.MessageId = MS_OXCROPSAdapter.MessageIdForRops;

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 1: Begin to send the RopRegisterNotification request:NotificationTypes=0x02.");

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                registerNotificationRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            registerNotificationResponse = (RopRegisterNotificationResponse)response;

            Site.Assert.AreEqual <uint>(
                TestSuiteBase.SuccessReturnValue,
                registerNotificationResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0 (success)");

            // Set NotificationTypes to 0x04, which means the server sends notifications to the client when ObjectCreated events occur
            // within the scope of interest, as specified in [MS-OXCNOTIF].
            registerNotificationRequest.NotificationTypes = (byte)NotificationTypes.ObjectCreated;

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 1: Begin to send the RopRegisterNotification request:NotificationTypes=0x04.");

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                registerNotificationRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            registerNotificationResponse = (RopRegisterNotificationResponse)response;

            Site.Assert.AreEqual <uint>(
                TestSuiteBase.SuccessReturnValue,
                registerNotificationResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0 (success)");

            // Set NotificationTypes to 0x08, which means the server sends notifications to the client when ObjectDeleted events occur
            // within the scope of interest, as specified in [MS-OXCNOTIF].
            registerNotificationRequest.NotificationTypes = (byte)NotificationTypes.ObjectDeleted;

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 1: Begin to send the RopRegisterNotification request:NotificationTypes=0x08.");

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                registerNotificationRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            registerNotificationResponse = (RopRegisterNotificationResponse)response;

            Site.Assert.AreEqual <uint>(
                TestSuiteBase.SuccessReturnValue,
                registerNotificationResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0 (success)");

            // Set NotificationTypes to 0x10, which means the server sends notifications to the client when ObjectModified events occur
            // within the scope of interest, as specified in [MS-OXCNOTIF].
            registerNotificationRequest.NotificationTypes = (byte)NotificationTypes.ObjectModified;

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 1: Begin to send the RopRegisterNotification request:NotificationTypes=0x10.");

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                registerNotificationRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            registerNotificationResponse = (RopRegisterNotificationResponse)response;

            Site.Assert.AreEqual <uint>(
                TestSuiteBase.SuccessReturnValue,
                registerNotificationResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0 (success)");

            // Set NotificationTypes to 0x20, which means the server sends notifications to the client when ObjectMoved events occur
            // within the scope of interest, as specified in [MS-OXCNOTIF].
            registerNotificationRequest.NotificationTypes = (byte)NotificationTypes.ObjectMoved;

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 1: Begin to send the RopRegisterNotification request:NotificationTypes=0x20.");

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                registerNotificationRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            registerNotificationResponse = (RopRegisterNotificationResponse)response;

            Site.Assert.AreEqual <uint>(
                TestSuiteBase.SuccessReturnValue,
                registerNotificationResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0 (success)");

            // Set NotificationTypes to 0x40, which means the server sends notifications to the client when ObjectCopied events occur
            // within the scope of interest, as specified in [MS-OXCNOTIF].
            registerNotificationRequest.NotificationTypes = (byte)NotificationTypes.ObjectCopied;

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 1: Begin to send the RopRegisterNotification request:NotificationTypes=0x40.");

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                registerNotificationRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            registerNotificationResponse = (RopRegisterNotificationResponse)response;

            Site.Assert.AreEqual <uint>(
                TestSuiteBase.SuccessReturnValue,
                registerNotificationResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0 (success)");

            // Set NotificationTypes to 0x80, which means the server sends notifications to the client when SearchCompleted events occur
            // within the scope of interest, as specified in [MS-OXCNOTIF].
            registerNotificationRequest.NotificationTypes = (byte)NotificationTypes.SearchCompleted;

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 1: Begin to send the RopRegisterNotification request:NotificationTypes=0x80.");

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                registerNotificationRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            registerNotificationResponse = (RopRegisterNotificationResponse)response;

            Site.Assert.AreEqual <uint>(
                TestSuiteBase.SuccessReturnValue,
                registerNotificationResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0 (success)");

            #endregion

            // Step 2: Create message,Save message to test RopPending, RopNotify and RopBufferTooSmall
            #region RopRegisterNotification success response

            #region prepare rops for createmessage, savemessage and release
            RopCreateMessageRequest      createMessageRequest      = new RopCreateMessageRequest();
            RopSaveChangesMessageRequest saveChangesMessageRequest = new RopSaveChangesMessageRequest();
            RopReleaseRequest            releaseRequest            = new RopReleaseRequest();
            this.PrepareRops(logonResponse, ref createMessageRequest, ref saveChangesMessageRequest, ref releaseRequest);
            #endregion
            // Totally create message loop count.
            int  loopCount;
            uint tableHandle = 0;

            string transportSeq = Common.GetConfigurationPropertyValue("TransportSeq", this.Site).ToLower();
            if (transportSeq == "mapi_http")
            {
                loopCount = 20;
                this.CreateVastMessages(ref logonResponse, out tableHandle, loopCount, createMessageRequest, saveChangesMessageRequest, releaseRequest);
            }
            else
            {
                loopCount = 1000;
                this.CreateSingleProcessEachLoop(ref logonResponse, out tableHandle, loopCount, createMessageRequest, saveChangesMessageRequest, releaseRequest);
            }

            #region RopBufferTooSmall response

            List <ISerializable> ropRequests1  = new List <ISerializable>();
            List <uint>          inputObjects1 = new List <uint>
            {
                this.inputObjHandle
            };
            List <IDeserializable>     ropResponses1 = new List <IDeserializable>();
            RopGetPropertiesAllRequest getPropertiesAllRequest;

            getPropertiesAllRequest.RopId            = (byte)RopId.RopGetPropertiesAll;
            getPropertiesAllRequest.LogonId          = TestSuiteBase.LogonId;
            getPropertiesAllRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

            // Set PropertySizeLimit, which specifies the maximum size allowed for a property value returned.
            getPropertiesAllRequest.PropertySizeLimit = TestSuiteBase.PropertySizeLimit;

            getPropertiesAllRequest.WantUnicode = Convert.ToUInt16(TestSuiteBase.Zero);
            byte count = 255;
            for (byte i = 1; i < count; i++)
            {
                ropRequests1.Add(getPropertiesAllRequest);
            }

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 2: Begin to send the ProcessMutipleRops request to verify RopBufferTooSmall response.");

            // Verify the RopBufferTooSmall
            this.responseSOHs = cropsAdapter.ProcessMutipleRops(ropRequests1, inputObjects1, ref ropResponses1, ref this.rawData, RopResponseType.FailureResponse);

            #endregion

            List <IDeserializable> ropResponses4 = new List <IDeserializable>();

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 2: Begin to resubmit all the GetPropertiesAll request.");

            // All the requests are GetPropertiesAllRequest, resubmit the request in another call and get the responses in the ropResponses4
            this.responseSOHs = cropsAdapter.ProcessMutipleRops(ropRequests1, inputObjects1, ref ropResponses4, ref this.rawData, RopResponseType.SuccessResponse);

            #region RopSetColumns success response

            RopSetColumnsRequest  setColumnsRequest;
            RopSetColumnsResponse setColumnsResponse;

            PropertyTag[] propertyTags = CreateSampleContentsTablePropertyTags();
            setColumnsRequest.RopId            = (byte)RopId.RopSetColumns;
            setColumnsRequest.LogonId          = TestSuiteBase.LogonId;
            setColumnsRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            setColumnsRequest.SetColumnsFlags  = (byte)AsynchronousFlags.None;
            setColumnsRequest.PropertyTagCount = (ushort)propertyTags.Length;
            setColumnsRequest.PropertyTags     = propertyTags;

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 2: Begin to send the RopSetColumns request.");

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                setColumnsRequest,
                tableHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            setColumnsResponse = (RopSetColumnsResponse)response;
            Site.Assert.AreEqual <uint>(
                TestSuiteBase.SuccessReturnValue,
                setColumnsResponse.ReturnValue,
                "if ROP succeeds, the ReturnValue of its response is 0(success)");

            #endregion

            #region RopQueryRows success response: send RopSetColumns and RopQueryRows in a request buffer
            RopQueryRowsRequest queryRowsRequest;

            queryRowsRequest.RopId            = (byte)RopId.RopQueryRows;
            queryRowsRequest.LogonId          = TestSuiteBase.LogonId;
            queryRowsRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            queryRowsRequest.QueryRowsFlags   = (byte)QueryRowsFlags.Advance;
            queryRowsRequest.ForwardRead      = TestSuiteBase.NonZero;

            // Set RowCount to 0x01, which the number of requested rows, as specified in [MS-OXCROPS].
            queryRowsRequest.RowCount = TestSuiteBase.RowCount;

            List <ISerializable> ropRequests = new List <ISerializable>
            {
                setColumnsRequest, queryRowsRequest
            };
            createMessageRequest.InputHandleIndex  = TestSuiteBase.InputHandleIndex2;
            createMessageRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex3;
            createMessageRequest.FolderId          = logonResponse.FolderIds[4];
            ropRequests.Add(createMessageRequest);
            saveChangesMessageRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex3;
            ropRequests.Add(saveChangesMessageRequest);
            List <uint> inputObjects = new List <uint>
            {
                tableHandle,
                0xFFFF,
                this.inputObjHandle,
                0xFFFF
            };

            // 0xFFFF indicates a default input handle.
            List <IDeserializable> ropResponses = new List <IDeserializable>();

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 2: Begin to send the multiple ROPs request to verify the RopNotify response.");

            // Verify the RopNotify
            this.responseSOHs = cropsAdapter.ProcessMutipleRops(ropRequests, inputObjects, ref ropResponses, ref this.rawData, RopResponseType.SuccessResponse);

            // Set RowCount to 0x0600, which the number of requested rows, as specified in [MS-OXCROPS].
            queryRowsRequest.RowCount = TestSuiteBase.RowCount;

            List <ISerializable> ropRequests2 = new List <ISerializable>
            {
                setColumnsRequest, queryRowsRequest
            };
            createMessageRequest.InputHandleIndex  = TestSuiteBase.InputHandleIndex2;
            createMessageRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex3;
            createMessageRequest.FolderId          = logonResponse.FolderIds[4];
            ropRequests2.Add(createMessageRequest);
            saveChangesMessageRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex3;
            ropRequests2.Add(saveChangesMessageRequest);
            List <uint> inputObjects2 = new List <uint>
            {
                tableHandle,
                0xFFFF,
                this.inputObjHandle,
                0xFFFF
            };

            // 0xFFFF indicates a default input handle.
            List <IDeserializable> ropResponses2 = new List <IDeserializable>();

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 2: Begin to send the multiple ROPs request to verify the RopPending response.");

            // Verify the RopPending
            this.responseSOHs = cropsAdapter.ProcessMutipleRops(ropRequests2, inputObjects2, ref ropResponses2, ref this.rawData, RopResponseType.SuccessResponse);

            bool isContainedRopPending = false;
            for (int i = 1; i < ropResponses2.Count; i++)
            {
                if (ropResponses2[i] is RopPendingResponse)
                {
                    isContainedRopPending = true;
                    break;
                }
            }

            // Send an empty ROP to verify all queued RopNotify response have got in last step.
            List <ISerializable>   ropRequestsEmpty = new List <ISerializable>(0x02);
            List <IDeserializable> ropResponsesNull = new List <IDeserializable>();

            this.responseSOHs = cropsAdapter.ProcessMutipleRops(ropRequestsEmpty, inputObjects, ref ropResponsesNull, ref this.rawData, RopResponseType.SuccessResponse);

            if (ropResponsesNull.Count == 0)
            {
                if (Common.IsRequirementEnabled(469303, this.Site))
                {
                    // Add the debug information
                    Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R469303");

                    // Verify MS-OXCROPS requirement: MS-OXCROPS_R469303
                    Site.CaptureRequirementIfIsTrue(
                        isContainedRopPending,
                        469303,
                        @"[In Appendix B: Product Behavior] Implementation does include a RopPending ROP response (section 2.2.14.3) even though the ROP output buffer contains all queued RopNotify ROP responses (section 2.2.14.2). (<19> Section 3.1.5.1.3: Exchange 2007 follows this behavior.)");
                }

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

                    // Verify MS-OXCROPS requirement: MS-OXCROPS_R4693031
                    Site.CaptureRequirementIfIsFalse(
                        isContainedRopPending,
                        4693031,
                        @"[In Appendix B: Product Behavior] Implementation does not include a RopPending ROP response if the ROP output buffer contain all queued RopNotify ROP responses. (Exchange 2010 and above follow this behavior.)");
                }
            }
            #endregion

            #endregion
        }