/// <summary> /// Verify the RopSetStreamSize operation related requirements. /// </summary> /// <param name="ropSetStreamSizeResponse">The RopSetStreamSize response buffer structure.</param> /// <param name="isStreamSizeEqualSetSize">Indicates if the stream size is equal to the pre-set value.</param> private void VerifyRopSetStreamSize(RopSetStreamSizeResponse ropSetStreamSizeResponse, bool isStreamSizeEqualSetSize) { // Since the RopSetStreamSize ROP response was parsed successfully, MS-OXCPRPT_R57702 can be captured directly. Site.CaptureRequirement( 57702, @"[In Processing RopSetStreamSize] The server responds with a RopSetStreamSize ROP response buffer."); // CPRPTErrorCode.None indicates the operation is performed successfully. if (ropSetStreamSizeResponse.ReturnValue.Equals((uint)CPRPTErrorCode.None)) { // If this operation is performed successfully, that means this operation is valid on Stream objects. Site.CaptureRequirement( 32301, @"[In RopSetStreamSize ROP] This operation is valid on Stream objects. "); Site.CaptureRequirementIfIsTrue( isStreamSizeEqualSetSize, 32003, @"[In RopGetStreamSize ROP Response Buffer] StreamSize: An integer that specifies the number of bytes in the stream."); Site.CaptureRequirementIfIsTrue( isStreamSizeEqualSetSize, 575, @"[In Processing RopGetStreamSize] The server MUST return the current size of the Stream object. "); } }
/// <summary> /// This method is used to set the size of a stream. /// </summary> /// <param name="isSizeIncreased"> Indicates the new size is increased or decreased.</param> /// <param name="isExtendedValueZero"> /// If the size of the stream is increased, then value of the extended stream MUST be zero.</param> /// <param name="isLost"> /// If the size of the stream is decreased, the information that extends past the end of the new size is lost.</param> /// <param name="isIncrease">If the size of the stream is increased, set this value to true</param> public void RopSetStreamSizeMethod(bool isSizeIncreased, out bool isExtendedValueZero, out bool isLost, out bool isIncrease) { isExtendedValueZero = false; isIncrease = false; isLost = false; bool isStreamSizeEqualSetSize = false; RopGetStreamSizeResponse getStreamSizeRes = this.RopGetStreamSize(this.cprptCurrentHandle, true); // The size of current object uint orginSize = getStreamSizeRes.StreamSize; RopSetStreamSizeResponse setStreamSizeResponse = new RopSetStreamSizeResponse(); if (isSizeIncreased) { setStreamSizeResponse = this.RopSetStreamSize(this.cprptCurrentHandle, orginSize + 1, false); if (setStreamSizeResponse.ReturnValue == 0) { this.RopSeekStream(this.cprptCurrentHandle, (byte)Origin.Beginning, 0, true); RopReadStreamResponse readResponse = this.RopReadStream(this.cprptCurrentHandle, (ushort)(orginSize + 2), 0, true); if (readResponse.DataSize == orginSize + 1) { isIncrease = true; isStreamSizeEqualSetSize = true; } } this.RopCommitStream(this.cprptCurrentHandle, true); this.RopSeekStream(this.cprptCurrentHandle, (byte)Origin.Beginning, orginSize, true); RopReadStreamResponse readStreamRes = this.RopReadStream(this.cprptCurrentHandle, 1, 0, true); if (readStreamRes.DataSize > 0) { if (readStreamRes.Data[0] == 0) { isExtendedValueZero = true; } } } else { setStreamSizeResponse = this.RopSetStreamSize(this.cprptCurrentHandle, orginSize - 1, false); if (setStreamSizeResponse.ReturnValue == 0) { this.RopSeekStream(this.cprptCurrentHandle, (byte)Origin.Beginning, 0, true); RopReadStreamResponse readResponse = this.RopReadStream(this.cprptCurrentHandle, (ushort)orginSize, 0, true); if (readResponse.DataSize == orginSize - 1) { isLost = true; isStreamSizeEqualSetSize = true; } } } this.VerifyRopSetStreamSize(setStreamSizeResponse, isStreamSizeEqualSetSize); this.Site.Assert.AreEqual((uint)CPRPTErrorCode.None, setStreamSizeResponse.ReturnValue, string.Format("Logon Failed! Error: 0x{0:X8}", setStreamSizeResponse.ReturnValue)); }
/// <summary> /// Verify RopSetStreamSize Response /// </summary> /// <param name="ropSetStreamSizeResponse">The response of RopSetStreamSize request</param> /// <param name="inputHandleIndex">The field of InputHandleIndex in RopSetStreamSize request</param> private void VerifyRopSetStreamSizeResponse(RopSetStreamSizeResponse ropSetStreamSizeResponse, byte inputHandleIndex) { // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R3321"); // Verify MS-OXCROPS requirement: MS-OXCROPS_R3321 Site.CaptureRequirementIfAreEqual<Type>( typeof(byte), ropSetStreamSizeResponse.RopId.GetType(), 3321, @"[In RopSetStreamSize ROP Response Buffer]RopId (1 byte): An unsigned integer."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R3323"); // Verify MS-OXCROPS requirement: MS-OXCROPS_R3323 Site.CaptureRequirementIfAreEqual<byte>( (byte)RopId.RopSetStreamSize, ropSetStreamSizeResponse.RopId, 3323, @"[In RopSetStreamSize ROP Response Buffer,RopId (1 byte)]For this operation[RopSetStreamSize], this field is set to 0x2F."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R3324"); // Verify MS-OXCROPS requirement: MS-OXCROPS_R3324 Site.CaptureRequirementIfAreEqual<Type>( typeof(byte), ropSetStreamSizeResponse.InputHandleIndex.GetType(), 3324, @"[In RopSetStreamSize ROP Response Buffer]InputHandleIndex (1 byte): An unsigned integer."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R3325"); // Verify MS-OXCROPS requirement: MS-OXCROPS_R3325 Site.CaptureRequirementIfAreEqual<byte>( inputHandleIndex, ropSetStreamSizeResponse.InputHandleIndex, 3325, @"[In RopSetStreamSize 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_R3327"); // Verify MS-OXCROPS requirement: MS-OXCROPS_R3327 Site.CaptureRequirementIfAreEqual<Type>( typeof(uint), ropSetStreamSizeResponse.ReturnValue.GetType(), 3327, @"[In RopSetStreamSize ROP Response Buffer]ReturnValue (4 bytes): An unsigned integer."); }