Ejemplo n.º 1
0
        /// <summary>
        /// Verify the RopReadStream operation related requirements.
        /// </summary>
        /// <param name="ropReadStreamResponse">The RopReadStream response buffer structure.</param>
        /// <param name="isReadingFailed">Indicates whether the RopReadStream failed.</param>
        private void VerifyRopReadStream(RopReadStreamResponse ropReadStreamResponse, bool isReadingFailed)
        {
            if (!isReadingFailed)
            {
                // Since the RopReadStream ROP response was parsed successfully, MS-OXCPRPT_R55202 can be captured directly.
                Site.CaptureRequirement(
                    55202,
                    @"[In Processing RopReadStream] The server responds with a RopReadStream ROP response buffer.");

                if (ropReadStreamResponse.ReturnValue.Equals((uint)CPRPTErrorCode.None))
                {
                    // Since the RopReadStream ROP response was parsed successfully, MS-OXCPRPT_R277 can be captured directly.
                    Site.CaptureRequirement(
                        277,
                        @"[In RopReadStream ROP] The RopReadStream ROP ([MS-OXCROPS] section 2.2.9.2) reads the stream of bytes from a Stream object.");

                    // The parser has ensured the field satisfied the format, otherwise the response cannot be received.
                    Site.CaptureRequirement(
                        286,
                        @"[In RopReadStream ROP Response Buffer] DataSize (2 bytes): An integer.");

                    Site.CaptureRequirementIfAreEqual<ushort>(
                        ropReadStreamResponse.DataSize,
                        (ushort)ropReadStreamResponse.Data.Length,
                        28601,
                        @"[In RopReadStream ROP Response Buffer] DataSize: An integer that specifies the number of bytes in the Data field.");

                    Site.CaptureRequirementIfAreEqual<ushort>(
                        ropReadStreamResponse.DataSize,
                        (ushort)ropReadStreamResponse.Data.Length,
                        296,
                        @"[In RopReadStream ROP Response Buffer] Data: This field MUST contain exactly the number of bytes specified in the DataSize field.");

                    // If this operation is performed successfully, that means this operation is valid on Stream objects.
                    Site.CaptureRequirement(
                        27800,
                        @"[In RopReadStream ROP] This operation is valid on Stream objects.");
                }
            }
            else
            {
                if (Common.IsRequirementEnabled(88601, this.Site))
                {
                    Site.CaptureRequirementIfAreEqual<ushort>(
                        0,
                        ropReadStreamResponse.DataSize,
                        88601,
                        @"[In Processing RopReadStream] Implementation does set the DataSize field to zero in the case of a failure.(Microsoft Exchange Server 2007 and above follow this behavior)");
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Verify the RopReadStream operation related requirements.
        /// </summary>
        /// <param name="readStreamResponse">The RopReadStream response buffer structure.</param>
        /// <param name="byteCount">Indicates the size to be read.</param>
        /// <param name="maxByteCount">If byteCount is 0xBABE, use MaximumByteCount to determine the size to be read.</param>
        private void VerifyRopReadStreamWithLimitedSize(RopReadStreamResponse readStreamResponse, ushort byteCount, uint maxByteCount)
        {
            if (byteCount != 0xBABE)
            {
                Site.CaptureRequirementIfIsTrue(
                    readStreamResponse.DataSize <= byteCount,
                    2830201,
                    @"[In RopReadStream ROP Request Buffer] ByteCount: An integer that specifies the maximum number of bytes to be read unless the value is 0xBABE");

                Site.CaptureRequirementIfIsTrue(
                    readStreamResponse.DataSize <= byteCount,
                    55206,
                    @"[In Processing RopReadStream]otherwise[If the ByteCount field of the ROP request buffer isn't set to 0xBABE], the number of bytes read MUST be less than or equal to the value of the ByteCount field.");
            }
            else
            {
                Site.CaptureRequirementIfIsTrue(
                   readStreamResponse.DataSize <= maxByteCount,
                   2830401,
                   @"[In RopReadStream ROP Request Buffer] MaximumByteCount: An integer that specifies the maximum number of bytes to be read if the ByteCount field is set to 0xBABE. ");

                Site.CaptureRequirementIfIsTrue(
                  readStreamResponse.DataSize <= maxByteCount,
                  55205,
                  @"[In Processing RopReadStream] If the ByteCount field of the ROP request buffer is set to 0xBABE, the number of bytes read MUST be less than or equal to the value of the MaximumByteCount field of the ROP request buffer;");
            }
        }
        /// <summary>
        /// Verify RopReadStream Response
        /// </summary>
        /// <param name="ropReadStreamResponse">The response of RopReadStream request</param>
        /// <param name="inputHandleIndex">The field of InputHandleIndex in RopReadStream request</param>
        private void VerifyRopReadStreamResponse(RopReadStreamResponse ropReadStreamResponse, byte inputHandleIndex)
        {
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R3216");

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R3216
            Site.CaptureRequirementIfAreEqual<Type>(
                typeof(byte),
                ropReadStreamResponse.RopId.GetType(),
                3216,
                @"[In RopReadStream ROP Response Buffer]RopId (1 byte): An unsigned integer.");

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

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R3218
            Site.CaptureRequirementIfAreEqual<byte>(
                (byte)RopId.RopReadStream,
                ropReadStreamResponse.RopId,
                3218,
                @"[In RopReadStream ROP Response Buffer,RopId (1 byte)]For this operation[RopReadStream], this field is set to 0x2C.");

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

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R3219
            Site.CaptureRequirementIfAreEqual<Type>(
                typeof(byte),
                ropReadStreamResponse.InputHandleIndex.GetType(),
                3219,
                @"[In RopReadStream ROP Response Buffer]InputHandleIndex (1 byte): An unsigned integer.");

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

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R3220
            Site.CaptureRequirementIfAreEqual<byte>(
                inputHandleIndex,
                ropReadStreamResponse.InputHandleIndex,
                3220,
                @"[In RopReadStream ROP Response Buffer,InputHandleIndex (1 byte)]This index MUST be set to the value specified in the InputHandleIndex field in the request.");

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

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R3222
            Site.CaptureRequirementIfAreEqual<Type>(
                typeof(uint),
                ropReadStreamResponse.ReturnValue.GetType(),
                3222,
                @"[In RopReadStream ROP Response Buffer]ReturnValue (4 bytes): An unsigned integer.");

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

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R3224
            Site.CaptureRequirementIfAreEqual<Type>(
                typeof(ushort),
                ropReadStreamResponse.DataSize.GetType(),
                3224,
                @"[In RopReadStream ROP Response Buffer]DataSize (2 bytes): An unsigned integer.");

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

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R3229
            Site.CaptureRequirementIfAreEqual<Type>(
                typeof(byte[]),
                ropReadStreamResponse.Data.GetType(),
                3229,
                @"[In RopReadStream ROP Response Buffer]Data (variable): An array of bytes.");

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

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R3231
            Site.CaptureRequirementIfAreEqual<int>(
                ropReadStreamResponse.DataSize,
                ropReadStreamResponse.Data.Length,
                3231,
                @"[In RopReadStream ROP Response Buffer,Data (variable)]The size of this field, in bytes, is specified by the DataSize field.");
        }