public void MSOXCROPS_S04_TC04_TestRopSetMessageReadFlags()
{
this.CheckTransportIsSupported();
// Check whether the environment supported public folder.
if (bool.Parse(Common.GetConfigurationPropertyValue("IsPublicFolderSupported", this.Site)))
{
this.cropsAdapter.RpcConnect(
Common.GetConfigurationPropertyValue("SutComputerName", this.Site),
ConnectionType.PublicFolderServer,
Common.GetConfigurationPropertyValue("UserEssdn", this.Site),
Common.GetConfigurationPropertyValue("Domain", this.Site),
Common.GetConfigurationPropertyValue("AdminUserName", this.Site),
Common.GetConfigurationPropertyValue("PassWord", this.Site));
// Step 1: Open the second folder and create a subfolder.
#region Open the second folder to create public folder under root folder
// Log on to a private mailbox.
RopLogonResponse logonResponse = Logon(LogonType.PublicFolder, this.userDN, out inputObjHandle);
RopOpenFolderRequest openFolderRequest;
RopOpenFolderResponse openFolderResponse;
openFolderRequest.RopId = (byte)RopId.RopOpenFolder;
openFolderRequest.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.
openFolderRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
// Set OutputHandleIndex to 0x1, which specifies the location in the Server object handle table where the handle
// for the output Server object will be stored.
openFolderRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;
// Set FolderId to the second folder of the logonResponse, which specifies the folder to be opened.
openFolderRequest.FolderId = logonResponse.FolderIds[1];
openFolderRequest.OpenModeFlags = (byte)FolderOpenModeFlags.None;
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Step 1: Begin to send the RopOpenFolder request.");
// Send the RopOpenFolder request and verify the success response.
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 openedFolderHandle = responseSOHs[0][openFolderResponse.OutputHandleIndex];
#endregion
// Step 2: Create a non-ghosted public folder.
#region Create a non-ghosted public folder
RopCreateFolderRequest createFolderRequest;
RopCreateFolderResponse createFolderResponse;
createFolderRequest.RopId = (byte)RopId.RopCreateFolder;
createFolderRequest.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.
createFolderRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
// Set OutputHandleIndex to 0x1, which specifies the location in the Server object handle table where the handle
// for the output Server object will be stored.
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(TRUE), which means the folder being created will be opened when it is already existed,
// as specified in [MS-OXCFOLD].
createFolderRequest.OpenExisting = TestSuiteBase.NonZero;
// Set Reserved to 0x0, this field is reserved and MUST be set to 0.
createFolderRequest.Reserved = TestSuiteBase.Reserved;
// Set new value for DisplayNameAndCommentForNonSearchFolder in Public Folder
string displayNameAndCommentForNonSearchFolder = "MS-OXCROPSPublicFolder" + DisplayNameAndCommentForNonSearchFolder;
// Set DisplayName, which specifies the name of the created folder.
createFolderRequest.DisplayName = Encoding.ASCII.GetBytes(displayNameAndCommentForNonSearchFolder + "\0");
// Set Comment, which specifies the folder comment that is associated with the created folder.
createFolderRequest.Comment = Encoding.ASCII.GetBytes(displayNameAndCommentForNonSearchFolder + "\0");
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Step 2: Begin to send the RopCreateFolder request.");
// Send the RopCreateFolder request to the server and verify the success response.
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)");
ulong folderId = createFolderResponse.FolderId;
#endregion
// Step 3: Open the folder containing the created message.
#region Open folder
openFolderRequest.RopId = (byte)RopId.RopOpenFolder;
openFolderRequest.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.
openFolderRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
// Set OutputHandleIndex to 0x1, which specifies the location in the Server object handle table where the handle
// for the output Server object will be stored.
openFolderRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;
// Set FolderId to that of created folder, which specifies the folder to be opened.
openFolderRequest.FolderId = folderId;
openFolderRequest.OpenModeFlags = (byte)FolderOpenModeFlags.None;
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Step 3: Begin to send the RopOpenFolder request.");
// Send the RopOpenFolder request and verify the success response.
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)");
#endregion
// Step 4: Create and save message.
#region Create and save message
#region Create a message.
RopCreateMessageRequest createMessageRequest = new RopCreateMessageRequest();
RopCreateMessageResponse createMessageResponse;
createMessageRequest.RopId = (byte)RopId.RopCreateMessage;
createMessageRequest.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.
createMessageRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
// Set OutputHandleIndex to 0x01, which specifies the location in the Server object handle table where the handle for the output Server object will be stored.
createMessageRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;
// Set CodePageId to 0x0FFF, which specified the code page of Logon object will be used.
createMessageRequest.CodePageId = TestSuiteBase.CodePageId;
// Set FolderId to that of created folder, which identifies the parent folder.
createMessageRequest.FolderId = createFolderResponse.FolderId;
// Set AssociatedFlag to 0x00, which specified this 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 4: Begin to send the RopCreateMessage request.");
// Send the RopCreateMessage request and verify the success response.
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
#region RopModifyRecipients response
RopModifyRecipientsRequest modifyRecipientsRequest;
RopModifyRecipientsResponse modifyRecipientsResponse;
modifyRecipientsRequest.RopId = (byte)RopId.RopModifyRecipients;
modifyRecipientsRequest.LogonId = TestSuiteBase.LogonId;
// Set InputHandleIndex to 0x00, which specifies the location in the Server object handle table where the handle for the input Server object is stored.
modifyRecipientsRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
// Call CreateSampleRecipientColumnsAndRecipientRows method to create Recipient Rows and Recipient Columns.
PropertyTag[] recipientColumns = null;
ModifyRecipientRow[] recipientRows = null;
this.CreateSampleRecipientColumnsAndRecipientRows(out recipientColumns, out recipientRows);
// Set ColumnCount, which specifies the number of rows in the RecipientRows field.
modifyRecipientsRequest.ColumnCount = (ushort)recipientColumns.Length;
// Set RecipientColumns to that created above, which specifies the property values that can be included
// for each recipient.
modifyRecipientsRequest.RecipientColumns = recipientColumns;
// Set RowCount, which specifies the number of rows in the RecipientRows field.
modifyRecipientsRequest.RowCount = (ushort)recipientRows.Length;
// Set RecipientRows to that created above, which is a list of ModifyRecipientRow structures.
modifyRecipientsRequest.RecipientRows = recipientRows;
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Step 4: Begin to send the RopModifyRecipients request.");
// Send the RopModifyRecipients request to the server and verify the success response.
this.responseSOHs = cropsAdapter.ProcessSingleRop(
modifyRecipientsRequest,
targetMessageHandle,
ref this.response,
ref this.rawData,
RopResponseType.SuccessResponse);
modifyRecipientsResponse = (RopModifyRecipientsResponse)response;
Site.Assert.AreEqual<uint>(
TestSuiteBase.SuccessReturnValue,
modifyRecipientsResponse.ReturnValue,
"If ROP succeeds, the ReturnValue of its response is 0 (success)");
#endregion
#region Save message
RopSaveChangesMessageRequest saveChangesMessageRequest;
RopSaveChangesMessageResponse saveChangesMessageResponse;
saveChangesMessageRequest.RopId = (byte)RopId.RopSaveChangesMessage;
saveChangesMessageRequest.LogonId = TestSuiteBase.LogonId;
// Set InputHandleIndex to 0x00, which specifies the location in the Server object handle table where the handle for the input Server object is stored.
saveChangesMessageRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
// Set ResponseHandleIndex to 0x01, which specifies the location in the Server object handle table that is referenced
// in the response.
saveChangesMessageRequest.ResponseHandleIndex = TestSuiteBase.ResponseHandleIndex1;
saveChangesMessageRequest.SaveFlags = (byte)SaveFlags.ForceSave;
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Step 4: Begin to send the RopSaveChangesMessage request.");
// Send the RopSaveChangesMessage request to the server and verify the success response.
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
#endregion
// Step 5: Send the RopCreateMessage request and verify the success response.
#region RopLongTermIdFromId success response
RopLongTermIdFromIdRequest longTermIdFromIdRequest;
RopLongTermIdFromIdResponse longTermIdFromIdResponse;
longTermIdFromIdRequest.RopId = (byte)RopId.RopLongTermIdFromId;
longTermIdFromIdRequest.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.
longTermIdFromIdRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
// Set ObjectId to that got in the foregoing code, this id will be converted to a short-term ID.
longTermIdFromIdRequest.ObjectId = saveChangesMessageResponse.MessageId;
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Step 5: Begin to send the RopLongTermIdFromId request.");
// Send the RopLongTermIdFromId request to the server and verify the success response.
this.responseSOHs = cropsAdapter.ProcessSingleRop(
longTermIdFromIdRequest,
this.inputObjHandle,
ref this.response,
ref this.rawData,
RopResponseType.SuccessResponse);
longTermIdFromIdResponse = (RopLongTermIdFromIdResponse)response;
Site.Assert.AreEqual<uint>(
TestSuiteBase.SuccessReturnValue,
longTermIdFromIdResponse.ReturnValue,
"If ROP succeeds, the ReturnValue of its response is 0 (success)");
#endregion
// Step 6: Send the RopOpenMessag request and verify the success response.
#region RopOpenMessag success response
RopOpenMessageRequest openMessageRequest;
RopOpenMessageResponse openMessageResponse;
openMessageRequest.RopId = (byte)RopId.RopOpenMessage;
openMessageRequest.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.
openMessageRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
// Set OutputHandleIndex to 0x01, which specifies the location in the Server object handle table where the handle for the output Server object will be stored.
openMessageRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;
// Set CodePageId to 0x0FFF, which specified the code page of Logon object will be used.
openMessageRequest.CodePageId = TestSuiteBase.CodePageId;
// Set FolderId to that of created folder, which identifies the parent folder.
openMessageRequest.FolderId = createFolderResponse.FolderId;
openMessageRequest.OpenModeFlags = (byte)MessageOpenModeFlags.ReadWrite;
// Set MessageId to that of created message, which identifies the message to be opened.
openMessageRequest.MessageId = saveChangesMessageResponse.MessageId;
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Step 6: Begin to send the RopCreateMessage request.");
// Send the RopCreateMessage request to the server and verify the success response.
this.responseSOHs = cropsAdapter.ProcessSingleRop(
openMessageRequest,
this.inputObjHandle,
ref this.response,
ref this.rawData,
RopResponseType.SuccessResponse);
openMessageResponse = (RopOpenMessageResponse)response;
Site.Assert.AreEqual<uint>(
TestSuiteBase.SuccessReturnValue,
openMessageResponse.ReturnValue,
"if ROP succeeds, the ReturnValue of its response is 0(success)");
#endregion
// Step 7: Send the RopSetMessageReadFlag request and verify the success response.
#region RopSetMessageReadFlag success response Test not changed
RopSetMessageReadFlagRequest setMessageReadFlagRequest;
RopSetMessageReadFlagResponse setMessageReadFlagResponse;
setMessageReadFlagRequest.RopId = (byte)RopId.RopSetMessageReadFlag;
setMessageReadFlagRequest.LogonId = TestSuiteBase.LogonId;
// Set ResponseHandleIndex, which specifies the location in the Server object handle table that is referenced
// in the response.
setMessageReadFlagRequest.ResponseHandleIndex = TestSuiteBase.ResponseHandleIndex1;
// Set InputHandleIndex to 0x00, which specifies the location in the Server object handle table where the handle for the input Server object is stored.
setMessageReadFlagRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
setMessageReadFlagRequest.ReadFlags = (byte)ReadFlags.GenerateReceiptOnly;
// Set ClientData, which specifies the information that is returned to the client in a successful response.
setMessageReadFlagRequest.ClientData = longTermIdFromIdResponse.LongTermId.Serialize();
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Step 7: Begin to send the RopSetMessageReadFlag request.");
// Send the RopSetMessageReadFlag request to the server and verify the success response.
this.responseSOHs = cropsAdapter.ProcessSingleRop(
setMessageReadFlagRequest,
targetMessageHandle,
ref this.response,
ref this.rawData,
RopResponseType.SuccessResponse);
setMessageReadFlagResponse = (RopSetMessageReadFlagResponse)response;
Site.Assert.AreEqual<uint>(
TestSuiteBase.SuccessReturnValue,
setMessageReadFlagResponse.ReturnValue,
"If ROP succeeds, the ReturnValue of its response is 0 (success)");
#endregion
#region Verify R2110 and R2114
if (setMessageReadFlagResponse.ReadStatusChanged == Convert.ToByte(TestSuiteBase.Zero))
{
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R2110");
// Verify MS-OXCROPS requirement: MS-OXCROPS_R2110
// LogonId is null means not present.
Site.CaptureRequirementIfAreEqual<byte?>(
null,
setMessageReadFlagResponse.LogonId,
2110,
@"[In RopSetMessageReadFlag ROP Success Response Buffer,LogonId (1 byte)]is not present otherwise[when the value in the ReadStatusChanged field is zero].");
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R2114");
// Verify MS-OXCROPS requirement: MS-OXCROPS_R2114
// ClientData is null means not present.
Site.CaptureRequirementIfIsNull(
setMessageReadFlagResponse.ClientData,
2114,
@"[In RopSetMessageReadFlag ROP Success Response Buffer,ClientData (24 bytes)]is not present otherwise[when the value in the ReadStatusChanged field is zero].");
}
#endregion
// Step 8: Send the RopSetMessageReadFlag request and verify the success response.
#region RopSetMessageReadFlag success response Test changed
setMessageReadFlagRequest.RopId = (byte)RopId.RopSetMessageReadFlag;
setMessageReadFlagRequest.LogonId = TestSuiteBase.LogonId;
// Set ResponseHandleIndex, which specifies the location in the Server object handle table that is referenced
// in the response.
setMessageReadFlagRequest.ResponseHandleIndex = TestSuiteBase.ResponseHandleIndex1;
// Set InputHandleIndex to 0x00, which specifies the location in the Server object handle table where the handle for the input Server object is stored.
setMessageReadFlagRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
setMessageReadFlagRequest.ReadFlags = (byte)ReadFlags.ClearReadFlag;
// Set ClientData, which specifies the information that is returned to the client in a successful response.
setMessageReadFlagRequest.ClientData = longTermIdFromIdResponse.LongTermId.Serialize();
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Step 8: Begin to send the RopSetMessageReadFlag request.");
// Send the RopSetMessageReadFlag request to the server and verify the success response.
this.responseSOHs = cropsAdapter.ProcessSingleRop(
setMessageReadFlagRequest,
targetMessageHandle,
ref this.response,
ref this.rawData,
RopResponseType.SuccessResponse);
setMessageReadFlagResponse = (RopSetMessageReadFlagResponse)response;
Site.Assert.AreEqual<uint>(
TestSuiteBase.SuccessReturnValue,
setMessageReadFlagResponse.ReturnValue,
"If ROP succeeds, the ReturnValue of its response is 0 (success)");
#endregion
#region Verify R2109 and R2113
if (setMessageReadFlagResponse.ReadStatusChanged != Convert.ToByte(TestSuiteBase.Zero))
{
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R2109");
// Verify MS-OXCROPS requirement: MS-OXCROPS_R2109
// LogonId is not null means present.
Site.CaptureRequirementIfIsNotNull(
setMessageReadFlagResponse.LogonId,
2109,
@"[In RopSetMessageReadFlag ROP Success Response Buffer,LogonId (1 byte)]This field is present when the value in the ReadStatusChanged field is nonzero.");
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R2113");
// Verify MS-OXCROPS requirement: MS-OXCROPS_R2113
// ClientData is not null means present.
Site.CaptureRequirementIfIsNotNull(
setMessageReadFlagResponse.ClientData,
2113,
@"[In RopSetMessageReadFlag ROP Success Response Buffer,ClientData (24 bytes)]This field is present when the value in the ReadStatusChanged field is nonzero.");
}
#endregion
// Step 9: Send the RopSetMessageReadFlag request and verify the failure response.
#region RopSetMessageReadFlag failure response
// Set InputHandleIndex to 0x01, which is an invalid index and will lead to a failure response.
setMessageReadFlagRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex1;
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Step 9: Begin to send the RopSetMessageReadFlag request.");
// Send the RopSetMessageReadFlag request and verify the failure response.
this.responseSOHs = cropsAdapter.ProcessSingleRop(
setMessageReadFlagRequest,
targetMessageHandle,
ref this.response,
ref this.rawData,
RopResponseType.FailureResponse);
setMessageReadFlagResponse = (RopSetMessageReadFlagResponse)response;
Site.Assert.AreNotEqual<uint>(
TestSuiteBase.SuccessReturnValue,
setMessageReadFlagResponse.ReturnValue,
"If ROP fails, the ReturnValue of its response is set to a value other than 0x00000000(failure)");
#endregion
// Step 10: Send a RopDeleteFolder request to the server.
#region RopDeleteFolder Response
RopDeleteFolderRequest deleteFolderRequest;
deleteFolderRequest.RopId = (byte)RopId.RopDeleteFolder;
deleteFolderRequest.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.
deleteFolderRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
deleteFolderRequest.DeleteFolderFlags = (byte)DeleteFolderFlags.DelMessages;
// Set FolderId to targetFolderId, this folder is to be deleted.
deleteFolderRequest.FolderId = folderId;
// Send a RopDeleteFolder request to the server and verify the success response.
this.responseSOHs = cropsAdapter.ProcessSingleRop(
deleteFolderRequest,
openedFolderHandle,
ref this.response,
ref this.rawData,
RopResponseType.SuccessResponse);
#endregion
}
else
{
Site.Assert.Inconclusive("This case runs only when the first system supports public folder logon.");
}
}