示例#1
0
        /// <summary>
        /// This ROP opens an existing message in a mailbox.
        /// </summary>
        /// <param name="handle">The handle to operate</param>
        /// <param name="folderId">The parent folder of the message to be opened.</param>
        /// <param name="messageId">The identifier of the message to be opened.</param>
        /// <param name="openMessageResponse">The response of this ROP.</param>
        /// <param name="needVerify">Whether need to verify the response</param>
        /// <returns>The handle of the opened message</returns>
        private uint RopOpenMessage(uint handle, ulong folderId, ulong messageId, out RopOpenMessageResponse openMessageResponse, bool needVerify)
        {
            this.rawDataValue      = null;
            this.responseValue     = null;
            this.responseSOHsValue = null;

            RopOpenMessageRequest openMessageRequest = new RopOpenMessageRequest()
            {
                RopId             = (byte)RopId.RopOpenMessage,
                LogonId           = LogonId,
                InputHandleIndex  = (byte)HandleIndex.FirstIndex,
                OutputHandleIndex = (byte)HandleIndex.SecondIndex,

                // Set CodePageId to SameAsLogonObject, which indicates it uses the same code page as the one for logon object.
                CodePageId = (ushort)CodePageId.SameAsLogonObject,
                FolderId   = folderId,

                // Set OpenModeFlags to read and write for further operation.
                OpenModeFlags = (byte)MessageOpenModeFlags.ReadWrite,
                MessageId     = messageId
            };

            this.responseSOHsValue = this.ProcessSingleRop(openMessageRequest, handle, ref this.responseValue, ref this.rawDataValue, RopResponseType.SuccessResponse);
            openMessageResponse    = (RopOpenMessageResponse)this.responseValue;
            if (needVerify)
            {
                this.Site.Assert.AreEqual((uint)RopResponseType.SuccessResponse, openMessageResponse.ReturnValue, string.Format("RopOpenMessageResponse Failed! Error: 0x{0:X8}", openMessageResponse.ReturnValue));
            }

            return(this.responseSOHsValue[0][openMessageResponse.OutputHandleIndex]);
        }
示例#2
0
        /// <summary>
        /// Verify whether the specified message in specified folder was deleted.
        /// </summary>
        /// <param name="messageId">The specified message ID.</param>
        /// <param name="folderId">The specified folder ID.</param>
        /// <returns>Return a Boolean value indicates whether the specified message was deleted.</returns>
        protected bool IsMessageDeleted(ulong messageId, ulong folderId)
        {
            bool isMessageDeleted = false;

            RopOpenMessageResponse openMessageResponse = this.OpenMessage(messageId, folderId, MessageOpenModeFlags.BestAccess);

            if (openMessageResponse.ReturnValue == 0x8004010F)
            {
                isMessageDeleted = true;
            }

            return(isMessageDeleted);
        }
