Exemplo n.º 1
0
        /// <summary>
        /// Logon Mail server.
        /// </summary>
        /// <param name="logonType">Logon Type.</param>
        /// <param name="objHandle">Server response handle.</param>
        /// <param name="openFlags">The possible values are specified in [MS-OXCSTOR]. This structure contains more flags that control the behavior of the logon.</param>
        /// <returns>Logon Response.</returns>
        protected RopLogonResponse Logon(LogonFlags logonType, out uint objHandle, uint openFlags)
        {
            RopLogonRequest logonRequest = new RopLogonRequest();
            object          ropResponse  = null;

            string userDN = Common.GetConfigurationPropertyValue("AdminUserEssdn", this.Site) + Constants.StringNullTerminated;

            logonRequest.RopId             = (byte)RopId.RopLogon;
            logonRequest.LogonId           = Constants.CommonLogonId;
            logonRequest.OutputHandleIndex = 0x0;
            logonRequest.StoreState        = 0;
            logonRequest.LogonFlags        = (byte)logonType;
            logonRequest.OpenFlags         = openFlags;

            if (LogonFlags.PublicFolder == logonType)
            {
                logonRequest.EssdnSize = 0;
                logonRequest.Essdn     = null;
            }
            else if (LogonFlags.Private == logonType)
            {
                logonRequest.EssdnSize = (ushort)Encoding.ASCII.GetByteCount(userDN);
                logonRequest.Essdn     = Encoding.ASCII.GetBytes(userDN);
            }

            this.Adapter.DoRopCall(logonRequest, this.LogonHandle, ref ropResponse, ref this.responseHandles);
            RopLogonResponse logonResponse = (RopLogonResponse)ropResponse;

            objHandle             = this.responseHandles[0][logonResponse.OutputHandleIndex];
            this.defaultFolderIds = logonResponse.FolderIds;
            return(logonResponse);
        }
Exemplo n.º 2
0
        /// <summary>
        /// This ROP logs on to a private mailbox or public folder.
        /// </summary>
        /// <param name="logonType">This type specifies ongoing action on the private mailbox or public folder.</param>
        /// <param name="logonResponse">The response of this ROP.</param>
        /// <param name="userDN">This string specifies which mailbox to log on to.</param>
        /// <param name="needVerify">Whether need to verify the response.</param>
        /// <returns>The handle of logon object.</returns>
        private uint RopLogon(LogonType logonType, out RopLogonResponse logonResponse, string userDN, bool needVerify)
        {
            this.rawDataValue      = null;
            this.responseValue     = null;
            this.responseSOHsValue = null;
            userDN += "\0";
            uint insideObjHandle = 0;

            RopLogonRequest logonRequest = new RopLogonRequest()
            {
                RopId             = (byte)RopId.RopLogon,
                LogonId           = LogonId,
                OutputHandleIndex = (byte)HandleIndex.FirstIndex,
                StoreState        = (uint)StoreState.None,

                // Set parameters for public folder logon type.
                LogonFlags = logonType == LogonType.PublicFolder ? (byte)LogonFlags.PublicFolder : (byte)LogonFlags.Private,
                OpenFlags  = logonType == LogonType.PublicFolder ? (uint)(OpenFlags.UsePerMDBReplipMapping | OpenFlags.Public) : (uint)OpenFlags.UsePerMDBReplipMapping,

                // Set EssdnSize to 0, which specifies the size of the ESSDN field.
                EssdnSize = logonType == LogonType.PublicFolder ? (ushort)0 : (ushort)Encoding.ASCII.GetByteCount(userDN),
                Essdn     = logonType == LogonType.PublicFolder ? null : Encoding.ASCII.GetBytes(userDN),
            };

            this.responseSOHsValue = this.ProcessSingleRop(logonRequest, insideObjHandle, ref this.responseValue, ref this.rawDataValue, RopResponseType.SuccessResponse);
            logonResponse          = (RopLogonResponse)this.responseValue;
            if (needVerify)
            {
                this.Site.Assert.AreEqual((uint)RopResponseType.SuccessResponse, logonResponse.ReturnValue, string.Format("Logon Failed! Error: 0x{0:X8}", logonResponse.ReturnValue));
            }

            return(this.responseSOHsValue[0][logonResponse.OutputHandleIndex]);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Logon to the server
        /// </summary>
        /// <returns>Server object handle of logon</returns>
        public RopLogonResponse Logon()
        {
            RopLogonRequest logonRequest;

            logonRequest.RopId             = 0xFE;
            logonRequest.LogonId           = 0x0;
            logonRequest.OutputHandleIndex = 0x0;

            string userDN = Common.GetConfigurationPropertyValue("User1Essdn", this.Site) + "\0";

            logonRequest.StoreState = 0;

            // logon to a private mailbox
            logonRequest.LogonFlags = 0x01;

            // requesting access to the mail box
            logonRequest.OpenFlags = 0x01000000;
            logonRequest.EssdnSize = (ushort)Encoding.ASCII.GetByteCount(userDN);
            logonRequest.Essdn     = Encoding.ASCII.GetBytes(userDN);

            Collection <uint> inputObjectHandles = new Collection <uint> {
                0
            };
            IList <IDeserializable> responses = this.Process(logonRequest, inputObjectHandles, out this.responseSOHs);

            RopLogonResponse logonResponse = (RopLogonResponse)responses[0];

            this.Site.Assert.AreEqual <uint>(
                0,
                logonResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0(success).");
            this.LogonHandle = this.responseSOHs[0][logonResponse.OutputHandleIndex];
            return(logonResponse);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Log on mailbox with specified user.
        /// </summary>
        /// <param name="testUser">Identify the user to log on to the server.</param>
        public void LogonMailbox(TestUser testUser)
        {
            this.testUser = testUser;
            RopLogonResponse logonResponse = new RopLogonResponse();

            if (testUser == TestUser.TestUser1)
            {
                this.OxoruleAdapter.Connect(ConnectionType.PrivateMailboxServer, this.User1Name, this.User1ESSDN, this.User1Password);

                // Logon to private mailbox.
                this.LogonHandle = this.OxoruleAdapter.RopLogon(LogonType.Mailbox, this.User1ESSDN, out logonResponse);
            }
            else
            {
                this.OxoruleAdapter.Connect(ConnectionType.PrivateMailboxServer, this.User2Name, this.User2ESSDN, this.User2Password);

                // Logon to private mailbox.
                this.LogonHandle = this.OxoruleAdapter.RopLogon(LogonType.Mailbox, this.User2ESSDN, out logonResponse);
            }

            // Get the mailbox's GUID
            this.MailboxGUID = logonResponse.MailboxGuid;

            // Get folder ids.
            this.InboxFolderID = logonResponse.FolderIds[4];
            this.DAFFolderID   = logonResponse.FolderIds[1];
            outBoxFolderID     = logonResponse.FolderIds[5];
            sentItemsFolderID  = logonResponse.FolderIds[6];

            // Open inbox and get inbox folder handle.
            RopOpenFolderResponse openInboxResponse = new RopOpenFolderResponse();

            this.InboxFolderHandle = this.OxoruleAdapter.RopOpenFolder(this.LogonHandle, this.InboxFolderID, out openInboxResponse);

            // Open DAF folder and get daf folder handle.
            RopOpenFolderResponse openDAFResponse = new RopOpenFolderResponse();

            this.DAFFolderHandle = this.OxoruleAdapter.RopOpenFolder(this.LogonHandle, this.DAFFolderID, out openDAFResponse);

            // Open outbox folder and get outbox folder handle.
            RopOpenFolderResponse openOutBoxResponse = new RopOpenFolderResponse();

            outBoxFolderHandle = this.OxoruleAdapter.RopOpenFolder(this.LogonHandle, outBoxFolderID, out openOutBoxResponse);

            // Open sent items folder and get sent items folder handle.
            RopOpenFolderResponse openSentItemsFolderResponse = new RopOpenFolderResponse();

            sentItemsFolderHandle = this.OxoruleAdapter.RopOpenFolder(this.LogonHandle, sentItemsFolderID, out openSentItemsFolderResponse);

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

            // Verify MS-OXORULE requirement: MS-OXORULE_R508.
            // If the DAF folder handle is not zero. It means the DAF has been created.
            Site.CaptureRequirementIfAreNotEqual <ulong>(
                0,
                this.DAFFolderHandle,
                508,
                @"[In Initialization] Prior to any client connecting to a mailbox, the server MUST ensure that the DAF has been created for that mailbox as specified in [MS-OXOSFLD] section 3.1.4.1.");
        }
Exemplo n.º 5
0
        public void MSOXCMSG_S06_TC02_RopReloadCachedInformationFailure()
        {
            this.CheckMapiHttpIsSupported();
            this.ConnectToServer(ConnectionType.PrivateMailboxServer);

            #region Call RopLogon to log on a private mailbox.
            RopLogonResponse logonResponse = this.Logon(LogonType.Mailbox, out this.insideObjHandle);
            #endregion

            #region Call RopCreateMessage to create a new message object.
            uint targetMessageHandle = this.CreatedMessage(logonResponse.FolderIds[4], this.insideObjHandle);
            #endregion

            #region Call RopSaveChangesMessage to commit the new message object.
            RopSaveChangesMessageResponse saveChangesMessageResponse = this.SaveMessage(targetMessageHandle, (byte)SaveFlags.ForceSave);
            Site.Assert.AreEqual <uint>(TestSuiteBase.Success, saveChangesMessageResponse.ReturnValue, TestSuiteBase.ROPSucceedMsg);
            ulong messageId = saveChangesMessageResponse.MessageId;
            #endregion

            this.ReleaseRop(targetMessageHandle);

            #region Call RopOpenMessage to open the created message.
            RopOpenMessageResponse openMessageResponse;
            uint openedMessageHandle = this.OpenSpecificMessage(logonResponse.FolderIds[4], messageId, this.insideObjHandle, MessageOpenModeFlags.ReadWrite, out openMessageResponse);
            #endregion

            #region Call RopReloadCachedInformation which contains an InputHandleIndex that does not refer to a message object.
            RopReloadCachedInformationRequest reloadCachedInformationRequest = new RopReloadCachedInformationRequest()
            {
                RopId            = (byte)RopId.RopReloadCachedInformation,
                LogonId          = CommonLogonId,
                InputHandleIndex = CommonInputHandleIndex,
                Reserved         = 0x0000
            };
            this.response     = new RopReloadCachedInformationResponse();
            this.ResponseSOHs = this.MSOXCMSGAdapter.DoRopCall(reloadCachedInformationRequest, TestSuiteBase.InvalidInputHandle, ref this.response, ref this.rawData, GetPropertiesFlags.None);
            RopReloadCachedInformationResponse reloadCachedInformationResponse = (RopReloadCachedInformationResponse)this.response;

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

            // Verify MS-OXCMSG requirement: MS-OXCMSG_R1498
            this.Site.CaptureRequirementIfAreEqual <uint>(
                0x000004b9,
                reloadCachedInformationResponse.ReturnValue,
                1498,
                @"[In Receiving a RopReloadCachedInformation ROP Request] [ecNullObject (0x000004b9)] means the value of the InputHandleIndex field on which this ROP [RopReloadCachedInformation] was called does not refer to a Message object.");
            #endregion

            #region Call RopRelease to release all resources
            this.ReleaseRop(openedMessageHandle);
            #endregion
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initialize a generic folder under inbox as a root folder for test.
        /// </summary>
        protected void GenericFolderInitialization()
        {
            RopLogonResponse logonResponse = this.Logon(LogonFlags.Private, out this.logonHandle);

            #region Open the inbox folder.
            RopOpenFolderRequest openFolderRequest = new RopOpenFolderRequest
            {
                RopId             = (byte)RopId.RopOpenFolder,
                LogonId           = Constants.CommonLogonId,
                InputHandleIndex  = Constants.CommonInputHandleIndex,
                OutputHandleIndex = Constants.CommonOutputHandleIndex,
                FolderId          = logonResponse.FolderIds[Constants.InboxIndex],
                OpenModeFlags     = (byte)FolderOpenModeFlags.OpenSoftDeleted
            };

            // Use the logon object as input handle here.
            RopOpenFolderResponse openFolderResponse = this.Adapter.OpenFolder(openFolderRequest, this.LogonHandle, ref this.responseHandles);
            this.inboxFolderHandle = this.responseHandles[0][openFolderResponse.OutputHandleIndex];
            #endregion

            #region Create a generic folder for test.
            RopCreateFolderRequest  createFolderRequest  = new RopCreateFolderRequest();
            RopCreateFolderResponse createFolderResponse = new RopCreateFolderResponse();
            createFolderRequest.RopId             = (byte)RopId.RopCreateFolder;
            createFolderRequest.LogonId           = Constants.CommonLogonId;
            createFolderRequest.InputHandleIndex  = Constants.CommonInputHandleIndex;
            createFolderRequest.OutputHandleIndex = Constants.CommonOutputHandleIndex;
            createFolderRequest.FolderType        = 0x01;
            createFolderRequest.UseUnicodeStrings = 0x0;
            createFolderRequest.OpenExisting      = 0x01;
            createFolderRequest.Reserved          = 0x0;
            createFolderRequest.DisplayName       = Encoding.ASCII.GetBytes(this.RootFolder);
            createFolderRequest.Comment           = Encoding.ASCII.GetBytes(this.RootFolder);
            createFolderResponse = this.Adapter.CreateFolder(createFolderRequest, this.inboxFolderHandle, ref this.responseHandles);
            Site.Assert.AreEqual <uint>(0, createFolderResponse.ReturnValue, "Creating Folder should succeed.");
            this.rootFolderHandle    = this.responseHandles[0][createFolderResponse.OutputHandleIndex];
            this.rootFolderId        = createFolderResponse.FolderId;
            this.isRootFolderCreated = true;
            #endregion
        }
Exemplo n.º 7
0
        public void MSOXCROPS_S07_TC01_TestRopsOpenReadWriteCommitStream()
        {
            this.CheckTransportIsSupported();

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

            // Step 1: Preparations-Create message and then open a stream.
            #region Common operations for RopReadStream,RopWriteStream,RopCommitStream and RopWriteAndCommitStream

            // Common variable for RopWriteStream and RopWriteAndCommitStream.
            byte[] data = Encoding.ASCII.GetBytes(SampleStreamData + "\0");

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

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 1:Call GetCreatedMessageHandle method to create a message.");

            // Create a message.
            uint messageHandle = GetCreatedMessageHandle(logonResponse.FolderIds[4], inputObjHandle);

            // Test RopOpenStream success response.
            #region Test RopOpenStream success response

            RopOpenStreamRequest  openStreamRequest;
            RopOpenStreamResponse openStreamResponse;

            // Client defines a new property.
            PropertyTag tag;
            tag.PropertyId   = TestSuiteBase.UserDefinedPropertyId;
            tag.PropertyType = (ushort)PropertyType.PtypString;

            openStreamRequest.RopId = (byte)RopId.RopOpenStream;

            openStreamRequest.LogonId           = TestSuiteBase.LogonId;
            openStreamRequest.InputHandleIndex  = TestSuiteBase.InputHandleIndex0;
            openStreamRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;
            openStreamRequest.PropertyTag       = tag;
            openStreamRequest.OpenModeFlags     = (byte)StreamOpenModeFlags.Create;

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

            // Send the RopOpenStream request and verify success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                openStreamRequest,
                messageHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            openStreamResponse = (RopOpenStreamResponse)response;
            Site.Assert.AreEqual <uint>(
                TestSuiteBase.SuccessReturnValue,
                openStreamResponse.ReturnValue,
                "if ROP succeeds, the ReturnValue of its response is 0(success)");
            uint streamObjectHandle = responseSOHs[0][openStreamResponse.OutputHandleIndex];

            #endregion

            // Test RopOpenStream failure response.
            #region Test RopOpenStream failure response

            openStreamRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex1;

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

            // Send the RopOpenStream request and verify failure response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                openStreamRequest,
                messageHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.FailureResponse);
            openStreamResponse = (RopOpenStreamResponse)response;
            Site.Assert.AreNotEqual <uint>(
                TestSuiteBase.SuccessReturnValue,
                openStreamResponse.ReturnValue,
                "if ROP failure, the ReturnValue of its response is not 0(success)");

            #endregion

            #endregion

            // Step 2: Verify RopReadStream Response when ByteCount is not equal to 0xBABE.
            #region Verify RopReadStream Response when ByteCount is not equal to 0xBABE.

            RopReadStreamRequest  readStreamRequest;
            RopReadStreamResponse readStreamResponse;

            readStreamRequest.RopId            = (byte)RopId.RopReadStream;
            readStreamRequest.LogonId          = TestSuiteBase.LogonId;
            readStreamRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

            // Set ByteCount to a value other than 0xBABE, then verify the response.
            readStreamRequest.ByteCount = TestSuiteBase.ByteCountForRopReadStream;

            readStreamRequest.MaximumByteCount = TestSuiteBase.MaximumByteCount;

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

            // Send the RopReadStream request and verify RopReadStream Response when ByteCount is not equal to 0xBABE.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                readStreamRequest,
                streamObjectHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            readStreamResponse = (RopReadStreamResponse)response;

            if (readStreamRequest.ByteCount != TestSuiteBase.ByteCount)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R3227,the ByteCount:{0},the DataSize:{1}", readStreamRequest.ByteCount, readStreamResponse.DataSize);

                // Verify MS-OXCROPS requirement: MS-OXCROPS_R3227
                // The maximum size is specified in the request buffer ByteCount field, must greater or equal than response DataSize field.
                bool isVerifyR3227 = readStreamRequest.ByteCount >= readStreamResponse.DataSize;
                Site.CaptureRequirementIfIsTrue(
                    isVerifyR3227,
                    3227,
                    @"[In RopReadStream ROP Response Buffer,DataSize (2 bytes),The maximum size is specified in the request buffer by one of the following:]The ByteCount field, when the value of the ByteCount value is not equal to 0xBABE.");
            }

            #endregion

            // Step 3: Verify RopReadStream Response when ByteCount is equal to 0xBABE.
            #region Verify RopReadStream Response when ByteCount is equal to 0xBABE.

            // Set ByteCount to 0xBABE, then verify the response.
            readStreamRequest.ByteCount = TestSuiteBase.ByteCount;
            this.responseSOHs           = cropsAdapter.ProcessSingleRop(
                readStreamRequest,
                streamObjectHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            readStreamResponse = (RopReadStreamResponse)response;

            if (readStreamRequest.ByteCount == TestSuiteBase.ByteCount)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R3228,the MaximumByteCount:{0},the DataSize:{1}", readStreamRequest.MaximumByteCount, readStreamResponse.DataSize);

                // Verify MS-OXCROPS requirement: MS-OXCROPS_R3228
                // The maximum size is specified in the request buffer MaximumByteCount field, must greater or equal than response DataSize field.
                bool isVerifyR3228 = readStreamRequest.MaximumByteCount >= readStreamResponse.DataSize;
                Site.CaptureRequirementIfIsTrue(
                    isVerifyR3228,
                    3228,
                    @"[In RopReadStream ROP Response Buffer,DataSize (2 bytes),The maximum size is specified in the request buffer by one of the following:]The MaximumByteCount field, when the value of the ByteCount field is equal to 0xBABE.");
            }
            #endregion

            // Step 4: Verify RopReadStream Response when MaximumByteCount is larger than 0x80000000.
            #region Verify RopReadStream Response when MaximumByteCount is larger than 0x80000000

            // Set MaximumByteCount to be larger than 0x80000000.
            readStreamRequest.MaximumByteCount = TestSuiteBase.ExceedMaxCount;

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                readStreamRequest,
                streamObjectHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.RPCError);

            #endregion

            // Step 5: Send the RopWriteStream request and verify the success response.
            #region RopWriteStream Response

            RopWriteStreamRequest  writeStreamRequest;
            RopWriteStreamResponse writeStreamResponse;

            writeStreamRequest.RopId            = (byte)RopId.RopWriteStream;
            writeStreamRequest.LogonId          = TestSuiteBase.LogonId;
            writeStreamRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            writeStreamRequest.DataSize         = (ushort)data.Length;
            writeStreamRequest.Data             = data;

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

            // Send the RopWriteStream request and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                writeStreamRequest,
                streamObjectHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            writeStreamResponse = (RopWriteStreamResponse)response;
            Site.Assert.AreEqual <uint>(
                TestSuiteBase.SuccessReturnValue,
                writeStreamResponse.ReturnValue,
                "if ROP succeeds, the ReturnValue of its response is 0(success)");

            #endregion

            // Step 6: Send the RopCommitStream request and verify the success response.
            #region RopCommitStream Response

            RopCommitStreamRequest  commitStreamRequest;
            RopCommitStreamResponse commitStreamResponse;

            commitStreamRequest.RopId            = (byte)RopId.RopCommitStream;
            commitStreamRequest.LogonId          = TestSuiteBase.LogonId;
            commitStreamRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

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

            // Send the RopCommitStream request and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                commitStreamRequest,
                streamObjectHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            commitStreamResponse = (RopCommitStreamResponse)response;
            Site.Assert.AreEqual <uint>(
                TestSuiteBase.SuccessReturnValue,
                commitStreamResponse.ReturnValue,
                "if ROP succeeds, the ReturnValue of its response is 0(success)");

            #endregion

            // Step 7: Send the RopWriteAndCommitStream request and verify the success response.
            #region RopWriteAndCommitStream response

            RopWriteAndCommitStreamRequest writeAndCommitStreamRequest;

            writeAndCommitStreamRequest.RopId            = (byte)RopId.RopWriteAndCommitStream;
            writeAndCommitStreamRequest.LogonId          = TestSuiteBase.LogonId;
            writeAndCommitStreamRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            writeAndCommitStreamRequest.DataSize         = (ushort)data.Length;
            writeAndCommitStreamRequest.Data             = data;

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

            // Send the RopWriteAndCommitStream request and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                writeAndCommitStreamRequest,
                streamObjectHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);

            // Refer to MS-OXCPRPT: Exchange 2003 and Exchange 2007 implement the RopWriteAndCommitStream ROP.
            if (Common.IsRequirementEnabled(752001, this.Site))
            {
                // Because the response of RopWriteAndCommitStream is the same to RopWriteStream.
                RopWriteStreamResponse writeAndCommitStreamResponse;
                writeAndCommitStreamResponse = (RopWriteStreamResponse)response;

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

                // Verify MS-OXCROPS requirement: MS-OXCROPS_R752001
                Site.CaptureRequirementIfAreEqual <uint>(
                    TestSuiteBase.SuccessReturnValue,
                    writeAndCommitStreamResponse.ReturnValue,
                    752001,
                    @"[In Appendix A: Product Behavior] Implementation does implement the RopWriteAndCommitStream ROP. (Exchange 2007 follows this behavior.)");

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

            #endregion
        }
        public void MSOXCROPS_S12_TC02_TestFailRPCForMaxPcbOut()
        {
            this.CheckTransportIsSupported();

            if (Common.IsRequirementEnabled(454509, this.Site))
            {
                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));

                // Define data for properties
                string dataForProperties = string.Empty;
                dataForProperties += TestSuiteBase.DataForProperties;
                dataForProperties += TestSuiteBase.DataForProperties;
                dataForProperties += TestSuiteBase.DataForProperties;
                dataForProperties += TestSuiteBase.DataForProperties;
                dataForProperties += TestSuiteBase.DataForProperties;
                dataForProperties += TestSuiteBase.DataForProperties;
                dataForProperties += TestSuiteBase.DataForProperties;
                dataForProperties += TestSuiteBase.DataForProperties;

                int loopCounter = (LoopCounter / Encoding.ASCII.GetBytes(dataForProperties).Length) + 1;

                #region Common operations for RopGetStreamSize,RopSetStreamSize and RopSeekStream

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

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Call GetCreatedMessageHandle method to create a message and get its handle.");

                // Call GetCreatedMessageHandle method to create a message and get its handle.
                uint messageHandle = GetCreatedMessageHandle(logonResponse.FolderIds[4], inputObjHandle);

                // Call GetOpenedStreamHandle method to open stream and get its handle.
                uint streamObjectHandle;

                for (int i = 0; i < loopCounter; i++)
                {
                    // Add the debug information
                    Site.Log.Add(LogEntryKind.Debug, "Call GetOpenedStreamHandle method to open stream and get its handle:loop counter i={0}", i);

                    streamObjectHandle = this.GetOpenedStreamHandle(
                        messageHandle,
                        (ushort)(this.propertyDictionary[PropertyNames.UserSpecified].PropertyId + i));

                    // Add the debug information
                    Site.Log.Add(LogEntryKind.Debug, "Call WriteStream method to write stream:loop counter i={0}", i);

                    // Call WriteStream method to write stream.
                    this.WriteStream(streamObjectHandle, dataForProperties);

                    // Add the debug information
                    Site.Log.Add(LogEntryKind.Debug, "Call CommitStream method to commit source stream:loop counter i={0}", i);

                    // Call CommitStream method to commit source stream.
                    this.CommitStream(streamObjectHandle);

                    #region Release the stream.
                    RopReleaseRequest releaseRequest;

                    releaseRequest.RopId   = (byte)RopId.RopRelease;
                    releaseRequest.LogonId = TestSuiteBase.LogonId;

                    // Set InputHandleIndex to 0x0, which specifies the location in the Server object handle table
                    // where the handle for the input Server object is stored.
                    releaseRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

                    // Add the debug information
                    Site.Log.Add(LogEntryKind.Debug, "Begin to send the RopRelease request.");

                    // Send a RopRelease request to release all resources associated with the Server object.
                    this.responseSOHs = cropsAdapter.ProcessSingleRop(
                        releaseRequest,
                        streamObjectHandle,
                        ref this.response,
                        ref this.rawData,
                        RopResponseType.SuccessResponse);
                    #endregion
                }

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Call SaveMessage method to save message.");

                // Call SaveMessage method to save message.
                this.SaveMessage(messageHandle);

                #endregion

                #region Check 0x40000 as the maximum value of pcbout.

                // Here will check counter with 0x40000 to ensure the response payload be bigger than 0x40000.
                if (this.counter <= MS_OXCROPSAdapter.MaxPcbOut)
                {
                    return;
                }

                RopGetPropertiesAllRequest getPropertiesAllRequest = new RopGetPropertiesAllRequest
                {
                    RopId             = (byte)RopId.RopGetPropertiesAll,
                    LogonId           = TestSuiteBase.LogonId,
                    InputHandleIndex  = TestSuiteBase.InputHandleIndex0,
                    PropertySizeLimit = TestSuiteBase.PropertySizeLimit,
                    WantUnicode       = (ushort)Zero
                };

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Begin to send the RopGetPropertiesAll request.");

                // Send the RopGetPropertiesAll request and verify RPC error response.
                this.responseSOHs = cropsAdapter.ProcessSingleRopWithOptionResponseBufferSize(
                    getPropertiesAllRequest,
                    messageHandle,
                    ref this.response,
                    ref this.rawData,
                    RopResponseType.RPCError,
                    MS_OXCROPSAdapter.MaxPcbOut);

                #endregion
            }
            else
            {
                Site.Assert.Inconclusive("This case runs only under Exchange 2010, since Exchange 2007 and Exchange 2013 do not support fail the RPC with 0x0000047D, if one of the ROP responses will not fit in the ROP output buffer when the pcbOut parameter of EcDoRpcExt2 is set to the maximum value.");
            }
        }
        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
        }
        public void MSOXCROPS_S10_TC04_TestRopFastTransferSourceCopyFolder()
        {
            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 RopOpenFolder request to open folder
            #region RopFastTransferDestinationPutBuffer success response

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

            // Open a folder first, then create a subfolder under the opened folder
            RopOpenFolderRequest  openFolderRequest;
            RopOpenFolderResponse openFolderResponse;

            openFolderRequest.RopId             = (byte)RopId.RopOpenFolder;
            openFolderRequest.LogonId           = TestSuiteBase.LogonId;
            openFolderRequest.InputHandleIndex  = TestSuiteBase.InputHandleIndex0;
            openFolderRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;

            // Open root folder
            openFolderRequest.FolderId = logonResponse.FolderIds[4];

            openFolderRequest.OpenModeFlags = (byte)FolderOpenModeFlags.None;

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                openFolderRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            openFolderResponse = (RopOpenFolderResponse)response;
            Site.Assert.AreEqual <uint>(
                TestSuiteBase.SuccessReturnValue,
                openFolderResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0 (success)");

            // This handle will be used as input handle in RopCreateFolder
            uint openedFolderHandle = responseSOHs[0][openFolderResponse.OutputHandleIndex];

            #endregion

            // Step 2: Send the RopCreateFolder request to create subfolder under opened folder
            #region RopCreateFolder success response

            RopCreateFolderRequest  createFolderRequest;
            RopCreateFolderResponse createFolderResponse;

            createFolderRequest.RopId             = (byte)RopId.RopCreateFolder;
            createFolderRequest.LogonId           = TestSuiteBase.LogonId;
            createFolderRequest.InputHandleIndex  = TestSuiteBase.InputHandleIndex0;
            createFolderRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;
            createFolderRequest.FolderType        = (byte)FolderType.Genericfolder;

            // Set UseUnicodeStrings to 0x0, which specifies the DisplayName and Comment are not specified in Unicode.
            createFolderRequest.UseUnicodeStrings = Convert.ToByte(TestSuiteBase.Zero);

            // Set OpenExisting to 0xFF, which means the folder being created will be opened when it is already existed.
            createFolderRequest.OpenExisting = TestSuiteBase.NonZero;

            createFolderRequest.Reserved    = TestSuiteBase.Reserved;
            createFolderRequest.DisplayName = Encoding.ASCII.GetBytes(TestSuiteBase.DisplayNameAndCommentForNonSearchFolder + "\0");
            createFolderRequest.Comment     = Encoding.ASCII.GetBytes(TestSuiteBase.DisplayNameAndCommentForNonSearchFolder + "\0");

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                createFolderRequest,
                openedFolderHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            createFolderResponse = (RopCreateFolderResponse)response;
            Site.Assert.AreEqual <uint>(
                TestSuiteBase.SuccessReturnValue,
                createFolderResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0 (success)");
            uint targetFolderHandle = responseSOHs[0][createFolderResponse.OutputHandleIndex];

            #endregion

            // Step 3: Send the RopFastTransferSourceCopyFolder request to create subfolder under opened folder
            #region RopFastTransferSourceCopyFolder success response

            RopFastTransferSourceCopyFolderRequest  fastTransferSourceCopyFolderRequest;
            RopFastTransferSourceCopyFolderResponse fastTransferSourceCopyFolderResponse;

            fastTransferSourceCopyFolderRequest.RopId             = (byte)RopId.RopFastTransferSourceCopyFolder;
            fastTransferSourceCopyFolderRequest.LogonId           = TestSuiteBase.LogonId;
            fastTransferSourceCopyFolderRequest.InputHandleIndex  = TestSuiteBase.InputHandleIndex0;
            fastTransferSourceCopyFolderRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;
            fastTransferSourceCopyFolderRequest.CopyFlags         = (byte)RopFastTransferSourceCopyFolderCopyFlags.CopySubfolders;
            fastTransferSourceCopyFolderRequest.SendOptions       = (byte)SendOptions.ForceUnicode;

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                fastTransferSourceCopyFolderRequest,
                targetFolderHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            fastTransferSourceCopyFolderResponse = (RopFastTransferSourceCopyFolderResponse)response;

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

            #endregion
        }
        public void MSOXCROPS_S10_TC07_TestRopFastTransferSourceCopyProperties()
        {
            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 RopCreateMessage request to create a message
            #region RopCreateMessage success response

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

            // Create a message
            RopCreateMessageRequest  createMessageRequest = new RopCreateMessageRequest();
            RopCreateMessageResponse createMessageResponse;

            createMessageRequest.RopId = (byte)RopId.RopCreateMessage;

            createMessageRequest.LogonId           = TestSuiteBase.LogonId;
            createMessageRequest.InputHandleIndex  = TestSuiteBase.InputHandleIndex0;
            createMessageRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;

            // Set CodePageId to 0x0FFF, which specified the code page of Logon object will be used.
            createMessageRequest.CodePageId = TestSuiteBase.CodePageId;

            // Create a message in INBOX
            createMessageRequest.FolderId = logonResponse.FolderIds[4];

            // Set AssociatedFlag to 0x00(FALSE), which specifies the message is not a folder associated information (FAI) message.
            createMessageRequest.AssociatedFlag = Convert.ToByte(TestSuiteBase.Zero);

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                createMessageRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            createMessageResponse = (RopCreateMessageResponse)response;
            Site.Assert.AreEqual <uint>(
                TestSuiteBase.SuccessReturnValue,
                createMessageResponse.ReturnValue,
                "if ROP succeeds, the ReturnValue of its response is 0(success)");
            uint targetMessageHandle = responseSOHs[0][createMessageResponse.OutputHandleIndex];

            #endregion

            // Step 2: Send the RopSaveChangesMessage request to save changes
            #region RopSaveChangesMessage success response

            // Save message
            RopSaveChangesMessageRequest  saveChangesMessageRequest;
            RopSaveChangesMessageResponse saveChangesMessageResponse;

            saveChangesMessageRequest.RopId               = (byte)RopId.RopSaveChangesMessage;
            saveChangesMessageRequest.LogonId             = TestSuiteBase.LogonId;
            saveChangesMessageRequest.InputHandleIndex    = TestSuiteBase.InputHandleIndex0;
            saveChangesMessageRequest.ResponseHandleIndex = TestSuiteBase.ResponseHandleIndex1;
            saveChangesMessageRequest.SaveFlags           = (byte)SaveFlags.ForceSave;

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                saveChangesMessageRequest,
                targetMessageHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            saveChangesMessageResponse = (RopSaveChangesMessageResponse)response;
            Site.Assert.AreEqual <uint>(
                TestSuiteBase.SuccessReturnValue,
                saveChangesMessageResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0 (success).");

            #endregion

            // Step 3: Send the RopFastTransferSourceCopyTo request to verify success response
            #region RopFastTransferSourceCopyTo response

            RopFastTransferSourceCopyPropertiesRequest fastTransferSourceCopyPropertiesRequest;

            PropertyTag[] messagePropertyTags = this.CreateMessageSamplePropertyTags();
            fastTransferSourceCopyPropertiesRequest.RopId             = (byte)RopId.RopFastTransferSourceCopyProperties;
            fastTransferSourceCopyPropertiesRequest.LogonId           = TestSuiteBase.LogonId;
            fastTransferSourceCopyPropertiesRequest.InputHandleIndex  = TestSuiteBase.InputHandleIndex0;
            fastTransferSourceCopyPropertiesRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;

            // This value specifies the level at which the copy is occurring, which is specified in [MS-OXCROPS].
            fastTransferSourceCopyPropertiesRequest.Level = TestSuiteBase.LevelOfNonZero;

            // Move: the client identifies the FastTransfer operation being configured as a logical part of a larger object move operation.
            fastTransferSourceCopyPropertiesRequest.CopyFlags = (byte)RopFastTransferSourceCopyPropertiesCopyFlags.Move;

            fastTransferSourceCopyPropertiesRequest.SendOptions      = (byte)SendOptions.Unicode;
            fastTransferSourceCopyPropertiesRequest.PropertyTagCount = (ushort)messagePropertyTags.Length;
            fastTransferSourceCopyPropertiesRequest.PropertyTags     = messagePropertyTags;

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                fastTransferSourceCopyPropertiesRequest,
                targetMessageHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);

            #endregion
        }
        public void MSOXCMSG_S09_TC01_RopOpenEmbeddedMessageSuccessfully()
        {
            this.CheckMapiHttpIsSupported();
            this.ConnectToServer(ConnectionType.PrivateMailboxServer);

            // Set property size
            int size = 0;

            TaggedPropertyValue[] taggedPropertyValueArray = this.CreateMessageTaggedPropertyValueArrays(out size, PidTagAttachMethodFlags.afEmbeddedMessage);

            #region Call RopLogon to log on a mailbox.
            RopLogonResponse logonResponse = this.Logon(LogonType.Mailbox, out this.insideObjHandle);
            #endregion

            #region Call RopCreateMessage to create a message.
            uint targetMessageHandle = this.CreatedMessage(logonResponse.FolderIds[4], this.insideObjHandle);
            #endregion

            #region Call RopCreateAttachment to create an embedded attachment.
            RopCreateAttachmentResponse createAttachmentResponse;
            uint attachmentId;
            uint attachmentHandle = this.CreateAttachment(targetMessageHandle, out createAttachmentResponse, out attachmentId);
            #endregion

            #region Call RopSetProperties to set PidTagAttachMethod property, that is the attachment is the embedded attachment.
            RopSetPropertiesRequest setPropertiesRequest = new RopSetPropertiesRequest()
            {
                RopId              = (byte)RopId.RopSetProperties,
                LogonId            = CommonLogonId,          // The logonId 0x00 is associated with RopSetProperties.
                InputHandleIndex   = CommonInputHandleIndex, // This index specifies the location 0x00 in the Server Object Handle Table where the handle for the input Server Object is stored.
                PropertyValueSize  = (ushort)(size + 2),
                PropertyValueCount = (ushort)taggedPropertyValueArray.Length,
                PropertyValues     = taggedPropertyValueArray
            };
            this.ResponseSOHs = this.MSOXCMSGAdapter.DoRopCall(setPropertiesRequest, attachmentHandle, ref this.response, ref this.rawData, GetPropertiesFlags.None);
            RopSetPropertiesResponse setPropertiesResponse = (RopSetPropertiesResponse)this.response;
            Site.Assert.AreEqual <uint>(TestSuiteBase.Success, setPropertiesResponse.ReturnValue, TestSuiteBase.ROPSucceedMsg);
            #endregion

            #region Call RopGetPropertiesSpecific to get property PidTagAttachMethod of created Attachment
            List <PropertyTag> tagArray = new List <PropertyTag>
            {
                PropertyHelper.PropertyTagDic[PropertyNames.PidTagAttachMethod]
            };

            RopGetPropertiesSpecificResponse getPropertiesSpecificResponse;
            getPropertiesSpecificResponse = this.GetSpecificPropertiesOfMessage(attachmentHandle, tagArray);
            List <PropertyObj> pts = PropertyHelper.GetPropertyObjFromBuffer(tagArray.ToArray(), getPropertiesSpecificResponse);

            // Parse property response get Property Value to verify test  case requirement
            PropertyObj pidTagAttachMethod = PropertyHelper.GetPropertyByName(pts, PropertyNames.PidTagAttachMethod);
            #endregion

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

            // Verify MS-OXCMSG requirement: MS-OXCMSG_R596
            this.Site.CaptureRequirementIfAreEqual <int>(
                0x00000005,
                Convert.ToInt32(pidTagAttachMethod.Value),
                596,
                @"[In PidTagAttachMethod Property] [afEmbeddedMessage (0x00000005)] The attachment is an embedded message that is accessed via the RopOpenEmbeddedMessage ROP ([MS-OXCROPS] section 2.2.6.16).");

            #region Call RopSaveChangesAttachment to save the attachment changes.
            RopSaveChangesAttachmentResponse saveChangesAttachmentResponse;
            this.SaveAttachment(attachmentHandle, out saveChangesAttachmentResponse);
            #endregion

            #region Call RopSaveChangesMessage to save the newly created message.
            RopSaveChangesMessageResponse saveChangesMessageResponse;
            saveChangesMessageResponse = this.SaveMessage(targetMessageHandle, (byte)SaveFlags.ForceSave);
            #endregion

            #region Call RopOpenEmbeddedMessage with OpenModeFlags set to 0x02 to create the attachment if it doesn't exist, and expect to get a successful response
            RopOpenEmbeddedMessageRequest openEmbeddedMessageRequest = new RopOpenEmbeddedMessageRequest()
            {
                RopId             = (byte)RopId.RopOpenEmbeddedMessage,
                LogonId           = CommonLogonId,           // The logonId 0x00 is associated with RopOpenEmbeddedMessage.
                InputHandleIndex  = CommonInputHandleIndex,  // This index specifies the location 0x00 in the Server Object Handle Table where the handle for the input Server Object is stored.
                OutputHandleIndex = CommonOutputHandleIndex, // This index specifies the location 0x01 in the Server Object Handle Table where the handle for the output Server Object is stored.
                CodePageId        = 0x0FFF,                  // Code page of Logon object is used
                OpenModeFlags     = 0x02                     // Create the attachment if it does not already exist and open the message for both reading and writing
            };
            this.ResponseSOHs = this.MSOXCMSGAdapter.DoRopCall(openEmbeddedMessageRequest, attachmentHandle, ref this.response, ref this.rawData, GetPropertiesFlags.None);
            RopOpenEmbeddedMessageResponse openEmbeddedMessageResponse = (RopOpenEmbeddedMessageResponse)this.response;
            Site.Assert.AreEqual <uint>(TestSuiteBase.Success, openEmbeddedMessageResponse.ReturnValue, TestSuiteBase.ROPSucceedMsg);
            uint embeddedMessageHandle = this.ResponseSOHs[0][openEmbeddedMessageResponse.OutputHandleIndex];
            #endregion

            #region Call RopSaveChangesMessage to save the newly created message.
            saveChangesMessageResponse = this.SaveMessage(embeddedMessageHandle, (byte)SaveFlags.ForceSave);
            #endregion

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

            // Verify MS-OXCMSG requirement: MS-OXCMSG_R913
            // The embedded message hasn't been created, so MS-OXCMSG_R913 can be verified if the response of calling RopOpenEmbeddedMessage with OpenModeFlags set to 0x02 is successful.
            this.Site.CaptureRequirementIfAreEqual <uint>(
                TestSuiteBase.Success,
                openEmbeddedMessageResponse.ReturnValue,
                913,
                @"[In RopOpenEmbeddedMessage ROP Request Buffer] [OpenModeFlags] [Create (0x02)] Create the attachment if it does not already exist and open the message for both reading and writing.");

            #region Call RopRelease to release the embedded message
            this.ReleaseRop(embeddedMessageHandle);
            #endregion

            #region Call RopOpenEmbeddedMessage with OpenModeFlags set to 0x00 to open the embedded message as read-only.
            openEmbeddedMessageRequest.CodePageId    = 0x0FFF; // Code page of Logon object is used
            openEmbeddedMessageRequest.OpenModeFlags = 0x00;   // Open the message as read-only.
            this.ResponseSOHs           = this.MSOXCMSGAdapter.DoRopCall(openEmbeddedMessageRequest, attachmentHandle, ref this.response, ref this.rawData, GetPropertiesFlags.None);
            openEmbeddedMessageResponse = (RopOpenEmbeddedMessageResponse)this.response;
            Site.Assert.AreEqual <uint>(TestSuiteBase.Success, openEmbeddedMessageResponse.ReturnValue, TestSuiteBase.ROPSucceedMsg);
            embeddedMessageHandle = this.ResponseSOHs[0][openEmbeddedMessageResponse.OutputHandleIndex];
            #endregion

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

            // Verify MS-OXCMSG requirement: MS-OXCMSG_R881
            // MS-OXCMSG_R881 can be verified when the handle returned from calling RopOpenEmbeddedMessage is not null.
            this.Site.CaptureRequirementIfIsNotNull(
                embeddedMessageHandle,
                881,
                @"[In RopOpenEmbeddedMessage ROP] The RopOpenEmbeddedMessage ROP ([MS-OXCROPS] section 2.2.6.16) retrieves a handle to a Message object from the given Attachment object.");

            #region Call RopModifyRecipients to add recipient to the read-only embedded message and expect to get the failure response
            // Initialize TestUser1
            PropertyTag[]             propertyTag        = this.CreateRecipientColumns();
            List <ModifyRecipientRow> modifyRecipientRow = new List <ModifyRecipientRow>
            {
                this.CreateModifyRecipientRow(TestUser1, 0)
            };

            RopModifyRecipientsResponse modifyRecipientsResponse;
            this.AddRecipients(modifyRecipientRow, embeddedMessageHandle, propertyTag, out modifyRecipientsResponse);
            #endregion

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

                // Verify MS-OXCMSG requirement: MS-OXCMSG_R3014
                // The response of RopModifyRecipients is not successful because the embedded message is opened as read-only, so MS-OXCMSG_R3014 can be verified.
                this.Site.CaptureRequirementIfAreNotEqual <uint>(
                    TestSuiteBase.Success,
                    modifyRecipientsResponse.ReturnValue,
                    3014,
                    @"[In Appendix A: Product Behavior] [OpenModeFlags] [ReadOnly (0x00)] Message will be opened as read only. (Exchange 2007 follows this behavior.)");
            }

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

                // Verify MS-OXCMSG requirement: MS-OXCMSG_R3013
                // The response of RopModifyRecipients is successful because the embedded message is opened as read/write, so MS-OXCMSG_R3013 can be verified.
                this.Site.CaptureRequirementIfAreEqual <uint>(
                    TestSuiteBase.Success,
                    modifyRecipientsResponse.ReturnValue,
                    3013,
                    @"[In Appendix A: Product Behavior]  [OpenModeFlags] [ReadOnly (0x00)] Message will be opened as read/write. (&lt;17&gt; Section 2.2.3.16.1:  Exchange 2010, Exchange 2013, Exchange 2016 and Exchange 2019 Preview  follow this behavior.)");
            }

            #region Call RopRelease to release the embedded message.
            this.ReleaseRop(embeddedMessageHandle);
            #endregion

            #region Call RopOpenEmbeddedMessage with OpenModeFlags set to 0x01 to open the embedded message as read/write
            openEmbeddedMessageRequest.InputHandleIndex = 0x00;
            openEmbeddedMessageRequest.OpenModeFlags    = 0x01; // Open the message for both reading and writing.
            this.ResponseSOHs           = this.MSOXCMSGAdapter.DoRopCall(openEmbeddedMessageRequest, attachmentHandle, ref this.response, ref this.rawData, GetPropertiesFlags.None);
            openEmbeddedMessageResponse = (RopOpenEmbeddedMessageResponse)this.response;
            embeddedMessageHandle       = this.ResponseSOHs[0][openEmbeddedMessageResponse.OutputHandleIndex];
            #endregion

            #region Call RopModifyRecipients to add recipient to the read/write embedded message and expect to get the successful response.
            this.AddRecipients(modifyRecipientRow, embeddedMessageHandle, propertyTag, out modifyRecipientsResponse);
            Site.Assert.AreEqual <uint>(TestSuiteBase.Success, modifyRecipientsResponse.ReturnValue, TestSuiteBase.ROPSucceedMsg);
            #endregion

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

            // Verify MS-OXCMSG requirement: MS-OXCMSG_R912
            // The response of RopModifyRecipients is success because the embedded message is opened as read/write, so MS-OXCMSG_R912 can be verified.
            this.Site.CaptureRequirementIfAreEqual <uint>(
                TestSuiteBase.Success,
                modifyRecipientsResponse.ReturnValue,
                912,
                @"[In RopOpenEmbeddedMessage ROP Request Buffer] [OpenModeFlags] [ReadWrite (0x01)] Message will be opened for both reading and writing.");

            #region Call RopRelease to release the created message and the created attachment.
            this.ReleaseRop(embeddedMessageHandle);
            this.ReleaseRop(targetMessageHandle);
            #endregion
        }
        public void MSOXCMSG_S09_TC02_RopOpenEmbeddedMessageFailed()
        {
            this.CheckMapiHttpIsSupported();
            this.ConnectToServer(ConnectionType.PrivateMailboxServer);

            // Set property size
            int size = 0;

            TaggedPropertyValue[] taggedPropertyValueArray = this.CreateMessageTaggedPropertyValueArrays(out size, PidTagAttachMethodFlags.afEmbeddedMessage);

            #region Call RopLogon to log on a mailbox.
            RopLogonResponse logonResponse = this.Logon(LogonType.Mailbox, out this.insideObjHandle);
            #endregion

            #region Call RopCreateMessage to create a message.
            uint targetMessageHandle = this.CreatedMessage(logonResponse.FolderIds[4], this.insideObjHandle);
            #endregion

            #region Call RopSaveChangesMessage to save the newly created message.
            RopSaveChangesMessageResponse saveChangesMessageResponse;
            saveChangesMessageResponse = this.SaveMessage(targetMessageHandle, (byte)SaveFlags.ForceSave);
            #endregion

            #region Call RopOpenMessage to open the message.
            RopOpenMessageResponse openMessageResponse;
            uint openedMessageHandle = this.OpenSpecificMessage(logonResponse.FolderIds[4], saveChangesMessageResponse.MessageId, this.insideObjHandle, MessageOpenModeFlags.ReadWrite, out openMessageResponse);
            Site.Assert.AreEqual <uint>(TestSuiteBase.Success, openMessageResponse.ReturnValue, TestSuiteBase.ROPSucceedMsg);
            #endregion

            #region Call RopCreateAttachment to create an embedded attachment.
            RopCreateAttachmentResponse createAttachmentResponse;
            uint attachmentId;
            uint attachmentHandle = this.CreateAttachment(openedMessageHandle, out createAttachmentResponse, out attachmentId);
            #endregion

            #region Call RopSetProperties to set PidTagAttachMethod property, that is the attachment is the embedded attachment.
            RopSetPropertiesRequest setPropertiesRequest = new RopSetPropertiesRequest()
            {
                RopId              = (byte)RopId.RopSetProperties,
                LogonId            = CommonLogonId,          // The logonId 0x00 is associated with RopSetProperties.
                InputHandleIndex   = CommonInputHandleIndex, // This index specifies the location 0x00 in the Server Object Handle Table where the handle for the input Server Object is stored.
                PropertyValueSize  = (ushort)(size + 2),
                PropertyValueCount = (ushort)taggedPropertyValueArray.Length,
                PropertyValues     = taggedPropertyValueArray
            };
            this.ResponseSOHs = this.MSOXCMSGAdapter.DoRopCall(setPropertiesRequest, attachmentHandle, ref this.response, ref this.rawData, GetPropertiesFlags.None);
            RopSetPropertiesResponse setPropertiesResponse = (RopSetPropertiesResponse)this.response;
            Site.Assert.AreEqual <uint>(TestSuiteBase.Success, setPropertiesResponse.ReturnValue, TestSuiteBase.ROPSucceedMsg);
            #endregion

            #region Call RopSaveChangesAttachment to save the attachment changes.
            RopSaveChangesAttachmentResponse saveChangesAttachmentResponse;
            this.SaveAttachment(attachmentHandle, out saveChangesAttachmentResponse);
            #endregion

            #region Call RopOpenEmbeddedMessage with OpenModeFlags set to 0x02 to create the attachment if it doesn't exist, and expect to get a successful response
            RopOpenEmbeddedMessageRequest openEmbeddedMessageRequest = new RopOpenEmbeddedMessageRequest()
            {
                RopId             = (byte)RopId.RopOpenEmbeddedMessage,
                LogonId           = CommonLogonId,           // The logonId 0x00 is associated with RopOpenEmbeddedMessage.
                InputHandleIndex  = CommonInputHandleIndex,  // This index specifies the location 0x00 in the Server Object Handle Table where the handle for the input Server Object is stored.
                OutputHandleIndex = CommonOutputHandleIndex, // This index specifies the location 0x01 in the Server Object Handle Table where the handle for the output Server Object is stored.
                CodePageId        = 0x0FFF,                  // Code page of Logon object is used
                OpenModeFlags     = 0x02                     // Create the attachment if it does not already exist and open the message for both reading and writing
            };
            this.ResponseSOHs = this.MSOXCMSGAdapter.DoRopCall(openEmbeddedMessageRequest, attachmentHandle, ref this.response, ref this.rawData, GetPropertiesFlags.None);
            RopOpenEmbeddedMessageResponse openEmbeddedMessageResponse = (RopOpenEmbeddedMessageResponse)this.response;
            Site.Assert.AreEqual <uint>(TestSuiteBase.Success, openEmbeddedMessageResponse.ReturnValue, TestSuiteBase.ROPSucceedMsg);
            uint embeddedMessageHandle = this.ResponseSOHs[0][openEmbeddedMessageResponse.OutputHandleIndex];
            #endregion

            #region Call RopRelease to release the embedded message
            this.ReleaseRop(embeddedMessageHandle);
            #endregion

            #region Call RopOpenEmbeddedMessage with CodePageId set to 0x000F and error code 0x000003ef is expected
            openEmbeddedMessageRequest.CodePageId = 0x000F;
            this.ResponseSOHs           = this.MSOXCMSGAdapter.DoRopCall(openEmbeddedMessageRequest, attachmentHandle, ref this.response, ref this.rawData, GetPropertiesFlags.None);
            openEmbeddedMessageResponse = (RopOpenEmbeddedMessageResponse)this.response;
            #endregion

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

            // Verify MS-OXCMSG requirement: MS-OXCMSG_R1068
            this.Site.CaptureRequirementIfAreEqual <uint>(
                0x000003ef,
                openEmbeddedMessageResponse.ReturnValue,
                1068,
                @"[In Receiving a RopOpenEmbeddedMessage ROP Request] [ecUnknownCodePage (0x000003ef)] The code page is unknown.");

            #region Call RopOpenEmbeddedMessage with InputHandleIndex set to 0x01 to open the embedded message and expect to get the error code 0x000004B9 (ecNullObject).
            openEmbeddedMessageRequest.CodePageId       = 0x0FFF; // Code page of Logon object is used
            openEmbeddedMessageRequest.InputHandleIndex = 0x01;
            this.ResponseSOHs           = this.MSOXCMSGAdapter.DoRopCall(openEmbeddedMessageRequest, attachmentHandle, ref this.response, ref this.rawData, GetPropertiesFlags.None);
            openEmbeddedMessageResponse = (RopOpenEmbeddedMessageResponse)this.response;
            #endregion

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

            // Verify MS-OXCMSG requirement: MS-OXCMSG_R1525
            this.Site.CaptureRequirementIfAreEqual <uint>(
                0x000004B9,
                openEmbeddedMessageResponse.ReturnValue,
                1525,
                @"[In Receiving a RopOpenEmbeddedMessage ROP Request] [ecNullObject (0x000004B9)] The value of the InputHandleIndex field on which this ROP [RopOpenEmbeddedMessage] was called does not refer to an Attachment object.");

            #region Call RopRelease to release the embedded message.
            this.ReleaseRop(embeddedMessageHandle);
            this.ReleaseRop(targetMessageHandle);
            #endregion
        }
Exemplo n.º 14
0
        /// <summary>
        /// Hard delete messages and subfolders under the specified folder.
        /// </summary>
        /// <param name="folderIndex">The id of folder in which subfolders and messages should be deleted</param>
        protected void HardDeleteMessagesAndSubfolders(FolderIds folderIndex)
        {
            #region Client connects with Server
            this.pcbOut      = ConstValues.ValidpcbOut;
            this.pcbAuxOut   = ConstValues.ValidpcbAuxOut;
            this.returnValue = this.oxcrpcAdapter.EcDoConnectEx(
                ref this.pcxh,
                TestSuiteBase.UlIcxrLinkForNoSessionLink,
                ref this.pulTimeStamp,
                null,
                this.userDN,
                ref this.pcbAuxOut,
                this.rgwClientVersion,
                out this.rgwBestVersion,
                out this.picxr);
            Site.Assert.AreEqual <uint>(0, this.returnValue, "EcDoConnectEx should succeed. This call is the precondition for EcDoRpcExt2. '0' is expected to be returned. The returned value is {0}.", this.returnValue);
            #endregion

            #region Logon to mailbox
            this.rgbIn     = AdapterHelper.ComposeRgbIn(ROPCommandType.RopLogon, this.unusedInfo, this.userPrivilege);
            this.pcbOut    = ConstValues.ValidpcbOut;
            this.pcbAuxOut = ConstValues.ValidpcbAuxOut;

            this.returnValue = this.oxcrpcAdapter.EcDoRpcExt2(
                ref this.pcxh,
                PulFlags.NoCompression | PulFlags.NoXorMagic,
                this.rgbIn,
                ref this.pcbOut,
                null,
                ref this.pcbAuxOut,
                out this.response,
                ref this.responseSOHTable);

            Site.Assert.AreEqual <uint>(0, this.returnValue, "RopLogon should succeed and '0' is expected to be returned. The returned value is {0}.", this.returnValue);
            RopLogonResponse logonResponse = (RopLogonResponse)this.response;
            uint             logonHandle   = this.responseSOHTable[TestSuiteBase.FIRST][logonResponse.OutputHandleIndex];
            #endregion

            #region OpenFolder
            this.rgbIn            = AdapterHelper.ComposeRgbIn(ROPCommandType.RopOpenFolder, logonHandle, logonResponse.FolderIds[(int)folderIndex]);
            this.pcbOut           = ConstValues.ValidpcbOut;
            this.pcbAuxOut        = ConstValues.ValidpcbAuxOut;
            this.responseSOHTable = new List <List <uint> >();
            uint payloadCount = 0;

            this.returnValue = this.oxcrpcAdapter.EcDoRpcExt2(
                ref this.pcxh,
                PulFlags.NoXorMagic,
                this.rgbIn,
                ref this.rgbOut,
                ref this.pcbOut,
                null,
                ref this.pcbAuxOut,
                out this.response,
                ref this.responseSOHTable,
                out payloadCount,
                ref this.rgbAuxOut);

            Site.Assert.AreEqual <uint>(0, this.returnValue, "RopOpenFolder should succeed and '0' is expected to be returned. The returned value is {0}.", this.returnValue);
            RopOpenFolderResponse openFolderResponse = (RopOpenFolderResponse)this.response;
            this.objHandle = this.responseSOHTable[TestSuiteBase.FIRST][openFolderResponse.OutputHandleIndex];
            #endregion

            #region HardDeleteFoldersAndMessages
            this.rgbIn            = AdapterHelper.ComposeRgbIn(ROPCommandType.RopHardDeleteMessagesAndSubfolders, this.objHandle, 0);
            this.pcbOut           = ConstValues.ValidpcbOut;
            this.pcbAuxOut        = ConstValues.ValidpcbAuxOut;
            this.responseSOHTable = new List <List <uint> >();
            payloadCount          = 0;

            this.returnValue = this.oxcrpcAdapter.EcDoRpcExt2(
                ref this.pcxh,
                PulFlags.NoXorMagic,
                this.rgbIn,
                ref this.rgbOut,
                ref this.pcbOut,
                null,
                ref this.pcbAuxOut,
                out this.response,
                ref this.responseSOHTable,
                out payloadCount,
                ref this.rgbAuxOut);

            // The returned value 1125 means ecNoDelSubmitMsg, that is, deleting a message that has been submitted for sending is not permitted.
            bool retValue = (this.returnValue == 0) || (this.returnValue == 1125);
            Site.Assert.AreEqual <bool>(true, retValue, "The returned status is {0}. TRUE means that RopHardDeleteMessagesAndSubfolders succeed, and FALSE means that RopHardDeleteMessagesAndSubfolders failed.", retValue);
            #endregion

            #region Client disconnects with Server
            this.returnValue = this.oxcrpcAdapter.EcDoDisconnect(ref this.pcxh);
            Site.Assert.AreEqual <uint>(0, this.returnValue, "EcDoDisconnect should succeed and '0' is expected to be returned. The returned value is {0}.", this.returnValue);
            #endregion
        }
Exemplo n.º 15
0
        public void MSOXCMSG_S02_TC01_SetAndGetMessageStatus()
        {
            this.CheckMapiHttpIsSupported();
            this.ConnectToServer(ConnectionType.PrivateMailboxServer);

            List <PropertyTag> propertyTags = new List <PropertyTag>
            {
                PropertyHelper.PropertyTagDic[PropertyNames.PidTagMessageStatus],
                PropertyHelper.PropertyTagDic[PropertyNames.PidTagChangeKey],
                PropertyHelper.PropertyTagDic[PropertyNames.PidTagLastModificationTime]
            };

            #region Call RopLogon to logon the private mailbox.
            RopLogonResponse logonResponse = this.Logon(LogonType.Mailbox, out this.insideObjHandle);
            #endregion

            #region Call RopCreateMessage to create a new message object.
            uint targetMessageHandle = this.CreatedMessage(logonResponse.FolderIds[4], this.insideObjHandle);
            #endregion

            #region Call RopSaveChangesMessage to commit the new message object.
            RopSaveChangesMessageResponse saveChangesMessageResponse = this.SaveMessage(targetMessageHandle, (byte)SaveFlags.ForceSave);
            Site.Assert.AreEqual <uint>(TestSuiteBase.Success, saveChangesMessageResponse.ReturnValue, TestSuiteBase.ROPSucceedMsg);
            #endregion

            #region Call RopRelease to release all resources.
            this.ReleaseRop(targetMessageHandle);
            #endregion

            #region Call RopOpenFolder to open the inbox folder.
            uint folderHandle = this.OpenSpecificFolder(logonResponse.FolderIds[4], this.insideObjHandle);
            #endregion

            #region Call RopGetPropertiesSpecific to get the PidTagMessageStatus,PidTagChangeKey and PidTagLastModificationTime property before set MessagStatus.
            List <PropertyObj> ps = this.GetSpecificPropertiesOfMessage(logonResponse.FolderIds[4], saveChangesMessageResponse.MessageId, this.insideObjHandle, propertyTags);
            PropertyObj        pidTagMessageStatusBeforeSet        = PropertyHelper.GetPropertyByName(ps, PropertyNames.PidTagMessageStatus);
            PropertyObj        pidTagChangeKeyBeforeSet            = PropertyHelper.GetPropertyByName(ps, PropertyNames.PidTagChangeKey);
            PropertyObj        pidTagLastModificationTimeBeforeSet = PropertyHelper.GetPropertyByName(ps, PropertyNames.PidTagLastModificationTime);
            #endregion

            #region Call RopSetMessageStatus to set the MessageStatusFlags property of specific message to 0x00001000.
            RopSetMessageStatusRequest setMessageStatusRequest = new RopSetMessageStatusRequest()
            {
                RopId              = (byte)RopId.RopSetMessageStatus,
                LogonId            = CommonLogonId,
                InputHandleIndex   = CommonInputHandleIndex,
                MessageId          = saveChangesMessageResponse.MessageId,
                MessageStatusFlags = (uint)MessageStatusFlags.MsRemoteDownload,
                MessageStatusMask  = (uint)MessageStatusFlags.MsInConflict | (uint)MessageStatusFlags.MsRemoteDownload | (uint)MessageStatusFlags.MsRemoteDelete
            };
            this.ResponseSOHs = this.MSOXCMSGAdapter.DoRopCall(setMessageStatusRequest, folderHandle, ref this.response, ref this.rawData, GetPropertiesFlags.None);
            RopSetMessageStatusResponse setMessageStatusResponse = (RopSetMessageStatusResponse)this.response;

            #region Verify MS-OXCMSG_R773 and MS-OXCMSG_R549
            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMSG_R773");

            // Verify MS-OXCMSG requirement: MS-OXCMSG_R773
            this.Site.CaptureRequirementIfAreEqual <uint>(
                TestSuiteBase.Success,
                setMessageStatusResponse.ReturnValue,
                773,
                @"[In RopSetMessageStatus ROP] The RopSetMessageStatus ROP ([MS-OXCROPS] section 2.2.6.8) sets the PidTagMessageStatus property ([MS-OXPROPS] section 2.787) on a message in a folder without the need to open or save the Message object.");

            // Because the MS-OXCMSG_R773 has been captured and verify that the RopSetMessthatageStatus ROP sets the PidTagMessageStatus property.
            // So MS-OXCMSG_R549 can be captured directly.
            this.Site.CaptureRequirement(
                549,
                @"[In Sending a RopSetProperties ROP Request] Instead, the client calls the RopSetMessageStatus ROP ([MS-OXCROPS] section 2.2.6.8), as specified in section 2.2.3.8.");
            #endregion
            #endregion

            #region Call RopGetMessageStatus to get the message status of specific message created step 2.
            RopGetMessageStatusRequest getMessageStatusRequest = new RopGetMessageStatusRequest()
            {
                RopId            = (byte)RopId.RopGetMessageStatus,
                LogonId          = CommonLogonId,
                InputHandleIndex = CommonInputHandleIndex,
                MessageId        = saveChangesMessageResponse.MessageId
            };
            this.ResponseSOHs = this.MSOXCMSGAdapter.DoRopCall(getMessageStatusRequest, folderHandle, ref this.response, ref this.rawData, GetPropertiesFlags.None);

            // The response buffers for RopGetMessageStatus are the same as those for RopSetMessageStatus.
            RopSetMessageStatusResponse getMessageStatusRespnse = (RopSetMessageStatusResponse)this.response;

            #region MS-OXCMSG_R786, MS-OXCMSG_R2028, MS-OXCMSG_R421
            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMSG_R786, the MessageStatusFlags is {0}.", getMessageStatusRespnse.MessageStatusFlags);

            // Verify MS-OXCMSG requirement: MS-OXCMSG_R786
            bool isVerifiedR786 = getMessageStatusRespnse.ReturnValue == TestSuiteBase.Success && getMessageStatusRespnse.MessageStatusFlags == 0x00001000;

            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR786,
                786,
                @"[In RopGetMessageStatus ROP] The RopGetMessageStatus ROP ([MS-OXCROPS] section 2.2.6.9) gets the message status of a message in a folder.");

            // Because the MS-OXCMSG_R786 has been captured and verify that the RopGetMessageStatus gets the message status of a message.
            // So OXCMSG_R55 can be captured directly.
            this.Site.CaptureRequirement(
                55,
                @"[In Sending a RopGetPropertiesSpecific ROP Request] Instead, the client calls the RopGetMessageStatus ROP ([MS-OXCROPS] section 2.2.6.9), as specified in section 2.2.3.9.");

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

            // Verify MS-OXCMSG requirement: MS-OXCMSG_R2028
            this.Site.CaptureRequirementIfAreEqual <uint>(
                0x00001000,
                getMessageStatusRespnse.MessageStatusFlags,
                2028,
                @"[In PidTagMessageStatus Property] [The value of flag msRemoteDownload is] 0x00001000.");

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

            // Verify MS-OXCMSG requirement: MS-OXCMSG_R421
            // Because the message handle has been release in above step.
            // If RopGetMessageStatus execute successfully then R421 will be verified.
            this.Site.CaptureRequirementIfAreEqual <uint>(
                TestSuiteBase.Success,
                getMessageStatusRespnse.ReturnValue,
                421,
                @"[In Receiving a RopGetMessageStatus ROP Request] When processing the RopGetMessageStatus ROP ([MS-OXCROPS] section 2.2.6.9), the server MUST NOT require the Message object to be opened.");
            #endregion
            #endregion

            #region Call RopGetPropertiesSpecific to get the PidTagMessageStatus,PidTagChangeKey and PidTagLastModificationTime property after set MessagStatus.
            ps = this.GetSpecificPropertiesOfMessage(logonResponse.FolderIds[4], saveChangesMessageResponse.MessageId, this.insideObjHandle, propertyTags);
            PropertyObj pidTagMessageStatusAfterSet        = PropertyHelper.GetPropertyByName(ps, PropertyNames.PidTagMessageStatus);
            PropertyObj pidTagChangeKeyAfterSet            = PropertyHelper.GetPropertyByName(ps, PropertyNames.PidTagChangeKey);
            PropertyObj pidTagLastModificationTimeAfterSet = PropertyHelper.GetPropertyByName(ps, PropertyNames.PidTagLastModificationTime);

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

            // Verify MS-OXCMSG requirement: MS-OXCMSG_R1501
            bool isVerifiedR1501 =
                Common.CompareByteArray((byte[])pidTagChangeKeyBeforeSet.Value, (byte[])pidTagChangeKeyAfterSet.Value) == true &&
                pidTagLastModificationTimeBeforeSet.Value.Equals(pidTagLastModificationTimeAfterSet.Value) &&
                pidTagMessageStatusBeforeSet.Value != pidTagMessageStatusAfterSet.Value;

            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR1501,
                1501,
                @"[In Receiving a RopSetMessageStatus ROP Request] The server immediately commits the changes to the Message object as if the Message object had been opened and the RopSaveChangesMessage ROP ([MS-OXCROPS] section 2.2.6.3) had been called, except that it [server] changes only the PidTagMessageStatus property, not the PidTagChangeKey property ([MS-OXCFXICS] section 2.2.1.2.7), the PidTagLastModificationTime property (section 2.2.2.2), or any other property that is modified during the RopSaveChangesMessage ROP request.");
            #endregion
            #endregion

            #region Call RopSetMessageStatus to set the MessageStatusFlags property of specific message to 0x00000800.
            setMessageStatusRequest = new RopSetMessageStatusRequest()
            {
                RopId              = (byte)RopId.RopSetMessageStatus,
                LogonId            = CommonLogonId,
                InputHandleIndex   = CommonInputHandleIndex,
                MessageId          = saveChangesMessageResponse.MessageId,
                MessageStatusFlags = (uint)MessageStatusFlags.MsInConflict,
                MessageStatusMask  = (uint)MessageStatusFlags.MsInConflict | (uint)MessageStatusFlags.MsRemoteDownload | (uint)MessageStatusFlags.MsRemoteDelete
            };
            this.ResponseSOHs        = this.MSOXCMSGAdapter.DoRopCall(setMessageStatusRequest, folderHandle, ref this.response, ref this.rawData, GetPropertiesFlags.None);
            setMessageStatusResponse = (RopSetMessageStatusResponse)this.response;
            Site.Assert.AreEqual <uint>(TestSuiteBase.Success, setMessageStatusResponse.ReturnValue, TestSuiteBase.ROPSucceedMsg);

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

            // Verify MS-OXCMSG requirement: MS-OXCMSG_R784
            this.Site.CaptureRequirementIfAreEqual <uint>(
                getMessageStatusRespnse.MessageStatusFlags,
                setMessageStatusResponse.MessageStatusFlags,
                784,
                @"[In RopSetMessageStatus ROP Response Buffer] MessageStatusFlags: 4 bytes indicating the status flags that were set on the Message object before processing this request.");
            #endregion
            #endregion

            #region Call RopGetMessageStatus to get the message status of specific message created step 2.
            // RopGetMessageStatusResponse getMessageStatusResponse;
            getMessageStatusRequest.MessageId = saveChangesMessageResponse.MessageId;
            this.ResponseSOHs       = this.MSOXCMSGAdapter.DoRopCall(getMessageStatusRequest, folderHandle, ref this.response, ref this.rawData, GetPropertiesFlags.None);
            getMessageStatusRespnse = (RopSetMessageStatusResponse)this.response;
            Site.Assert.AreEqual <uint>(TestSuiteBase.Success, setMessageStatusResponse.ReturnValue, TestSuiteBase.ROPSucceedMsg);

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

            // Verify MS-OXCMSG requirement: MS-OXCMSG_R2029
            this.Site.CaptureRequirementIfAreEqual <uint>(
                0x00000800,
                getMessageStatusRespnse.MessageStatusFlags,
                2029,
                @"[In PidTagMessageStatus Property] [The value of flag msInConflict is] 0x00000800.");

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMSG_R416, the MessageStatusFlags value is {0}.", setMessageStatusResponse.MessageStatusFlags);

            // Verify MS-OXCMSG requirement: MS-OXCMSG_R416
            bool isVerifiedR416 = getMessageStatusRespnse.MessageStatusFlags == (setMessageStatusRequest.MessageStatusMask & setMessageStatusRequest.MessageStatusFlags);

            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR416,
                416,
                @"[In Receiving a RopSetMessageStatus ROP Request] When processing the RopSetMessageStatus ROP ([MS-OXCROPS] section 2.2.6.8), the server modifies the bits on the PidTagMessageStatus property (section 2.2.1.8) specified by the MessageStatusMask field, preserving only those flags that are set in both the MessageStatusMask field and the MessageStatusFlags field, and clearing any other flags set only in the MessageStatusMask field.");

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

            // Verify MS-OXCMSG requirement: MS-OXCMSG_R1500
            bool isVerifiedR1500 = (getMessageStatusRespnse.MessageStatusFlags & (~setMessageStatusRequest.MessageStatusFlags & setMessageStatusRequest.MessageStatusMask)) == 0x00000000;

            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR1500,
                1500,
                @"[In Receiving a RopSetMessageStatus ROP Request] [When processing the RopSetMessageStatus ROP, the server] clearing any other flags set only in the MessageStatusMask field.");
            #endregion
            #endregion

            #region Call RopSetMessageStatus to set the MessageStatusFlags property of specific message to 0x00002000.
            setMessageStatusRequest = new RopSetMessageStatusRequest()
            {
                RopId              = (byte)RopId.RopSetMessageStatus,
                LogonId            = CommonLogonId,
                InputHandleIndex   = CommonInputHandleIndex,
                MessageId          = saveChangesMessageResponse.MessageId,
                MessageStatusFlags = (uint)MessageStatusFlags.MsRemoteDelete,
                MessageStatusMask  = (uint)MessageStatusFlags.MsInConflict | (uint)MessageStatusFlags.MsRemoteDownload | (uint)MessageStatusFlags.MsRemoteDelete
            };
            this.ResponseSOHs        = this.MSOXCMSGAdapter.DoRopCall(setMessageStatusRequest, folderHandle, ref this.response, ref this.rawData, GetPropertiesFlags.None);
            setMessageStatusResponse = (RopSetMessageStatusResponse)this.response;
            Site.Assert.AreEqual <uint>(TestSuiteBase.Success, setMessageStatusResponse.ReturnValue, TestSuiteBase.ROPSucceedMsg);
            #endregion

            #region Call RopGetMessageStatus get the message status of specific message created step 2.
            getMessageStatusRequest.MessageId = saveChangesMessageResponse.MessageId;
            this.ResponseSOHs       = this.MSOXCMSGAdapter.DoRopCall(getMessageStatusRequest, folderHandle, ref this.response, ref this.rawData, GetPropertiesFlags.None);
            getMessageStatusRespnse = (RopSetMessageStatusResponse)this.response;
            Site.Assert.AreEqual <uint>(TestSuiteBase.Success, setMessageStatusResponse.ReturnValue, TestSuiteBase.ROPSucceedMsg);

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

            // Verify MS-OXCMSG requirement: MS-OXCMSG_R2030
            this.Site.CaptureRequirementIfAreEqual <uint>(
                0x00002000,
                getMessageStatusRespnse.MessageStatusFlags,
                2030,
                @"[In PidTagMessageStatus Property] [The value of flag msRemoteDelete is] 0x00002000.");
            #endregion
            #endregion
        }
Exemplo n.º 16
0
        public void MSOXCRPC_S02_TC03_TestInvalidAsynchronousContextHandle()
        {
            this.CheckTransport();

            #region Client connects with Server
            this.pcbAuxOut   = ConstValues.ValidpcbAuxOut;
            this.returnValue = this.oxcrpcAdapter.EcDoConnectEx(
                ref this.pcxh,
                TestSuiteBase.UlIcxrLinkForNoSessionLink,
                ref this.pulTimeStamp,
                null,
                this.userDN,
                ref this.pcbAuxOut,
                this.rgwClientVersion,
                out this.rgwBestVersion,
                out this.picxr);
            Site.Assert.AreEqual <uint>(0, this.returnValue, "EcDoConnectEx should succeed, and send Session Context Handle (CXH) to EcDoAsyncConnectEx for testing EcDoAsyncWaitEx. '0' is expected to be returned. The returned value is {0}.", this.returnValue);
            #endregion

            #region Call EcDoRpcExt2 method with RopLogon as rgbIn
            // Parameter inObjHandle is no use for RopLogon command, so set it to unUsedInfo.
            this.rgbIn     = AdapterHelper.ComposeRgbIn(ROPCommandType.RopLogon, this.unusedInfo, this.userPrivilege);
            this.pcbOut    = ConstValues.ValidpcbOut;
            this.pcbAuxOut = ConstValues.ValidpcbAuxOut;

            this.returnValue = this.oxcrpcAdapter.EcDoRpcExt2(
                ref this.pcxh,
                PulFlags.NoCompression | PulFlags.NoXorMagic,
                this.rgbIn,
                ref this.pcbOut,
                null,
                ref this.pcbAuxOut,
                out this.response,
                ref this.responseSOHTable);
            Site.Assert.AreEqual <uint>(0, this.returnValue, "RopLogon should succeed and '0' is expected to be returned. The returned value is {0}.", this.returnValue);
            RopLogonResponse logonResponse = (RopLogonResponse)this.response;
            Site.Assert.AreEqual <uint>(0, logonResponse.ReturnValue, "RopLogon should succeed and 0 is expected to be returned. The returned value is {0}.", logonResponse.ReturnValue);
            this.objHandle = this.responseSOHTable[TestSuiteBase.FIRST][logonResponse.OutputHandleIndex];
            #endregion

            #region Call EcDoAsyncConnectEx
            this.returnValue = this.oxcrpcAdapter.EcDoAsyncConnectEx(this.pcxh, ref this.pacxh);
            Site.Assert.AreEqual <uint>(0, this.returnValue, "EcDoAsyncConnectEx should succeed and sends ACXH to EcDoAsyncWaitEx. '0' is expected to be returned. The returned value is {0}.", this.returnValue);
            #endregion

            #region Register events on server
            this.rgbIn     = AdapterHelper.ComposeRgbIn(ROPCommandType.RopRegisterNotification, this.objHandle, logonResponse.FolderIds[(int)FolderIds.InterpersonalMessage]);
            this.pcbOut    = ConstValues.ValidpcbOut;
            this.pcbAuxOut = ConstValues.ValidpcbAuxOut;

            this.returnValue = this.oxcrpcAdapter.EcDoRpcExt2(
                ref this.pcxh,
                PulFlags.NoCompression | PulFlags.NoXorMagic,
                this.rgbIn,
                ref this.pcbOut,
                null,
                ref this.pcbAuxOut,
                out this.response,
                ref this.responseSOHTable);
            Site.Assert.AreEqual <uint>(0, this.returnValue, "EcDoRpcExt2 should succeed and '0' is expected to be returned. The returned value is {0}.", this.returnValue);
            RopRegisterNotificationResponse registerNotificationResponse = (RopRegisterNotificationResponse)this.response;
            Site.Assert.AreEqual <uint>(0, registerNotificationResponse.ReturnValue, "RopRegisterNotification should succeed and '0' is expected to be returned. The returned value is {0}.", registerNotificationResponse.ReturnValue);
            #endregion

            #region Client disconnects with Server
            this.returnValue = this.oxcrpcAdapter.EcDoDisconnect(ref this.pcxh);
            Site.Assert.AreEqual <uint>(0, this.returnValue, "EcDoDisconnect should succeed and CXH used for testing EcDoAsyncWaitEx should be released. '0' is expected to be returned. The returned value is {0}.", this.returnValue);
            #endregion

            #region Call EcDoAsyncWaitEx
            uint returnValueForEcDoAsyncWaitEx = this.oxcrpcAdapter.EcDoAsyncWaitEx(this.pacxh, out this.isNotificationPending);
            #endregion

            #region Call EcDoRpcExt2 with no ROP in rgbIn to get the notify information
            // Parameter inObjHandle and auxInfo are no use for null ROP command, so set them to unUsedInfo.
            this.rgbIn     = AdapterHelper.ComposeRgbIn(ROPCommandType.WithoutRops, this.unusedInfo, this.unusedInfo);
            this.pcbAuxOut = ConstValues.ValidpcbAuxOut;
            this.pcbOut    = ConstValues.ValidpcbOut;
            uint returnValueForEcDoRpcExt2 = this.oxcrpcAdapter.EcDoRpcExt2(
                ref this.pcxh,
                PulFlags.NoCompression | PulFlags.NoXorMagic,
                this.rgbIn,
                ref this.pcbOut,
                null,
                ref this.pcbAuxOut,
                out this.response,
                ref this.responseSOHTable);

            #region Capture code.
            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCRPC_R1213, server returns {0} when call EcDoAsyncWaitEx, server returns {1} when call EcDoRpcExt2.", returnValueForEcDoAsyncWaitEx, returnValueForEcDoRpcExt2);

            // Verify MS-OXCRPC requirement: MS-OXCRPC_R1213
            bool isVerifiedR1213 = returnValueForEcDoAsyncWaitEx != 0 || returnValueForEcDoRpcExt2 != 0;

            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR1213,
                1213,
                @"[In Abstract Data Model] When the session context is destroyed, the asynchronous context handle becomes invalid and will be rejected if used.");

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCRPC_R1269,server returns {0} when call EcDoAsyncWaitEx, server returns {1} when call EcDoRpcExt2.", returnValueForEcDoAsyncWaitEx, returnValueForEcDoRpcExt2);

            // Verify MS-OXCRPC requirement: MS-OXCRPC_R1269
            bool isVerifiedR1269 = returnValueForEcDoAsyncWaitEx != 0 || returnValueForEcDoRpcExt2 != 0;

            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR1269,
                1269,
                @"[In Abstract Data Model] When the client connection is lost, the asynchronous context handle becomes invalid and will be rejected if used.");
            #endregion
            #endregion
        }
Exemplo n.º 17
0
        public void MSOXCRPC_S02_TC02_TestWithPendingEvent()
        {
            this.CheckTransport();

            #region Initializes Server and Client
            this.returnStatus = this.oxcrpcAdapter.InitializeRPC(this.authenticationLevel, this.authenticationService, this.userName, this.password);
            Site.Assert.IsTrue(this.returnStatus, "The returned status is {0}. TRUE means that initializing the server and client to call EcDoAsyncWaitEx successfully, and FALSE means that initializing the server and client to call EcDoAsyncWaitEx failed.", this.returnStatus);
            #endregion

            #region Client connects with Server
            this.pcbAuxOut   = ConstValues.ValidpcbAuxOut;
            this.returnValue = this.oxcrpcAdapter.EcDoConnectEx(
                ref this.pcxh,
                TestSuiteBase.UlIcxrLinkForNoSessionLink,
                ref this.pulTimeStamp,
                null,
                this.userDN,
                ref this.pcbAuxOut,
                this.rgwClientVersion,
                out this.rgwBestVersion,
                out this.picxr);
            Site.Assert.AreEqual <uint>(0, this.returnValue, "EcDoConnectEx should succeed and send Session Context Handle (CXH) to EcDoRpcExt2 for testing EcDoAsyncWaitEx. '0' is expected to be returned. The returned value is {0}.", this.returnValue);
            #endregion

            #region Call EcDoRpcExt2 method with RopLogon as rgbIn
            // Parameter inObjHandle is no use for RopLogon command, so set it to unUsedInfo.
            this.rgbIn     = AdapterHelper.ComposeRgbIn(ROPCommandType.RopLogon, this.unusedInfo, this.userPrivilege);
            this.pcbOut    = ConstValues.ValidpcbOut;
            this.pcbAuxOut = ConstValues.ValidpcbAuxOut;

            this.returnValue = this.oxcrpcAdapter.EcDoRpcExt2(
                ref this.pcxh,
                PulFlags.NoCompression | PulFlags.NoXorMagic,
                this.rgbIn,
                ref this.pcbOut,
                null,
                ref this.pcbAuxOut,
                out this.response,
                ref this.responseSOHTable);
            Site.Assert.AreEqual <uint>(0, this.returnValue, "EcDoRpcExt2 should succeed and '0' is expected to be returned. The returned value is {0}.", this.returnValue);
            RopLogonResponse logonResponse = (RopLogonResponse)this.response;
            Site.Assert.AreEqual <uint>(0, logonResponse.ReturnValue, "RopLogon should succeed and 0 is expected to be returned. The returned value is {0}.", logonResponse.ReturnValue);
            this.objHandle = this.responseSOHTable[TestSuiteBase.FIRST][logonResponse.OutputHandleIndex];
            #endregion

            #region Call EcDoAsyncConnectEx
            this.returnValue = this.oxcrpcAdapter.EcDoAsyncConnectEx(this.pcxh, ref this.pacxh);
            Site.Assert.AreEqual <uint>(0, this.returnValue, "EcDoAsyncConnectEx should succeed and sends ACXH to EcDoAsyncWaitEx. '0' is expected to be returned. The returned value is {0}.", this.returnValue);
            #endregion

            #region Register events on server
            this.rgbIn     = AdapterHelper.ComposeRgbIn(ROPCommandType.RopRegisterNotification, this.objHandle, logonResponse.FolderIds[(int)FolderIds.InterpersonalMessage]);
            this.pcbOut    = ConstValues.ValidpcbOut;
            this.pcbAuxOut = ConstValues.ValidpcbAuxOut;

            this.returnValue = this.oxcrpcAdapter.EcDoRpcExt2(
                ref this.pcxh,
                PulFlags.NoCompression | PulFlags.NoXorMagic,
                this.rgbIn,
                ref this.pcbOut,
                null,
                ref this.pcbAuxOut,
                out this.response,
                ref this.responseSOHTable);
            Site.Assert.AreEqual <uint>(0, this.returnValue, "EcDoRpcExt2 should succeed and '0' is expected to be returned. The returned value is {0}.", this.returnValue);
            RopRegisterNotificationResponse registerNotificationResponse = (RopRegisterNotificationResponse)this.response;
            Site.Assert.AreEqual <uint>(0, registerNotificationResponse.ReturnValue, "RopRegisterNotification should succeed and 0 is expected to be returned. The returned value is {0}.", registerNotificationResponse.ReturnValue);
            #endregion

            #region Call EcDoAsyncWaitEx
            // Trigger the event
            bool isCreateMailSuccess = this.oxcrpcControlAdapter.CreateMailItem();
            Site.Assert.IsTrue(isCreateMailSuccess, "CreateMailItem method should execute successfully.");

            this.returnValue = this.oxcrpcAdapter.EcDoAsyncWaitEx(this.pacxh, out this.isNotificationPending);
            Site.Assert.AreEqual <uint>(0, this.returnValue, @"EcDoAsyncWaitEx should succeed to check whether the NotificationPending flag is set in the pulFlagsOut field, on AsyncEMSMDB method if an event is pending. '0' is expected to be returned. The returned value is {0}.", this.returnValue);

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCRPC_R1231, there are {0} pending events for the client on the Session Context on the server.", this.isNotificationPending ? string.Empty : "not");

            // Verify MS-OXCRPC requirement: MS-OXCRPC_R1231
            Site.CaptureRequirementIfIsTrue(
                this.isNotificationPending,
                1231,
                @"[In EcDoAsyncWaitEx Method (opnum 0)] If an event is pending, the server completes the call immediately and returns the NotificationPending flag in the pulFlagsOut parameter.");

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

            // Verify MS-OXCRPC requirement: MS-OXCRPC_R19
            // Because client can use the asynchronous context handle to call EcDoAsyncWaitEx method successful.
            // So R19 will be verified.
            this.Site.CaptureRequirementIfAreEqual <uint>(
                0,
                this.returnValue,
                19,
                @"[In ACXH Data Type] The AXCH data type is an asynchronous context handle to be used with an AsyncEMSMDB interface, as specified in section 3.3 and section 3.4.");

            #endregion

            #region Call EcDoRpcExt2 with no ROP in rgbIn to get the notify information
            // Parameter inObjHandle and auxInfo are no use for null ROP command, so set them to unUsedInfo.
            this.rgbIn       = AdapterHelper.ComposeRgbIn(ROPCommandType.WithoutRops, this.unusedInfo, this.unusedInfo);
            this.pcbAuxOut   = ConstValues.ValidpcbAuxOut;
            this.pcbOut      = ConstValues.ValidpcbOut;
            this.returnValue = this.oxcrpcAdapter.EcDoRpcExt2(
                ref this.pcxh,
                PulFlags.NoCompression | PulFlags.NoXorMagic,
                this.rgbIn,
                ref this.pcbOut,
                null,
                ref this.pcbAuxOut,
                out this.response,
                ref this.responseSOHTable);

            Site.Assert.AreEqual <uint>(0, this.returnValue, @"EcDoRpcExt2 should succeed to get the RopNotifyResponse. '0' is expected to be returned. The returned value is {0}.", this.returnValue);

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCRPC_R1243, the ROP response is {0}", (RopNotifyResponse)this.response);

            // Verify MS-OXCRPC requirement: MS-OXCRPC_R1243
            // According to the Open Specification MS-OXCNOTIF, the event details are in the RopNotifyResponse. If the rgbOut can be converted (parsed) to RopNotifyResponse, this requirement will be verified.
            Site.CaptureRequirementIfIsNotNull(
                (RopNotifyResponse)this.response,
                1243,
                @"[In EcDoAsyncWaitEx Method (opnum 0)] [pulFlagsOut] [Flag NotificationPending] The server will return the event details in the ROP response buffer.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCRPC_R1229, the ROP response is {0}", (RopNotifyResponse)this.response);

            // Verify MS-OXCRPC requirement: MS-OXCRPC_R1229
            // If the response of method EcDoRpcExt2 is not null, it indicates that method EcDoAsyncWaitEx have been completed because server will return the event details in the ROP response buffer.
            Site.CaptureRequirementIfIsNotNull(
                (RopNotifyResponse)this.response,
                1229,
                @"[In EcDoAsyncWaitEx Method (opnum 0)] The EcDoAsyncWaitEx method is an asynchronous call that the server does not complete until events are pending on the Session Context, up to a 5-minute duration of no client activity.");

            #endregion

            #region Client disconnects with Server
            this.returnValue = this.oxcrpcAdapter.EcDoDisconnect(ref this.pcxh);
            Site.Assert.AreEqual <uint>(0, this.returnValue, "EcDoDisconnect should succeed and CXH used for testing EcDoAsyncWaitEx should be released. '0' is expected to be returned. The returned value is {0}.", this.returnValue);
            #endregion
        }
Exemplo n.º 18
0
        public void MSOXCROPS_S09_TC01_TestRopModifyRules()
        {
            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: Preparations-Open folder and get it's handle.
            RopLogonResponse logonResponse = Logon(LogonType.Mailbox, this.userDN, out inputObjHandle);

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 1: Call GetFolderObjectHandle method to get folder object handle..");

            uint folderHandle = GetFolderObjectHandle(ref logonResponse);

            // Step 2: Send the RopModifyRules request and verify success response.
            #region RopModifyRules

            RopModifyRulesRequest  modifyRulesRequest;
            RopModifyRulesResponse modifyRulesResponse;
            RuleData[]             sampleRuleDataArray;

            modifyRulesRequest.RopId = (byte)RopId.RopModifyRules;

            modifyRulesRequest.LogonId          = TestSuiteBase.LogonId;
            modifyRulesRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

            // Call CreateSampleRuleDataArrayForAdd method to create Sample RuleData Array.
            sampleRuleDataArray = this.CreateSampleRuleDataArrayForAdd();

            modifyRulesRequest.ModifyRulesFlags = (byte)ModifyRulesFlags.None;
            modifyRulesRequest.RulesCount       = (ushort)sampleRuleDataArray.Length;
            modifyRulesRequest.RulesData        = sampleRuleDataArray;

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

            // Send the RopModifyRules request and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                modifyRulesRequest,
                folderHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            modifyRulesResponse = (RopModifyRulesResponse)response;
            Site.Assert.AreEqual <uint>(
                TestSuiteBase.SuccessReturnValue,
                modifyRulesResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0 (success0");

            #endregion

            // Step 3: Send the RopGetRulesTable request and verify success response.
            #region RopGetRulesTable

            RopGetRulesTableRequest  getRulesTableRequest;
            RopGetRulesTableResponse getRulesTableResponse;

            getRulesTableRequest.RopId             = (byte)RopId.RopGetRulesTable;
            getRulesTableRequest.LogonId           = TestSuiteBase.LogonId;
            getRulesTableRequest.InputHandleIndex  = TestSuiteBase.InputHandleIndex0;
            getRulesTableRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;
            getRulesTableRequest.TableFlags        = (byte)TableFlags.None;

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

            // Send the RopGetRulesTable request and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                getRulesTableRequest,
                folderHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            getRulesTableResponse = (RopGetRulesTableResponse)response;
            Site.Assert.AreEqual <uint>(
                TestSuiteBase.SuccessReturnValue,
                getRulesTableResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0 (success0");

            #endregion

            // Step 4: Send the RopUpdateDeferredActionMessages request and verify success response.
            #region RopUpdateDeferredActionMessages

            RopUpdateDeferredActionMessagesRequest updateDeferredActionMessagesRequest;

            updateDeferredActionMessagesRequest.RopId            = (byte)RopId.RopUpdateDeferredActionMessages;
            updateDeferredActionMessagesRequest.LogonId          = TestSuiteBase.LogonId;
            updateDeferredActionMessagesRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

            // Set ServerEntryIdSize,which specifies the size of the ServerEntryId field.
            updateDeferredActionMessagesRequest.ServerEntryIdSize = TestSuiteBase.ServerEntryIdSize;

            byte[] serverId = { ServerEntryId };
            updateDeferredActionMessagesRequest.ServerEntryId = serverId;

            // Set ClientEntryIdSize,which specifies the size of the ClientEntryId field.
            updateDeferredActionMessagesRequest.ClientEntryIdSize = TestSuiteBase.ClientEntryIdSize;

            byte[] clientId = { ClientEntryId };
            updateDeferredActionMessagesRequest.ClientEntryId = clientId;

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

            // Send the RopUpdateDeferredActionMessages request.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                updateDeferredActionMessagesRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);

            #endregion
        }
Exemplo n.º 19
0
        public void MSOXCMSG_S06_TC01_RopReloadCachedInformation()
        {
            this.CheckMapiHttpIsSupported();
            this.ConnectToServer(ConnectionType.PrivateMailboxServer);

            #region Call RopLogon to log on a private mailbox.
            uint             logonHandle;
            RopLogonResponse logonResponse = this.Logon(LogonType.Mailbox, out logonHandle);
            #endregion

            #region Call RopCreateMessage to create a new message object.
            uint targetMessageHandle = this.CreatedMessage(logonResponse.FolderIds[4], logonHandle);
            #endregion

            #region Call RopSaveChangesMessage to commit the new message object.
            RopSaveChangesMessageResponse saveChangesMessageResponse = this.SaveMessage(targetMessageHandle, (byte)SaveFlags.ForceSave);
            Site.Assert.AreEqual <uint>(TestSuiteBase.Success, saveChangesMessageResponse.ReturnValue, TestSuiteBase.ROPSucceedMsg);
            ulong messageId = saveChangesMessageResponse.MessageId;
            #endregion

            this.ReleaseRop(targetMessageHandle);

            #region Call RopOpenMessage to open the created message.
            RopOpenMessageResponse openMessageResponse;
            uint openedMessageHandle = this.OpenSpecificMessage(logonResponse.FolderIds[4], messageId, logonHandle, MessageOpenModeFlags.ReadWrite, out openMessageResponse);
            #endregion

            #region Call RopReloadCachedInformation to get information of the specific message.
            RopReloadCachedInformationRequest reloadCachedInformationRequest = new RopReloadCachedInformationRequest()
            {
                RopId            = (byte)RopId.RopReloadCachedInformation,
                LogonId          = CommonLogonId,
                InputHandleIndex = CommonInputHandleIndex,
                Reserved         = 0x0000
            };
            this.response     = new RopReloadCachedInformationResponse();
            this.ResponseSOHs = this.MSOXCMSGAdapter.DoRopCall(reloadCachedInformationRequest, openedMessageHandle, ref this.response, ref this.rawData, GetPropertiesFlags.None);
            RopReloadCachedInformationResponse reloadCachedInformationResponse = (RopReloadCachedInformationResponse)this.response;

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

            // Verify MS-OXCMSG requirement: MS-OXCMSG_R279
            this.Site.CaptureRequirementIfAreEqual <uint>(
                TestSuiteBase.Success,
                reloadCachedInformationResponse.ReturnValue,
                279,
                @"[In Reload Message Object Header Info] A client retrieves the current state of the data returned in a RopOpenMessage ROP ([MS-OXCROPS] section 2.2.6.1) by sending a RopReloadCachedInformation ROP request ([MS-OXCROPS] section 2.2.6.7).");

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

            // Verify MS-OXCMSG requirement: MS-OXCMSG_R766
            bool isVerifiedR766 = this.CompareResponseOfOpenMessageAndRopReloadCachedInformation(openMessageResponse, reloadCachedInformationResponse);

            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR766,
                766,
                @"[In RopReloadCachedInformation ROP] The RopReloadCachedInformation ROP ([MS-OXCROPS] section 2.2.6.7) retrieves the same information as RopOpenMessage ROP ([MS-OXCROPS] section 2.2.6.1) but operates on an already opened Message object.");
            #endregion
            #endregion

            #region Call RopRelease to release all resources
            this.ReleaseRop(openedMessageHandle);
            #endregion
        }
        public void MSOXCROPS_S08_TC01_TestRopGetAndModifyPermissions()
        {
            this.CheckTransportIsSupported();

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

            // Step 1: Preparations-Open folder and create a subfolder, then get it's handle.
            #region Common operations

            RopLogonResponse logonResponse = Logon(LogonType.Mailbox, this.userDN, out inputObjHandle);
            uint             folderHandle  = GetFolderObjectHandle(ref logonResponse);

            #endregion

            // Step 2: Construct RopGetPermissionsTable request.
            #region RopGetPermissionsTable request

            RopGetPermissionsTableRequest getPermissionsTableRequest;

            getPermissionsTableRequest.RopId = (byte)RopId.RopGetPermissionsTable;

            getPermissionsTableRequest.LogonId           = TestSuiteBase.LogonId;
            getPermissionsTableRequest.InputHandleIndex  = TestSuiteBase.InputHandleIndex0;
            getPermissionsTableRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;
            getPermissionsTableRequest.TableFlags        = (byte)PermTableFlags.IncludeFreeBusy;

            #endregion

            // Step 3: Construct RopSetColumns request.
            #region RopSetColumns request

            // Call CreatePermissionPropertyTags method to create Permission PropertyTags.
            PropertyTag[]        propertyTags = this.CreatePermissionPropertyTags();
            RopSetColumnsRequest setColumnsRequest;

            setColumnsRequest.RopId            = (byte)RopId.RopSetColumns;
            setColumnsRequest.LogonId          = TestSuiteBase.LogonId;
            setColumnsRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex1;
            setColumnsRequest.PropertyTagCount = (ushort)propertyTags.Length;
            setColumnsRequest.PropertyTags     = propertyTags;
            setColumnsRequest.SetColumnsFlags  = (byte)AsynchronousFlags.None;

            #endregion

            // Step 4: Construct RopQueryRows request.
            #region RopQueryRows request

            RopQueryRowsRequest queryRowsRequest;

            queryRowsRequest.RopId            = (byte)RopId.RopQueryRows;
            queryRowsRequest.LogonId          = TestSuiteBase.LogonId;
            queryRowsRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex1;
            queryRowsRequest.QueryRowsFlags   = (byte)QueryRowsFlags.Advance;

            // TRUE: read the table forwards.
            queryRowsRequest.ForwardRead = TestSuiteBase.NonZero;

            // Maximum number of rows to be returned
            queryRowsRequest.RowCount = TestSuiteBase.RowCount;

            #endregion

            // Step 5: Send the Multiple ROPs request and verify the success response.
            #region Multiple ROPs

            List <ISerializable>   requests     = new List <ISerializable>();
            List <IDeserializable> ropResponses = new List <IDeserializable>();
            List <uint>            handleList   = new List <uint>
            {
                folderHandle,
                TestSuiteBase.DefaultFolderHandle
            };
            requests.Add(getPermissionsTableRequest);
            requests.Add(setColumnsRequest);
            requests.Add(queryRowsRequest);

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

            // Send the Multiple ROPs request and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessMutipleRops(
                requests,
                handleList,
                ref ropResponses,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            RopGetPermissionsTableResponse getPermissionsTableResponse = (RopGetPermissionsTableResponse)ropResponses[0];
            RopSetColumnsResponse          setColumnsResponse          = (RopSetColumnsResponse)ropResponses[1];
            RopQueryRowsResponse           queryRowsResponse           = (RopQueryRowsResponse)ropResponses[2];

            // Send the RopModifyPermissions request and verify response.
            #region RopModifyPermissions request

            RopModifyPermissionsRequest modifyPermissionsRequest;
            PermissionData[]            permissionsDataArray = this.GetPermissionDataArray();

            modifyPermissionsRequest.RopId            = (byte)RopId.RopModifyPermissions;
            modifyPermissionsRequest.LogonId          = TestSuiteBase.LogonId;
            modifyPermissionsRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            modifyPermissionsRequest.ModifyFlags      = (byte)ModifyFlags.IncludeFreeBusy;
            modifyPermissionsRequest.ModifyCount      = (ushort)permissionsDataArray.Length;
            modifyPermissionsRequest.PermissionsData  = permissionsDataArray;

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                modifyPermissionsRequest,
                folderHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            RopModifyPermissionsResponse modifyPermissionsResponse = (RopModifyPermissionsResponse)response;

            #endregion

            bool isRopsSuccess = (getPermissionsTableResponse.ReturnValue == TestSuiteBase.SuccessReturnValue) &&
                                 (setColumnsResponse.ReturnValue == TestSuiteBase.SuccessReturnValue) &&
                                 (queryRowsResponse.ReturnValue == TestSuiteBase.SuccessReturnValue) &&
                                 (modifyPermissionsResponse.ReturnValue == TestSuiteBase.SuccessReturnValue);
            Site.Assert.IsTrue(isRopsSuccess, "If ROP succeeds, the ReturnValue of its response is 0 (success)");

            #endregion
        }
Exemplo n.º 21
0
        public void MSOXCMSG_S02_TC02_ErrorCodeOfMessageStatus()
        {
            this.CheckMapiHttpIsSupported();
            this.ConnectToServer(ConnectionType.PrivateMailboxServer);

            #region Call RopLogon to logon the private mailbox.
            RopLogonResponse logonResponse = this.Logon(LogonType.Mailbox, out this.insideObjHandle);
            #endregion

            #region Call RopCreateMessage to create a Message object.
            uint targetMessageHandle = this.CreatedMessage(logonResponse.FolderIds[4], this.insideObjHandle);
            #endregion

            #region Call RopSaveChangesMessage to save created message.
            RopSaveChangesMessageResponse saveChangesMessageResponse = this.SaveMessage(targetMessageHandle, (byte)SaveFlags.ForceSave);
            Site.Assert.AreEqual <uint>(TestSuiteBase.Success, saveChangesMessageResponse.ReturnValue, TestSuiteBase.ROPSucceedMsg);
            #endregion

            #region Call RopOpenFolder to open the inbox folder.
            uint folderHandle = this.OpenSpecificFolder(logonResponse.FolderIds[4], this.insideObjHandle);
            #endregion

            #region Call RopSetMessageStatus to set message status. The value of the InputHandleIndex field on which this ROP was called does not refer to a Folder object.
            RopSetMessageStatusRequest setMessageStatusRequest = new RopSetMessageStatusRequest()
            {
                RopId              = (byte)RopId.RopSetMessageStatus,
                LogonId            = CommonLogonId,
                InputHandleIndex   = CommonInputHandleIndex,
                MessageId          = saveChangesMessageResponse.MessageId,
                MessageStatusFlags = (uint)MessageStatusFlags.MsRemoteDownload,
                MessageStatusMask  = (uint)MessageStatusFlags.MsRemoteDownload
            };
            this.ResponseSOHs = this.MSOXCMSGAdapter.DoRopCall(setMessageStatusRequest, TestSuiteBase.InvalidInputHandle, ref this.response, ref this.rawData, GetPropertiesFlags.None);
            RopSetMessageStatusResponse setMessageStatusResponse = (RopSetMessageStatusResponse)this.response;

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

            // Verify MS-OXCMSG requirement: MS-OXCMSG_R1505
            this.Site.CaptureRequirementIfAreEqual <uint>(
                0x000004B9,
                setMessageStatusResponse.ReturnValue,
                1505,
                @"[In Receiving a RopSetMessageStatus ROP Request] [ecNullObject (0x000004B9)] The value of the InputHandleIndex field on which this ROP [RopSetMessageStatus] was called does not refer to a Folder object.");
            #endregion

            #region Call RopGetMessageStatus to get message status.The value of the InputHandleIndex field on which this ROP was called does not refer to a Folder object.
            RopGetMessageStatusRequest getMessageStatusRequest = new RopGetMessageStatusRequest
            {
                RopId            = (byte)RopId.RopGetMessageStatus,
                LogonId          = CommonLogonId,
                InputHandleIndex = CommonInputHandleIndex,
                MessageId        = saveChangesMessageResponse.MessageId
            };

            // RopGetMessageStatusResponse getMessageStatusResponse;
            this.ResponseSOHs = this.MSOXCMSGAdapter.DoRopCall(getMessageStatusRequest, TestSuiteBase.InvalidInputHandle, ref this.response, ref this.rawData, GetPropertiesFlags.None);

            // The response buffers for RopGetMessageStatus are the same as those for RopSetMessageStatus
            setMessageStatusResponse = (RopSetMessageStatusResponse)this.response;

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

            // Verify MS-OXCMSG requirement: MS-OXCMSG_R1507
            this.Site.CaptureRequirementIfAreEqual <uint>(
                0x000004B9,
                setMessageStatusResponse.ReturnValue,
                1507,
                @"[In Receiving a RopGetMessageStatus ROP Request] [ecNullObject (0x000004B9)] The value of the InputHandleIndex field on which this ROP [RopGetMessageStatus] was called does not refer to a Folder object.");
            #endregion

            #region Call RopRelease to release created message.
            this.ReleaseRop(targetMessageHandle);
            this.ReleaseRop(folderHandle);
            #endregion
        }
Exemplo n.º 22
0
        public void MSOXCROPS_S07_TC04_TestRopsCloneAndCopyToStream()
        {
            this.CheckTransportIsSupported();

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

            // Step 5: Preparations for RopCloneStream and RopCopyToStream.
            #region Common operations for RopCloneStream and RopCopyToStream

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

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 5:Call GetCreatedMessageHandle method to create message and get its handle.");

            // Call GetCreatedMessageHandle method to create message and get its handle.
            uint sourceMessageHandle = GetCreatedMessageHandle(logonResponse.FolderIds[4], inputObjHandle);

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 5:Call GetOpenedStreamHandle method to open stream and get its handle.");

            // Call GetOpenedStreamHandle method to open stream and get its handle.
            uint sourceStreamObjectHandle = this.GetOpenedStreamHandle(sourceMessageHandle);

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 5:Call WriteStream method to write stream.");

            // Call WriteStream method to write stream.
            this.WriteStream(sourceStreamObjectHandle);

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 5:Call CommitStream method to commit source stream.");

            // Call CommitStream method to commit source stream.
            this.CommitStream(sourceStreamObjectHandle);

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 5:Call SaveMessage method to save message.");

            // Call SaveMessage method to save message.
            this.SaveMessage(sourceMessageHandle);

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 5:Call GetOpenedStreamHandle method to open the source stream again.");

            // Open the source stream again.
            sourceStreamObjectHandle = this.GetOpenedStreamHandle(sourceMessageHandle);

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 5:Call GetCreatedMessageHandle method to create a second message.");

            // Create a second message.
            uint destinationMessageHandle = GetCreatedMessageHandle(logonResponse.FolderIds[4], inputObjHandle);

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 5:Call GetOpenedStreamHandle method to open stream.");

            // Open stream, used as destination stream.
            uint destinationStreamObjectHandle = this.GetOpenedStreamHandle(destinationMessageHandle);

            // Copy stream, from source to destination.
            List <uint> handleList = new List <uint>
            {
                sourceStreamObjectHandle, destinationStreamObjectHandle
            };

            #endregion

            // Refer to MS-OXCPRPT: Exchange 2003 and Exchange 2007 implement the RopCloneStream ROP.
            if (Common.IsRequirementEnabled(753001, this.Site))
            {
                // Step 6: Send the RopCloneStream request and verify the success response.
                #region RopCloneStream response

                RopCloneStreamRequest  cloneStreamRequest;
                RopCloneStreamResponse cloneStreamResponse;

                cloneStreamRequest.RopId             = (byte)RopId.RopCloneStream;
                cloneStreamRequest.LogonId           = TestSuiteBase.LogonId;
                cloneStreamRequest.InputHandleIndex  = TestSuiteBase.InputHandleIndex0;
                cloneStreamRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;

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

                // Send the RopCloneStream request and verify the success response.
                this.responseSOHs = cropsAdapter.ProcessSingleRopWithMutipleServerObjects(
                    cloneStreamRequest,
                    handleList,
                    ref this.response,
                    ref this.rawData,
                    RopResponseType.SuccessResponse);
                cloneStreamResponse = (RopCloneStreamResponse)response;

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

                // Verify MS-OXCROPS requirement: MS-OXCROPS_R753001
                Site.CaptureRequirementIfAreEqual <uint>(
                    TestSuiteBase.SuccessReturnValue,
                    cloneStreamResponse.ReturnValue,
                    753001,
                    @"[In Appendix A: Product Behavior] Implementation does implement the RopCloneStream ROP. (Exchange 2007 follows this behavior.)");

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

                #endregion
            }

            // Refer to MS-OXCPRPT: The initial release version of Exchange 2010 does not implement the RopCopyToStream ROP.
            if (Common.IsRequirementEnabled(8670901, this.Site))
            {
                // Step 7: Send the RopCopyToStream request and verify the success response.
                #region RopCopyToStream success response

                RopCopyToStreamRequest  copyToStreamRequest;
                RopCopyToStreamResponse copyToStreamResponse;

                copyToStreamRequest.RopId             = (byte)RopId.RopCopyToStream;
                copyToStreamRequest.LogonId           = TestSuiteBase.LogonId;
                copyToStreamRequest.SourceHandleIndex = TestSuiteBase.SourceHandleIndex0;
                copyToStreamRequest.DestHandleIndex   = TestSuiteBase.DestHandleIndex;

                // Set ByteCount to a value less than the length of original property.
                copyToStreamRequest.ByteCount = TestSuiteBase.ByteCountForRopCopyToStream;

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

                // Send the RopCopyToStream request and verify the success response.
                this.responseSOHs = cropsAdapter.ProcessSingleRopWithMutipleServerObjects(
                    copyToStreamRequest,
                    handleList,
                    ref this.response,
                    ref this.rawData,
                    RopResponseType.SuccessResponse);
                copyToStreamResponse = (RopCopyToStreamResponse)response;

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

                // Verify MS-OXCROPS requirement: MS-OXCROPS_R8670901
                Site.CaptureRequirementIfAreEqual <uint>(
                    TestSuiteBase.SuccessReturnValue,
                    copyToStreamResponse.ReturnValue,
                    8670901,
                    @"[In Appendix A: Product Behavior] Implementation does implement the RopCopyToStream ROP. (Exchange 2007 and Exchange 2013 follows this behavior.)");

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

                #endregion

                // Step 8: Send the RopCopyToStream request and verify the null destination failure response.
                #region RopCopyToStream null destination failure response

                handleList.RemoveAt(1);

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

                this.responseSOHs = cropsAdapter.ProcessSingleRopWithMutipleServerObjects(
                    copyToStreamRequest,
                    handleList,
                    ref this.response,
                    ref this.rawData,
                    RopResponseType.NullDestinationFailureResponse);
                copyToStreamResponse = (RopCopyToStreamResponse)response;
                Site.Assert.AreEqual <uint>(
                    MS_OXCROPSAdapter.ReturnValueForRopMoveFolderResponseAndMoveCopyMessage,
                    copyToStreamResponse.ReturnValue,
                    "if ROP null destination failure, the ReturnValue of its response is 0x00000503");

                #endregion
            }
        }
Exemplo n.º 23
0
        public void MSOXCROPS_S07_TC02_TestRopsGetSetStreamSizeAndSeekStream()
        {
            this.CheckTransportIsSupported();

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

            // Step 1: Preparations-Create message and get its handle, open a stream and get its handle.
            #region Common operations for RopGetStreamSize,RopSetStreamSize and RopSeekStream

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

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 1:Call GetCreatedMessageHandle method to create a message and get its handle.");

            // Call GetCreatedMessageHandle method to create a message and get its handle.
            uint messageHandle = GetCreatedMessageHandle(logonResponse.FolderIds[4], inputObjHandle);

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 1:Call GetOpenedStreamHandle method to open stream and get its handle.");

            // Call GetOpenedStreamHandle method to open stream and get its handle.
            uint streamObjectHandle = this.GetOpenedStreamHandle(messageHandle);

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 1:Call WriteStream method to write stream.");

            // Call WriteStream method to write stream.
            this.WriteStream(streamObjectHandle);

            #endregion

            // Step 2: Send the RopGetStreamSize request and verify the success response.
            #region RopGetStreamSize success response

            RopGetStreamSizeRequest  getStreamSizeRequest;
            RopGetStreamSizeResponse getStreamSizeResponse;

            getStreamSizeRequest.RopId = (byte)RopId.RopGetStreamSize;

            getStreamSizeRequest.LogonId          = TestSuiteBase.LogonId;
            getStreamSizeRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

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

            // Send the RopGetStreamSize request and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                getStreamSizeRequest,
                streamObjectHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            getStreamSizeResponse = (RopGetStreamSizeResponse)response;
            Site.Assert.AreEqual <uint>(
                TestSuiteBase.SuccessReturnValue,
                getStreamSizeResponse.ReturnValue,
                "if ROP succeeds, the ReturnValue of its response is 0(success)");

            #endregion

            // Step 3: Send the RopGetStreamSize request and verify the failure response.
            #region RopGetStreamSize failure response

            getStreamSizeRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex1;

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                getStreamSizeRequest,
                streamObjectHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.FailureResponse);
            getStreamSizeResponse = (RopGetStreamSizeResponse)response;
            Site.Assert.AreNotEqual <uint>(
                TestSuiteBase.SuccessReturnValue,
                getStreamSizeResponse.ReturnValue,
                "if ROP failure, the ReturnValue of its response is not 0(success)");

            #endregion

            // Step 4: Send the RopSetStreamSize request and verify the success response.
            #region RopSetStreamSize Response

            RopSetStreamSizeRequest  setStreamSizeRequest;
            RopSetStreamSizeResponse setStreamSizeResponse;

            setStreamSizeRequest.RopId            = (byte)RopId.RopSetStreamSize;
            setStreamSizeRequest.LogonId          = TestSuiteBase.LogonId;
            setStreamSizeRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

            // Change the original stream size to 0x00000000000000FF.
            setStreamSizeRequest.StreamSize = TestSuiteBase.StreamSize;

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

            // Send the RopSetStreamSize request and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                setStreamSizeRequest,
                streamObjectHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            setStreamSizeResponse = (RopSetStreamSizeResponse)response;
            Site.Assert.AreEqual <uint>(
                TestSuiteBase.SuccessReturnValue,
                setStreamSizeResponse.ReturnValue,
                "if ROP succeeds, the ReturnValue of its response is 0(success)");

            #endregion

            // Step 5: Send the RopSeekStream request and verify the success response.
            #region RopSeekStream success response

            RopSeekStreamRequest  seekStreamRequest;
            RopSeekStreamResponse seekStreamResponse;

            seekStreamRequest.RopId            = (byte)RopId.RopSeekStream;
            seekStreamRequest.LogonId          = TestSuiteBase.LogonId;
            seekStreamRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            seekStreamRequest.Origin           = (byte)Origin.Beginning;

            // Defined by tester, less than the stream size.
            seekStreamRequest.Offset = TestSuiteBase.Offset;

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

            // Send the RopSeekStream request and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                seekStreamRequest,
                streamObjectHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            seekStreamResponse = (RopSeekStreamResponse)response;
            Site.Assert.AreEqual <uint>(
                TestSuiteBase.SuccessReturnValue,
                seekStreamResponse.ReturnValue,
                "if ROP succeeds, the ReturnValue of its response is 0(success)");

            #endregion

            // Step 6: Send the RopSeekStream request and verify the failure response.
            #region RopSeekStream failure response

            seekStreamRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex1;

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                seekStreamRequest,
                streamObjectHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.FailureResponse);
            seekStreamResponse = (RopSeekStreamResponse)response;
            Site.Assert.AreNotEqual <uint>(
                TestSuiteBase.SuccessReturnValue,
                seekStreamResponse.ReturnValue,
                "if ROP failure, the ReturnValue of its response is not 0(success)");

            #endregion
        }
        public void MSOXCMSG_S09_TC03_Transaction()
        {
            this.CheckMapiHttpIsSupported();
            this.ConnectToServer(ConnectionType.PrivateMailboxServer);

            // Set property size
            int size = 0;

            TaggedPropertyValue[] taggedPropertyValueArray = this.CreateMessageTaggedPropertyValueArrays(out size, PidTagAttachMethodFlags.afEmbeddedMessage);

            #region Call RopLogon to log on a mailbox.
            RopLogonResponse logonResponse = this.Logon(LogonType.Mailbox, out this.insideObjHandle);
            #endregion

            #region Call RopCreateMessage to create a message.
            uint targetMessageHandle = this.CreatedMessage(logonResponse.FolderIds[4], this.insideObjHandle);
            #endregion

            #region Call RopSaveChangesMessage to save the newly created message.
            RopSaveChangesMessageResponse saveChangesMessageResponse;
            saveChangesMessageResponse = this.SaveMessage(targetMessageHandle, (byte)SaveFlags.ForceSave);
            #endregion

            #region Call RopOpenMessage to open the message.
            RopOpenMessageResponse openMessageResponse;
            uint openedMessageHandle = this.OpenSpecificMessage(logonResponse.FolderIds[4], saveChangesMessageResponse.MessageId, this.insideObjHandle, MessageOpenModeFlags.ReadWrite, out openMessageResponse);
            Site.Assert.AreEqual <uint>(TestSuiteBase.Success, openMessageResponse.ReturnValue, TestSuiteBase.ROPSucceedMsg);
            #endregion

            #region Call RopCreateAttachment to create an embedded attachment.
            RopCreateAttachmentResponse createAttachmentResponse;
            uint attachmentId;
            uint attachmentHandle = this.CreateAttachment(openedMessageHandle, out createAttachmentResponse, out attachmentId);
            #endregion

            #region Call RopSetProperties to set PidTagAttachMethod property, that is the attachment is the embedded attachment.
            // Setting PidTagAttachMethod property means the attachment is the embedded message
            RopSetPropertiesRequest setPropertiesRequest = new RopSetPropertiesRequest()
            {
                RopId              = (byte)RopId.RopSetProperties,
                LogonId            = CommonLogonId,          // The logonId 0x00 is associated with RopSetProperties.
                InputHandleIndex   = CommonInputHandleIndex, // This index specifies the location 0x00 in the Server Object Handle Table where the handle for the input Server Object is stored.
                PropertyValueSize  = (ushort)(size + 2),
                PropertyValueCount = (ushort)taggedPropertyValueArray.Length,
                PropertyValues     = taggedPropertyValueArray
            };
            this.ResponseSOHs = this.MSOXCMSGAdapter.DoRopCall(setPropertiesRequest, attachmentHandle, ref this.response, ref this.rawData, GetPropertiesFlags.None);
            RopSetPropertiesResponse setPropertiesResponse = (RopSetPropertiesResponse)this.response;
            Site.Assert.AreEqual <uint>(TestSuiteBase.Success, setPropertiesResponse.ReturnValue, TestSuiteBase.ROPSucceedMsg);
            #endregion

            #region Call RopSaveChangesAttachment to save the attachment changes
            RopSaveChangesAttachmentResponse saveChangesAttachmentResponse;
            this.SaveAttachment(attachmentHandle, out saveChangesAttachmentResponse);
            #endregion

            #region Call RopOpenEmbeddedMessage with OpenModeFlags set to 0x02 to create an embedded message.
            RopOpenEmbeddedMessageRequest openEmbeddedMessageRequest = new RopOpenEmbeddedMessageRequest()
            {
                RopId             = (byte)RopId.RopOpenEmbeddedMessage,
                LogonId           = CommonLogonId,           // The logonId 0x00 is associated with RopOpenEmbeddedMessage.
                InputHandleIndex  = CommonInputHandleIndex,  // This index specifies the location 0x00 in the Server Object Handle Table where the handle for the input Server Object is stored.
                OutputHandleIndex = CommonOutputHandleIndex, // This index specifies the location 0x01 in the Server Object Handle Table where the handle for the output Server Object is stored.
                CodePageId        = 0x0FFF,                  // Code page of Logon object is used
                OpenModeFlags     = 0x02                     // Create the attachment if it does not already exist and open the message for both reading and writing
            };
            this.ResponseSOHs = this.MSOXCMSGAdapter.DoRopCall(openEmbeddedMessageRequest, attachmentHandle, ref this.response, ref this.rawData, GetPropertiesFlags.None);
            RopOpenEmbeddedMessageResponse openEmbeddedMessageResponse = (RopOpenEmbeddedMessageResponse)this.response;
            uint embeddedMessageHandle = this.ResponseSOHs[0][openMessageResponse.OutputHandleIndex];
            Site.Assert.AreEqual <uint>(TestSuiteBase.Success, openEmbeddedMessageResponse.ReturnValue, TestSuiteBase.ROPSucceedMsg);
            #endregion

            #region Call RopOpenEmbeddedMessage with OpenModeFlags set to 0x01 to open the embedded message which is created in step 9 and expect a failure response
            RopOpenEmbeddedMessageResponse openEmbeddedMessageResponseFirst;
            openEmbeddedMessageRequest.OpenModeFlags = 0x01; // Try to open the embedded message as read/write.
            this.ResponseSOHs = this.MSOXCMSGAdapter.DoRopCall(openEmbeddedMessageRequest, attachmentHandle, ref this.response, ref this.rawData, GetPropertiesFlags.None);
            openEmbeddedMessageResponseFirst = (RopOpenEmbeddedMessageResponse)this.response;
            #endregion

            #region Call RopSaveChangesMessage to save the embedded message created in step 9.
            saveChangesMessageResponse = this.SaveMessage(embeddedMessageHandle, (byte)SaveFlags.ForceSave);
            #endregion

            #region Call ReleaseRop to release the embedded message created in step 9.
            this.ReleaseRop(embeddedMessageHandle);
            #endregion

            #region Call RopOpenEmbeddedMessage with OpenModeFlags set to 0x01 to open the embedded message which is created in step 9 and expect a successful response.
            RopOpenEmbeddedMessageResponse openEmbeddedMessageResponseSecond;
            openEmbeddedMessageRequest.OpenModeFlags = 0x01; // Try to open the embedded message as read/write.
            this.ResponseSOHs = this.MSOXCMSGAdapter.DoRopCall(openEmbeddedMessageRequest, attachmentHandle, ref this.response, ref this.rawData, GetPropertiesFlags.None);
            openEmbeddedMessageResponseSecond = (RopOpenEmbeddedMessageResponse)this.response;
            #endregion

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMSG_R481. The return value of RopOpenEmbeddedMessage before calling RopSaveChangesMessage is {0}, the return value of RopOpenEmbeddedMessage after calling RopSaveChangesMessage is {1}.", openEmbeddedMessageResponseFirst.ReturnValue, openEmbeddedMessageResponseSecond.ReturnValue);

            // Verify MS-OXCMSG requirement: MS-OXCMSG_R481
            bool isVerifiedR481 = openEmbeddedMessageResponseFirst.ReturnValue != TestSuiteBase.Success && openEmbeddedMessageResponseSecond.ReturnValue == TestSuiteBase.Success;

            // The server doesn't commit the Message object to the containing Attachment object until the RopSaveChangesMessage ROP is called if isVerifiedR481 is true, then MS-OXCMSG_R481 can be verified.
            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR481,
                481,
                @"[In Receiving a RopOpenEmbeddedMessage ROP Request] The server MUST NOT commit the Message object to the containing Attachment object until the RopSaveChangesMessage ROP ([MS-OXCROPS] section 2.2.6.3) is called with the Embedded Message object's handle.");

            #region Call RopRelease to release the message created in step 2.
            this.ReleaseRop(targetMessageHandle);
            #endregion
        }