示例#3
0
        /// <summary>
        /// Send ROP request with single operation.
        /// </summary>
        /// <param name="ropRequest">ROP request objects.</param>
        /// <param name="insideObjHandle">Server object handle in request.</param>
        /// <param name="response">ROP response objects.</param>
        /// <param name="rawData">The ROP response payload.</param>
        /// <param name="getPropertiesFlag">The flag indicate the test cases expect to get which object type's properties(message's properties or attachment's properties).</param>
        /// <param name="returnValue">An unsigned integer value indicates the return value of call EcDoRpcExt2 method.</param>
        /// <returns>Server objects handles in response.</returns>
        public List <List <uint> > DoRopCall(ISerializable ropRequest, uint insideObjHandle, ref object response, ref byte[] rawData, GetPropertiesFlags getPropertiesFlag, out uint returnValue)
        {
            List <ISerializable> requestRops = new List <ISerializable>
            {
                ropRequest
            };

            List <uint> requestSOH = new List <uint>
            {
                insideObjHandle
            };

            if (Common.IsOutputHandleInRopRequest(ropRequest))
            {
                // Add an element for server output object handle, set default value to 0xFFFFFFFF
                requestSOH.Add(DefaultOutputHandle);
            }

            List <IDeserializable> responseRops = new List <IDeserializable>();
            List <List <uint> >    responseSOHs = new List <List <uint> >();

            // 0x10008 specifies the maximum size of the rgbOut buffer to place in Response.
            uint ret = this.oxcropsClient.RopCall(requestRops, requestSOH, ref responseRops, ref responseSOHs, ref rawData, 0x10008);

            returnValue = ret;
            if (ret == OxcRpcErrorCode.ECRpcFormat)
            {
                this.Site.Assert.Fail("Error RPC Format");
            }

            if (ret != 0)
            {
                return(responseSOHs);
            }

            if (responseRops != null)
            {
                if (responseRops.Count > 0)
                {
                    response = responseRops[0];
                }
            }
            else
            {
                response = null;
            }

            if (ropRequest.GetType() == typeof(RopReleaseRequest))
            {
                return(responseSOHs);
            }

            byte ropId = (byte)BitConverter.ToInt16(ropRequest.Serialize(), 0);

            List <PropertyObj> pts = null;

            switch (ropId)
            {
            case (byte)RopId.RopOpenMessage:
                RopOpenMessageResponse openMessageResponse = (RopOpenMessageResponse)response;

                // This check is for the open specification expectation for a particular request with some valid input parameters.
                if (openMessageResponse.ReturnValue == 0x00000000)
                {
                    this.VerifyRopOpenMessageResponse(openMessageResponse);
                }

                break;

            case (byte)RopId.RopGetPropertiesSpecific:
                // RopGetPropertiesSpecificRequest
                pts = PropertyHelper.GetPropertyObjFromBuffer(((RopGetPropertiesSpecificRequest)ropRequest).PropertyTags, (RopGetPropertiesSpecificResponse)response);

                foreach (PropertyObj pitem in pts)
                {
                    // Verify capture code for MS-OXCMSG.
                    this.VerifyMessageSyntaxDataType(pitem);
                }

                PropertyObj propertyObjPidTagSubjectPrefix     = PropertyHelper.GetPropertyByName(pts, PropertyNames.PidTagSubjectPrefix);
                PropertyObj propertyObjPidTagNormalizedSubject = PropertyHelper.GetPropertyByName(pts, PropertyNames.PidTagNormalizedSubject);

                // Verify the message of PidTagSubjectPrefixAndPidTagNormalizedSubject
                if (PropertyHelper.IsPropertyValid(propertyObjPidTagSubjectPrefix) || PropertyHelper.IsPropertyValid(propertyObjPidTagNormalizedSubject))
                {
                    this.VerifyMessageSyntaxPidTagSubjectPrefixAndPidTagNormalizedSubject(propertyObjPidTagSubjectPrefix, propertyObjPidTagNormalizedSubject);
                }

                // Verify the requirements of PidTagAttachmentLinkId and PidTagAttachmentFlags.
                PropertyObj pidTagAttachmentLinkId = PropertyHelper.GetPropertyByName(pts, PropertyNames.PidTagAttachmentLinkId);
                if (PropertyHelper.IsPropertyValid(pidTagAttachmentLinkId))
                {
                    this.VerifyMessageSyntaxPidTagAttachmentLinkIdAndPidTagAttachmentFlags(pidTagAttachmentLinkId);
                }

                PropertyObj pidTagAttachmentFlags = PropertyHelper.GetPropertyByName(pts, PropertyNames.PidTagAttachmentFlags);
                if (PropertyHelper.IsPropertyValid(pidTagAttachmentFlags))
                {
                    this.VerifyMessageSyntaxPidTagAttachmentLinkIdAndPidTagAttachmentFlags(pidTagAttachmentFlags);
                }

                // Verify the requirements of PidTagDisplayName
                PropertyObj pidTagDisplayName        = PropertyHelper.GetPropertyByName(pts, PropertyNames.PidTagDisplayName);
                PropertyObj pidTagAttachLongFilename = PropertyHelper.GetPropertyByName(pts, PropertyNames.PidTagAttachLongFilename);

                if (PropertyHelper.IsPropertyValid(pidTagDisplayName) && PropertyHelper.IsPropertyValid(pidTagAttachLongFilename))
                {
                    this.VerifyMessageSyntaxPidTagDisplayName(pidTagDisplayName, pidTagAttachLongFilename);
                }

                break;

            case (byte)RopId.RopGetPropertiesAll:
                RopGetPropertiesAllResponse getPropertiesAllResponse = (RopGetPropertiesAllResponse)response;
                pts = PropertyHelper.GetPropertyObjFromBuffer(getPropertiesAllResponse);

                foreach (PropertyObj pitem in pts)
                {
                    // Verify capture code for MS-OXCMSG.
                    this.VerifyMessageSyntaxDataType(pitem);
                }

                // Verify the requirements of PidTagArchiveDate
                PropertyObj pidTagArchiveDateObj = PropertyHelper.GetPropertyByName(pts, PropertyNames.PidTagArchiveDate);
                PropertyObj pidTagStartDateEtc   = PropertyHelper.GetPropertyByName(pts, PropertyNames.PidTagStartDateEtc);

                if (PropertyHelper.IsPropertyValid(pidTagArchiveDateObj))
                {
                    if (PropertyHelper.IsPropertyValid(pidTagStartDateEtc))
                    {
                        byte[] byteDest = new byte[8];
                        Array.Copy((byte[])pidTagStartDateEtc.Value, 6, byteDest, 0, 8);
                        this.VerifyMessageSyntaxPidTagArchiveDate(pidTagArchiveDateObj, DateTime.FromFileTimeUtc(BitConverter.ToInt64(byteDest, 0)));
                    }
                }

                PropertyObj pidTagAccessLevel = PropertyHelper.GetPropertyByName(pts, PropertyNames.PidTagAccessLevel);
                PropertyObj pidTagRecordKey   = PropertyHelper.GetPropertyByName(pts, PropertyNames.PidTagRecordKey);

                if (getPropertiesFlag == GetPropertiesFlags.MessageProperties)
                {
                    PropertyObj pidTagAccess = PropertyHelper.GetPropertyByName(pts, PropertyNames.PidTagAccess);

                    PropertyObj pidTagChangeKey            = PropertyHelper.GetPropertyByName(pts, PropertyNames.PidTagChangeKey);
                    PropertyObj pidTagCreationTime         = PropertyHelper.GetPropertyByName(pts, PropertyNames.PidTagCreationTime);
                    PropertyObj pidTagLastModificationTime = PropertyHelper.GetPropertyByName(pts, PropertyNames.PidTagLastModificationTime);
                    PropertyObj pidTagLastModifierName     = PropertyHelper.GetPropertyByName(pts, PropertyNames.PidTagLastModifierName);
                    PropertyObj pidTagSearchKey            = PropertyHelper.GetPropertyByName(pts, PropertyNames.PidTagSearchKey);

                    // Verify properties PidTagAccess, PidTagAccessLevel, PidTagChangeKey, PidTagCreationTime, PidTagLastModificationTime, PidTagLastModifierName and PidTagSearchKey exist on all Message objects.
                    this.VerifyPropertiesExistOnAllMessageObject(pidTagAccess, pidTagAccessLevel, pidTagChangeKey, pidTagCreationTime, pidTagLastModificationTime, pidTagLastModifierName, pidTagSearchKey);
                }

                if (getPropertiesFlag == GetPropertiesFlags.AttachmentProperties)
                {
                    // Verify properties PidTagAccessLevel and PidTagRecordKey exist on any Attachment object.
                    this.VerifyPropertiesExistOnAllAttachmentObject(pidTagAccessLevel, pidTagRecordKey);
                }

                break;

            case (byte)RopId.RopCreateMessage:
                RopCreateMessageResponse createMessageResponse = (RopCreateMessageResponse)response;

                // Adapter requirements related with RopCreateMessage will be verified if the response is a successful one.
                if (createMessageResponse.ReturnValue == 0x00000000)
                {
                    int hasMessageId = createMessageResponse.HasMessageId;
                    this.VerifyMessageSyntaxHasMessageId(hasMessageId);
                }

                break;

            case (byte)RopId.RopReadRecipients:
                RopReadRecipientsResponse readRecipientsResponse = (RopReadRecipientsResponse)response;

                // Adapter requirements related with RopReadRecipients will be verified if the response is a successful one.
                if (readRecipientsResponse.ReturnValue == 0x00000000)
                {
                    this.VerifyMessageSyntaxRowCount(readRecipientsResponse);
                }

                break;

            case (byte)RopId.RopSetMessageStatus:
                RopSetMessageStatusResponse setMessageStatusResponse = (RopSetMessageStatusResponse)response;

                // Adapter requirements related with RopSetMessageStatus will be verified if the response is a successful one.
                if (setMessageStatusResponse.ReturnValue == 0x00000000)
                {
                    this.VerifyMessageSyntaxMessageStatusFlags(setMessageStatusResponse);
                }

                break;

            case (byte)RopId.RopCreateAttachment:
                RopCreateAttachmentResponse createAttachmentResponse = (RopCreateAttachmentResponse)response;

                // Adapter requirements related with RopCreateAttachment will be verified if the response is a successful one.
                if (createAttachmentResponse.ReturnValue == 0x00000000)
                {
                    int id = (int)createAttachmentResponse.AttachmentID;
                    this.VerifyDataStructureRopCreateAttachmentResponse(createAttachmentResponse, id);
                }

                break;

            case (byte)RopId.RopOpenEmbeddedMessage:
                RopOpenEmbeddedMessageResponse openEmbeddedMessageResponse = (RopOpenEmbeddedMessageResponse)response;

                // Adapter requirements related with RopOpenEmbeddedMessage will be verified if the response is a successful one.
                if (openEmbeddedMessageResponse.ReturnValue == 0x00000000)
                {
                    ulong mid = openEmbeddedMessageResponse.MessageId;
                    this.VerifyDataStructureRopOpenEmbeddedMessageResponse(openEmbeddedMessageResponse, mid);
                }

                break;

            case (byte)RopId.RopSetMessageReadFlag:
                RopSetMessageReadFlagResponse setMessageReadFlagResponse = (RopSetMessageReadFlagResponse)response;

                // Adapter requirements related with RopSetMessageReadFlag will be verified if the response is a successful one.
                if (setMessageReadFlagResponse.ReturnValue == 0x00000000)
                {
                    this.VerifyMessageSyntaxReadStatusChanged(setMessageReadFlagResponse, (RopSetMessageReadFlagRequest)ropRequest);
                }

                break;

            case (byte)RopId.RopSetReadFlags:
                // Adapter requirements related with RopSetReadFlags will be verified if the response is a successful one.
                if (((RopSetReadFlagsResponse)response).ReturnValue == 0x00000000)
                {
                    this.VerifyRopSetReadFlagsResponse((RopSetReadFlagsResponse)response);
                }

                break;

            case (byte)RopId.RopGetMessageStatus:
                // Adapter requirements related with RopGetMessageStatus will be verified if the response is a successful one.
                if (((RopSetMessageStatusResponse)response).ReturnValue == 0x00000000)
                {
                    this.VerifyGetMessageStatusResponse((RopSetMessageStatusResponse)response);
                }

                break;

            default:
                break;
            }

            this.VerifyMAPITransport();

            return(responseSOHs);
        }