Exemplo n.º 25
0
        public void MSOXCROPS_S07_TC03_TestRopsLockAndUnlockRegionStream()
        {
            this.CheckTransportIsSupported();

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

            // Step 1: Preparations-Create message and get its handle, open stream and get its handle.
            #region Common operations for RopLockRegionStream and RopUnlockRegionStream

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

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 1:Call GetCreatedMessageHandle method to create message and get its handle.");

            // Call GetCreatedMessageHandle method to create message and get its handle.
            uint messageHandle = GetCreatedMessageHandle(logonResponse.FolderIds[4], inputObjHandle);

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 1:Call GetOpenedStreamHandle method to open stream and get its handle.");

            // Call GetOpenedStreamHandle method to open stream and get its handle.
            uint streamObjectHandle = this.GetOpenedStreamHandle(messageHandle);

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 1:Call WriteStream method to write stream.");

            // Call WriteStream method to write stream.
            this.WriteStream(streamObjectHandle);

            #endregion

            // Refer to MS-OXCPRPT: Exchange 2003 and Exchange 2007 implement the RopLockRegionStream ROP.
            if (Common.IsRequirementEnabled(750001, this.Site))
            {
                // Step 2: Send the RopLockRegionStream request and verify the success response.
                #region RopLockRegionStream Response

                RopLockRegionStreamRequest  lockRegionStreamRequest = new RopLockRegionStreamRequest();
                RopLockRegionStreamResponse lockRegionStreamResponse;

                lockRegionStreamRequest.RopId = (byte)RopId.RopLockRegionStream;

                lockRegionStreamRequest.LogonId          = TestSuiteBase.LogonId;
                lockRegionStreamRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
                lockRegionStreamRequest.RegionOffset     = TestSuiteBase.RegionOffset;

                // Defined by tester, less than the stream size.
                lockRegionStreamRequest.RegionSize = TestSuiteBase.RegionSize;

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

                // Send the RopLockRegionStream request and verify the failure response.
                this.responseSOHs = cropsAdapter.ProcessSingleRop(
                    lockRegionStreamRequest,
                    streamObjectHandle,
                    ref this.response,
                    ref this.rawData,
                    RopResponseType.SuccessResponse);
                lockRegionStreamResponse = (RopLockRegionStreamResponse)response;

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

                // Verify MS-OXCROPS requirement: MS-OXCROPS_R750001
                Site.CaptureRequirementIfAreEqual <uint>(
                    TestSuiteBase.SuccessReturnValue,
                    lockRegionStreamResponse.ReturnValue,
                    750001,
                    @"[In Appendix A: Product Behavior] Implementation does implement the RopLockRegionStream ROP. (Exchange 2007 follows this behavior.)");

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

                #endregion
            }

            // Refer to MS-OXCPRPT: Exchange 2003 and Exchange 2007 implement the RopUnlockRegionStream ROP.
            if (Common.IsRequirementEnabled(751001, this.Site))
            {
                // Step 3: Send the RopUnlockRegionStream request and verify the success response.
                #region RopUnlockRegionStream response

                RopUnlockRegionStreamRequest  unlockRegionStreamRequest = new RopUnlockRegionStreamRequest();
                RopUnlockRegionStreamResponse unlockRegionStreamResponse;

                unlockRegionStreamRequest.RopId            = (byte)RopId.RopUnlockRegionStream;
                unlockRegionStreamRequest.LogonId          = TestSuiteBase.LogonId;
                unlockRegionStreamRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

                // Beginning of the stream.
                unlockRegionStreamRequest.RegionOffset = TestSuiteBase.RegionOffset;

                // Defined by tester, less than the stream size.
                unlockRegionStreamRequest.RegionSize = TestSuiteBase.RegionSize;

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

                // Step 4: Send the RopUnlockRegionStream request and verify the success response.
                this.responseSOHs = cropsAdapter.ProcessSingleRop(
                    unlockRegionStreamRequest,
                    streamObjectHandle,
                    ref this.response,
                    ref this.rawData,
                    RopResponseType.SuccessResponse);
                unlockRegionStreamResponse = (RopUnlockRegionStreamResponse)response;

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

                // Verify MS-OXCROPS requirement: MS-OXCROPS_R751001
                Site.CaptureRequirementIfAreEqual <uint>(
                    TestSuiteBase.SuccessReturnValue,
                    unlockRegionStreamResponse.ReturnValue,
                    751001,
                    @"[In Appendix A: Product Behavior] Implementation does implement the RopUnlockRegionStream ROP. (Exchange 2007 follows this behavior.)");

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

                #endregion
            }
        }
        public void MSOXCROPS_S10_TC03_TestRopFastTransferDestinationPutBuffer()
        {
            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 RopOpenFolder request to OpenFolder
            #region RopOpenFolder success response

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

            // Open a folder first, then create a subfolder under the opened folder
            RopOpenFolderRequest  openFolderRequest;
            RopOpenFolderResponse openFolderResponse;

            openFolderRequest.RopId = (byte)RopId.RopOpenFolder;

            openFolderRequest.LogonId           = TestSuiteBase.LogonId;
            openFolderRequest.InputHandleIndex  = TestSuiteBase.InputHandleIndex0;
            openFolderRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;
            openFolderRequest.FolderId          = logonResponse.FolderIds[4];
            openFolderRequest.OpenModeFlags     = (byte)FolderOpenModeFlags.None;

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                openFolderRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            openFolderResponse = (RopOpenFolderResponse)response;
            Site.Assert.AreEqual <uint>(
                TestSuiteBase.SuccessReturnValue,
                openFolderResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0 (success)");

            // This handle will be used as input handle in RopCreateFolder
            uint openedFolderHandle = responseSOHs[0][openFolderResponse.OutputHandleIndex];

            #endregion

            // Step 2: Send the RopCreateFolder request to create a subfolder under the opened folder
            #region RopCreateFolder success response

            // Create a subfolder in opened folder
            RopCreateFolderRequest  createFolderRequest;
            RopCreateFolderResponse createFolderResponse;

            createFolderRequest.RopId             = (byte)RopId.RopCreateFolder;
            createFolderRequest.LogonId           = TestSuiteBase.LogonId;
            createFolderRequest.InputHandleIndex  = TestSuiteBase.InputHandleIndex0;
            createFolderRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;
            createFolderRequest.FolderType        = (byte)FolderType.Genericfolder;

            // Set UseUnicodeStrings to 0x0(FALSE), which specifies the DisplayName and Comment are not specified in Unicode.
            createFolderRequest.UseUnicodeStrings = Convert.ToByte(TestSuiteBase.Zero);

            // Set OpenExisting to 0xFF, which means the folder being created will be opened when it is already existed.
            createFolderRequest.OpenExisting = TestSuiteBase.NonZero;

            createFolderRequest.Reserved    = TestSuiteBase.Reserved;
            createFolderRequest.DisplayName = Encoding.ASCII.GetBytes(TestSuiteBase.DisplayNameAndCommentForNonSearchFolder + "\0");
            createFolderRequest.Comment     = Encoding.ASCII.GetBytes(TestSuiteBase.DisplayNameAndCommentForNonSearchFolder + "\0");

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                createFolderRequest,
                openedFolderHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            createFolderResponse = (RopCreateFolderResponse)response;
            Site.Assert.AreEqual <uint>(
                TestSuiteBase.SuccessReturnValue,
                createFolderResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0 (success)");
            uint targetFolderHandle = responseSOHs[0][createFolderResponse.OutputHandleIndex];

            #endregion

            // Step 3: Send the RopFastTransferDestinationConfigure request to verify success response
            #region RopFastTransferDestinationConfigure success response

            RopFastTransferDestinationConfigureRequest  fastTransferDestinationConfigureRequest;
            RopFastTransferDestinationConfigureResponse fastTransferDestinationConfigureResponse;

            fastTransferDestinationConfigureRequest.RopId             = (byte)RopId.RopFastTransferDestinationConfigure;
            fastTransferDestinationConfigureRequest.LogonId           = TestSuiteBase.LogonId;
            fastTransferDestinationConfigureRequest.InputHandleIndex  = TestSuiteBase.InputHandleIndex0;
            fastTransferDestinationConfigureRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;
            fastTransferDestinationConfigureRequest.SourceOperation   = (byte)SourceOperation.CopyTo;

            // The client identifies the FastTransfer operation being configured as a logical part of a larger object move operation
            fastTransferDestinationConfigureRequest.CopyFlags = (byte)RopFastTransferDestinationConfigureCopyFlags.Move;

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                fastTransferDestinationConfigureRequest,
                targetFolderHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            fastTransferDestinationConfigureResponse = (RopFastTransferDestinationConfigureResponse)response;

            Site.Assert.AreEqual <uint>(
                TestSuiteBase.SuccessReturnValue,
                fastTransferDestinationConfigureResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0 (success)");
            uint fastTranferUploadContextHandle = responseSOHs[0][fastTransferDestinationConfigureResponse.OutputHandleIndex];

            #endregion

            // Step 4: Send the RopFastTransferDestinationPutBuffer request to verify success response
            #region RopFastTransferDestinationPutBuffer success response

            RopFastTransferDestinationPutBufferRequest fastTransferDestinationPutBufferRequest;

            // Set to a marker value (StartTopFld) refer to the table in MS-OXCFXICS.
            byte[] transferData = { 0x03, 0x00, 0x09, 0x40 };
            fastTransferDestinationPutBufferRequest.RopId            = (byte)RopId.RopFastTransferDestinationPutBuffer;
            fastTransferDestinationPutBufferRequest.LogonId          = TestSuiteBase.LogonId;
            fastTransferDestinationPutBufferRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            fastTransferDestinationPutBufferRequest.TransferDataSize = (ushort)transferData.Length;
            fastTransferDestinationPutBufferRequest.TransferData     = transferData;

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                fastTransferDestinationPutBufferRequest,
                fastTranferUploadContextHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);

            #endregion
        }
Exemplo n.º 27
0
        public void MSOXCROPS_S07_TC05_TestRopWriteStreamExtended()
        {
            this.CheckTransportIsSupported();
            if (Common.IsRequirementEnabled(3256018, this.Site))
            {
                this.cropsAdapter.RpcConnect(
                    Common.GetConfigurationPropertyValue("SutComputerName", this.Site),
                    ConnectionType.PrivateMailboxServer,
                    Common.GetConfigurationPropertyValue("UserEssdn", this.Site),
                    Common.GetConfigurationPropertyValue("Domain", this.Site),
                    Common.GetConfigurationPropertyValue("AdminUserName", this.Site),
                    Common.GetConfigurationPropertyValue("PassWord", this.Site));

                // Step 1: Preparations-Create message and then open a stream.
                #region Common operations for RopReadStream,RopWriteStreamExtended,RopCommitStream and RopWriteAndCommitStream

                // Common variable for RopWriteStream and RopWriteAndCommitStream.
                byte[] data = Encoding.ASCII.GetBytes(SampleStreamData + "\0");

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

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Step 1:Call GetCreatedMessageHandle method to create a message.");

                // Create a message.
                uint messageHandle = GetCreatedMessageHandle(logonResponse.FolderIds[4], inputObjHandle);

                // Test RopOpenStream success response.
                #region Test RopOpenStream success response

                RopOpenStreamRequest  openStreamRequest;
                RopOpenStreamResponse openStreamResponse;

                // Client defines a new property.
                PropertyTag tag;
                tag.PropertyId   = TestSuiteBase.UserDefinedPropertyId;
                tag.PropertyType = (ushort)PropertyType.PtypString;

                openStreamRequest.RopId = (byte)RopId.RopOpenStream;

                openStreamRequest.LogonId           = TestSuiteBase.LogonId;
                openStreamRequest.InputHandleIndex  = TestSuiteBase.InputHandleIndex0;
                openStreamRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;
                openStreamRequest.PropertyTag       = tag;
                openStreamRequest.OpenModeFlags     = (byte)StreamOpenModeFlags.Create;

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

                // Send the RopOpenStream request and verify success response.
                this.responseSOHs = cropsAdapter.ProcessSingleRop(
                    openStreamRequest,
                    messageHandle,
                    ref this.response,
                    ref this.rawData,
                    RopResponseType.SuccessResponse);
                openStreamResponse = (RopOpenStreamResponse)response;
                Site.Assert.AreEqual <uint>(
                    TestSuiteBase.SuccessReturnValue,
                    openStreamResponse.ReturnValue,
                    "if ROP succeeds, the ReturnValue of its response is 0(success)");
                uint streamObjectHandle = responseSOHs[0][openStreamResponse.OutputHandleIndex];

                #endregion
                #endregion

                // Step 2: Send the RopWriteStreamExtended request and verify the success response.
                #region RopWriteStreamExtended Response
                RopWriteStreamExtendedRequest  writeStreamExtendedRequest;
                RopWriteStreamExtendedResponse writeStreamExtendedResponse;

                writeStreamExtendedRequest.RopId            = (byte)RopId.RopWriteStreamExtended;
                writeStreamExtendedRequest.LogonId          = TestSuiteBase.LogonId;
                writeStreamExtendedRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
                writeStreamExtendedRequest.DataSize         = (ushort)data.Length;
                writeStreamExtendedRequest.Data             = data;

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

                // Send the RopWriteStreamExtended request and verify the success response.
                this.responseSOHs = cropsAdapter.ProcessSingleRop(
                    writeStreamExtendedRequest,
                    streamObjectHandle,
                    ref this.response,
                    ref this.rawData,
                    RopResponseType.SuccessResponse);
                writeStreamExtendedResponse = (RopWriteStreamExtendedResponse)response;
                Site.Assert.AreEqual <uint>(
                    TestSuiteBase.SuccessReturnValue,
                    writeStreamExtendedResponse.ReturnValue,
                    "if ROP succeeds, the ReturnValue of its response is 0(success)");

                #endregion

                // Step 3: Send the RopCommitStream request and verify the success response.
                #region RopCommitStream Response

                RopCommitStreamRequest  commitStreamRequest;
                RopCommitStreamResponse commitStreamResponse;

                commitStreamRequest.RopId            = (byte)RopId.RopCommitStream;
                commitStreamRequest.LogonId          = TestSuiteBase.LogonId;
                commitStreamRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

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

                // Send the RopCommitStream request and verify the success response.
                this.responseSOHs = cropsAdapter.ProcessSingleRop(
                    commitStreamRequest,
                    streamObjectHandle,
                    ref this.response,
                    ref this.rawData,
                    RopResponseType.SuccessResponse);
                commitStreamResponse = (RopCommitStreamResponse)response;
                Site.Assert.AreEqual <uint>(
                    TestSuiteBase.SuccessReturnValue,
                    commitStreamResponse.ReturnValue,
                    "if ROP succeeds, the ReturnValue of its response is 0(success)");

                #endregion
            }
            else
            {
                Site.Assert.Inconclusive("Exchange Server 2010 does not support RopWriteStreamExtended ROP.");
            }
        }
        public void MSOXCROPS_S10_TC01_TestRopFastTransferSourceCopyMessages()
        {
            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 RopCreateMessage request to create a message
            #region RopCreateMessage success response

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

            // Create a message
            RopCreateMessageRequest  createMessageRequest = new RopCreateMessageRequest();
            RopCreateMessageResponse createMessageResponse;
            createMessageRequest.RopId = (byte)RopId.RopCreateMessage;

            createMessageRequest.LogonId           = TestSuiteBase.LogonId;
            createMessageRequest.InputHandleIndex  = TestSuiteBase.InputHandleIndex0;
            createMessageRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;

            // Set CodePageId to 0x0FFF, which specified the code page of Logon object will be used.
            createMessageRequest.CodePageId = TestSuiteBase.CodePageId;

            // Create a message in INBOX
            createMessageRequest.FolderId = logonResponse.FolderIds[4];

            // Set AssociatedFlag to 0x00(FALSE), which specifies the message is not a folder associated information (FAI) message.
            createMessageRequest.AssociatedFlag = Convert.ToByte(TestSuiteBase.Zero);

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                createMessageRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            createMessageResponse = (RopCreateMessageResponse)response;
            Site.Assert.AreEqual <uint>(
                TestSuiteBase.SuccessReturnValue,
                createMessageResponse.ReturnValue,
                "if ROP succeeds, the ReturnValue of its response is 0(success)");
            uint targetMessageHandle = responseSOHs[0][createMessageResponse.OutputHandleIndex];

            #endregion

            // Step 2: Send the RopSaveChangesMessage request to save changes
            #region RopSaveChangesMessage success response

            // Save message
            RopSaveChangesMessageRequest  saveChangesMessageRequest;
            RopSaveChangesMessageResponse saveChangesMessageResponse;
            saveChangesMessageRequest.RopId               = (byte)RopId.RopSaveChangesMessage;
            saveChangesMessageRequest.LogonId             = TestSuiteBase.LogonId;
            saveChangesMessageRequest.InputHandleIndex    = TestSuiteBase.InputHandleIndex0;
            saveChangesMessageRequest.ResponseHandleIndex = TestSuiteBase.ResponseHandleIndex1;
            saveChangesMessageRequest.SaveFlags           = (byte)SaveFlags.ForceSave;

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                saveChangesMessageRequest,
                targetMessageHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            saveChangesMessageResponse = (RopSaveChangesMessageResponse)response;
            Site.Assert.AreEqual <uint>(
                TestSuiteBase.SuccessReturnValue,
                saveChangesMessageResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0 (success).");
            ulong messageId = saveChangesMessageResponse.MessageId;

            #endregion

            // Step 3: Send the RopOpenFolder request to open folder containing created message
            #region RopOpenFoldersuccess response

            // Open the folder(Inbox) containing the created message
            RopOpenFolderRequest  openFolderRequest;
            RopOpenFolderResponse openFolderResponse;

            openFolderRequest.RopId             = (byte)RopId.RopOpenFolder;
            openFolderRequest.LogonId           = TestSuiteBase.LogonId;
            openFolderRequest.InputHandleIndex  = TestSuiteBase.InputHandleIndex0;
            openFolderRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;

            // Inbox will be opened
            openFolderRequest.FolderId = logonResponse.FolderIds[4];

            openFolderRequest.OpenModeFlags = (byte)FolderOpenModeFlags.None;

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                openFolderRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            openFolderResponse = (RopOpenFolderResponse)response;
            Site.Assert.AreEqual <uint>(
                TestSuiteBase.SuccessReturnValue,
                openFolderResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0 (success).");
            uint folderHandle = responseSOHs[0][openFolderResponse.OutputHandleIndex];

            ulong[] messageIds = new ulong[1];
            messageIds[0] = messageId;

            #endregion

            // Step 4: Send the RopFastTransferSourceCopyMessages request to verify success response
            #region RopFastTransferSourceCopyMessages success response

            RopFastTransferSourceCopyMessagesRequest  fastTransferSourceCopyMessagesRequest;
            RopFastTransferSourceCopyMessagesResponse fastTransferSourceCopyMessagesResponse;

            fastTransferSourceCopyMessagesRequest.RopId             = (byte)RopId.RopFastTransferSourceCopyMessages;
            fastTransferSourceCopyMessagesRequest.LogonId           = TestSuiteBase.LogonId;
            fastTransferSourceCopyMessagesRequest.InputHandleIndex  = TestSuiteBase.InputHandleIndex0;
            fastTransferSourceCopyMessagesRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;
            fastTransferSourceCopyMessagesRequest.MessageIdCount    = (ushort)messageIds.Length;
            fastTransferSourceCopyMessagesRequest.MessageIds        = messageIds;
            fastTransferSourceCopyMessagesRequest.CopyFlags         = (byte)RopFastTransferSourceCopyMessagesCopyFlags.BestBody;
            fastTransferSourceCopyMessagesRequest.SendOptions       = (byte)SendOptions.ForceUnicode;

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                fastTransferSourceCopyMessagesRequest,
                folderHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            fastTransferSourceCopyMessagesResponse = (RopFastTransferSourceCopyMessagesResponse)response;

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

            #endregion
        }