示例#4
0
        /// <summary>
        /// Compare the information of Message object from RopOpenMessageResponse and RopReloadCachedInformationResponse.
        /// </summary>
        /// <param name="openResp">The response of RopOpenMessage.</param>
        /// <param name="reloadResp">The response of RopReloadCachedInformation.</param>
        /// <returns>A Boolean indicates whether the information is same.</returns>
        private bool CompareResponseOfOpenMessageAndRopReloadCachedInformation(RopOpenMessageResponse openResp, RopReloadCachedInformationResponse reloadResp)
        {
            if (openResp.HasNamedProperties != reloadResp.HasNamedProperties)
            {
                return(false);
            }

            if (!openResp.SubjectPrefix.Equals(reloadResp.SubjectPrefix))
            {
                return(false);
            }

            if (!openResp.NormalizedSubject.Equals(reloadResp.NormalizedSubject))
            {
                return(false);
            }

            if (!openResp.RecipientCount.Equals(reloadResp.RecipientCount))
            {
                return(false);
            }

            if (!openResp.ColumnCount.Equals(reloadResp.ColumnCount))
            {
                return(false);
            }

            if (!openResp.RowCount.Equals(reloadResp.RowCount))
            {
                return(false);
            }

            if ((openResp.RecipientColumns == null && reloadResp.RecipientColumns != null) || (openResp.RecipientColumns != null && reloadResp.RecipientColumns == null))
            {
                return(false);
            }

            if (openResp.RecipientColumns != null && reloadResp.RecipientColumns != null)
            {
                if (openResp.RecipientColumns.Length != reloadResp.RecipientColumns.Length)
                {
                    return(false);
                }

                for (int i = 0; i < openResp.RecipientColumns.Length; i++)
                {
                    if (!openResp.RecipientColumns[i].Equals(reloadResp.RecipientColumns[i]))
                    {
                        return(false);
                    }
                }
            }

            if ((openResp.RecipientRows == null && reloadResp.RecipientRows != null) || (openResp.RecipientRows != null && reloadResp.RecipientRows == null))
            {
                return(false);
            }

            if (openResp.RecipientRows != null && reloadResp.RecipientRows != null)
            {
                if (openResp.RecipientRows.Length != reloadResp.RecipientRows.Length)
                {
                    return(false);
                }

                for (int i = 0; i < openResp.RecipientRows.Length; i++)
                {
                    if (!openResp.RecipientRows[i].Equals(reloadResp.RecipientRows[i]))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }