public void MSOXORULE_S01_TC03_AddExtendedRule_WithLargeMessageCondition() { this.CheckMAPIHTTPTransportSupported(); #region TestUser1 creates an FAI message. RopCreateMessageResponse ropCreateMessageResponse; uint extendedRuleMessageHandle = this.OxoruleAdapter.RopCreateMessage(this.InboxFolderHandle, this.InboxFolderID, Convert.ToByte(true), out ropCreateMessageResponse); Site.Assert.AreEqual<uint>(0, ropCreateMessageResponse.ReturnValue, "Creating the first FAI message should succeed."); #endregion #region TestUser1 adds the extended rule with NamedProperty successfully. string ruleConditionSubjectName = Constants.RuleConditionSubjectContainString; NamedPropertyInfo namedPropertyInfo = new NamedPropertyInfo { NoOfNamedProps = 2, PropId = new uint[2] { 0x8001, 0x8002 } }; // 0x01 means the property is identified by the name property. PropertyName testPropertyName = new PropertyName { Guid = System.Guid.NewGuid().ToByteArray(), Kind = 0x01, Name = Encoding.Unicode.GetBytes(Constants.NameOfPropertyName + "\0") }; testPropertyName.NameSize = (byte)testPropertyName.Name.Length; // 0x00 means the property is identified by the LID. PropertyName secondPropertyName = new PropertyName { Guid = System.Guid.NewGuid().ToByteArray(), Kind = 0x00, LID = 0x88888888 }; namedPropertyInfo.NamedProperty = new PropertyName[2] { testPropertyName, secondPropertyName }; namedPropertyInfo.NamedPropertiesSize = (uint)(testPropertyName.Serialize().Length + secondPropertyName.Serialize().Length); string ruleName = Common.GenerateResourceName(this.Site, Constants.ExtendRulename1); TaggedPropertyValue[] extendedRuleProperties = AdapterHelper.GenerateExtendedRuleTestData(ruleName, 0, (uint)RuleState.ST_ENABLED, Constants.PidTagRuleProvider, ActionType.OP_MARK_AS_READ, new DeleteMarkReadActionData(), ruleConditionSubjectName, namedPropertyInfo); // Set properties for extended rule FAI message. RopSetPropertiesResponse ropSetPropertiesResponse = this.OxoruleAdapter.RopSetProperties(extendedRuleMessageHandle, extendedRuleProperties); Site.Assert.AreEqual<uint>(0, ropSetPropertiesResponse.ReturnValue, "Setting property for Extended rule FAI message should succeed."); // Save changes of message. RopSaveChangesMessageResponse ropSaveChangesMessagResponse = this.OxoruleAdapter.RopSaveChangesMessage(extendedRuleMessageHandle); Site.Assert.AreEqual<uint>(0, ropSaveChangesMessagResponse.ReturnValue, "Saving Extend rule message should succeed."); // Specify the properties to be got. PropertyTag[] propertyTagArray = new PropertyTag[2]; // PidTagRuleMessageProviderData propertyTagArray[0].PropertyId = (ushort)PropertyId.PidTagRuleMessageProvider; propertyTagArray[0].PropertyType = (ushort)PropertyType.PtypString; // PidTagRuleMessageName propertyTagArray[1].PropertyId = (ushort)PropertyId.PidTagRuleMessageName; propertyTagArray[1].PropertyType = (ushort)PropertyType.PtypString; // Get the specific properties of the extended rule. RopGetPropertiesSpecificResponse ropGetPropertiesSpecificResponse = this.OxoruleAdapter.RopGetPropertiesSpecific(extendedRuleMessageHandle, propertyTagArray); Site.Assert.AreEqual<uint>(0, ropGetPropertiesSpecificResponse.ReturnValue, "Getting folder id property operation should succeed."); #region Capture Code // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R184"); // Verify MS-OXORULE requirement: MS-OXORULE_R184 string pidTagRuleMessageProviderData = AdapterHelper.PropertyValueConvertToString(ropGetPropertiesSpecificResponse.RowData.PropertyValues[0].Value); Site.CaptureRequirementIfAreEqual<string>( Constants.PidTagRuleProvider, pidTagRuleMessageProviderData, 184, @"[In PidTagRuleMessageProvider Property] This property has the same semantics as the PidTagRuleProvider property (section 2.2.1.3.1.5). [The PidTagRuleMessageProvider property identifies the client application that owns the rule (2).]"); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R164"); // Verify MS-OXORULE requirement: MS-OXORULE_R164 // The rule name set by client is "ExtendRulename1". string pidTagRuleMessageNameValue = AdapterHelper.PropertyValueConvertToString(ropGetPropertiesSpecificResponse.RowData.PropertyValues[1].Value); Site.CaptureRequirementIfAreEqual<string>( ruleName, pidTagRuleMessageNameValue, 164, @"[In PidTagRuleMessageName Property] This property has the same semantics as the PidTagRuleName property (section 2.2.1.3.1.4). [The PidTagRuleMessageName property specifies the name of the rule (2).]"); #endregion #endregion #region TestUser1 retrieves data of the new extended rule. this.OxoruleAdapter.TargetOfRop = TargetOfRop.ForExtendedRules; RopGetPropertiesAllResponse ropGetExtendRuleMessageResponse = this.OxoruleAdapter.RopGetPropertiesAll(extendedRuleMessageHandle, this.PropertySizeLimitFlag, (ushort)WantUnicode.Want); Site.Assert.AreEqual<uint>(0, ropGetExtendRuleMessageResponse.ReturnValue, "Getting all properties operation should succeed."); Site.Assert.IsTrue(ropGetExtendRuleMessageResponse.PropertyValues.Length != 0, "Extended Rule data should be found in related FAI message!"); this.OxoruleAdapter.TargetOfRop = TargetOfRop.OtherTarget; ExtendedRuleActions extendedRuleMessageActions = null; // Check the properties set on Extended Rule, and find the Extended Rule Actions. for (int i = 0; i < ropGetExtendRuleMessageResponse.PropertyValues.Length; i++) { // propertyId indicates the Id of a property set on Extended Rule. ushort propertyId = ropGetExtendRuleMessageResponse.PropertyValues[i].PropertyTag.PropertyId; if (propertyId == (ushort)PropertyId.PidTagExtendedRuleMessageActions) { byte[] propertyValue = ropGetExtendRuleMessageResponse.PropertyValues[i].Value; extendedRuleMessageActions = AdapterHelper.PropertyValueConvertToExtendedRuleActions(propertyValue); break; } } Site.Assert.AreNotEqual<ExtendedRuleActions>(null, extendedRuleMessageActions, "extendedRuleMessageActions should not be null."); // Get the Property Names saved by server in the extendedRuleMessageActions. PropertyName[] propertyNames = extendedRuleMessageActions.NamedPropertyInformation.NamedProperty; PropertyName testPropertyNameSavedOnServer = new PropertyName(); PropertyName secondPropertyNameSavedOnServer = new PropertyName(); if (propertyNames != null && propertyNames.Length > 0) { for (int i = 0; i < propertyNames.Length; i++) { // If the Kind is 0x01, it means this PropertyName is the testPropertyName. if (propertyNames[i].Kind == 0x01) { testPropertyNameSavedOnServer = propertyNames[i]; } else if (propertyNames[i].Kind == 0x00) { // If the Kind is 0x00, it means this PropertyName is the secondPropertyName. secondPropertyNameSavedOnServer = propertyNames[i]; } } } Site.Assert.IsNotNull(testPropertyNameSavedOnServer.Guid, "testPropertyNameSavedOnServer should not be null."); Site.Assert.IsNotNull(secondPropertyNameSavedOnServer.Guid, "secondPropertyNameSavedOnServer should not be null."); #endregion #region TestUser1 creates a new FAI message. extendedRuleMessageHandle = this.OxoruleAdapter.RopCreateMessage(this.InboxFolderHandle, this.InboxFolderID, Convert.ToByte(true), out ropCreateMessageResponse); Site.Assert.AreEqual<uint>(0, ropCreateMessageResponse.ReturnValue, "Creating the second FAI message should succeed."); #endregion #region TestUser1 creates an extended rule with PidTagExtendedRuleMessageCondition property value size larger than the size set by the server. propertyTagArray = new PropertyTag[1]; propertyTagArray[0].PropertyId = (ushort)PropertyId.PidTagExtendedRuleSizeLimit; propertyTagArray[0].PropertyType = (ushort)PropertyType.PtypInteger32; ropGetPropertiesSpecificResponse = this.OxoruleAdapter.RopGetPropertiesSpecific(this.LogonHandle, propertyTagArray); uint pidTagExtendedRuleSizeLimit = Common.ConvertByteArrayToUint(ropGetPropertiesSpecificResponse.RowData.PropertyValues[0].Value); // According to MS-OXCRPC, "The server SHOULD fail with the RPC status code of RPC_X_BAD_STUB_DATA (0x000006F7) if the request buffer is larger than 0x00040000 bytes in size." if (pidTagExtendedRuleSizeLimit < 0x00040000) { ruleConditionSubjectName = Constants.RuleConditionSubjectContainString; namedPropertyInfo = new NamedPropertyInfo { NoOfNamedProps = 2, PropId = new uint[2] { 0x8001, 0x8002 } }; // Generate a string value whose size lager than the one specified by the PidTagExtendedRuleSizeLimit property. StringBuilder stringByteValue = new StringBuilder("ExtentRuleSize"); stringByteValue.Append('a', (int)pidTagExtendedRuleSizeLimit); // If the value of Kind is 0x01, it means that the property is identified by the name property. testPropertyName = new PropertyName { Guid = System.Guid.NewGuid().ToByteArray(), Kind = 0x01, Name = Encoding.Unicode.GetBytes(stringByteValue + "\0") }; testPropertyName.NameSize = (byte)testPropertyName.Name.Length; // If the value of Kind is 0x00, it means that the property is identified by the LID. secondPropertyName = new PropertyName { Guid = System.Guid.NewGuid().ToByteArray(), Kind = 0x00, LID = 0x88888888 }; namedPropertyInfo.NamedProperty = new PropertyName[2] { testPropertyName, secondPropertyName }; namedPropertyInfo.NamedPropertiesSize = (uint)(testPropertyName.Serialize().Length + secondPropertyName.Serialize().Length); extendedRuleProperties = AdapterHelper.GenerateExtendedRuleTestData(Common.GenerateResourceName(this.Site, Constants.ExtendRulename1), 0, (uint)RuleState.ST_ENABLED, Constants.PidTagRuleProvider, ActionType.OP_MARK_AS_READ, new DeleteMarkReadActionData(), ruleConditionSubjectName, namedPropertyInfo); TaggedPropertyValue pidTagExtendedRuleMessageCondition = new TaggedPropertyValue(); foreach (TaggedPropertyValue propertyValue in extendedRuleProperties) { if (propertyValue.PropertyTag.PropertyId == (ushort)PropertyId.PidTagExtendedRuleMessageCondition) { pidTagExtendedRuleMessageCondition = propertyValue; break; } } uint pidTagExtendedRuleMessageConditionSize = uint.Parse(pidTagExtendedRuleMessageCondition.Value.Length.ToString()); // Set properties for extended rule FAI message. ropSetPropertiesResponse = this.OxoruleAdapter.RopSetProperties(extendedRuleMessageHandle, extendedRuleProperties); // Save changes of message. ropSaveChangesMessagResponse = this.OxoruleAdapter.RopSaveChangesMessage(extendedRuleMessageHandle); // Add the debug information. Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R1016"); // Verify MS-OXORULE requirement: MS-OXORULE_R1016. if (pidTagExtendedRuleMessageConditionSize > pidTagExtendedRuleSizeLimit) { Site.CaptureRequirementIfAreNotEqual<uint>( 0x0000, ropSaveChangesMessagResponse.ReturnValue, 1016, @"[In Processing Incoming Messages to a Folder] If the PidTagExtendedRuleSizeLimit property is set and the size of the PidTagExtendedRuleMessageCondition property (section 2.2.4.1.10) exceeds the value specified by the PidTagExtendedRuleSizeLimit property, the server MUST return an error."); } else { Site.Assert.Fail("The size of the PidTagExtendedRuleMessageCondition property should exceeds the value specified by the PidTagExtendedRuleSizeLimit property."); } } #endregion }
public void MSOXORULE_S04_TC02_AddModifyDeleteExtendedRule_OnPublicFolder() { this.CheckMAPIHTTPTransportSupported(); #region TestUser1 logs on to the public folder. RopOpenFolderResponse openFolderResponse; RopLogonResponse logonResponse; bool ret = this.OxoruleAdapter.Connect(ConnectionType.PublicFolderServer, this.User1Name, this.User1ESSDN, this.User1Password); Site.Assert.IsTrue(ret, "connect to public folder server should be successful"); uint publicFolderLogonHandler = this.OxoruleAdapter.RopLogon(LogonType.PublicFolder, this.User1ESSDN, out logonResponse); // Assert the client to log on to the public folder successfully. Site.Assert.AreEqual<uint>(0, logonResponse.ReturnValue, "Logon the public folder should be successful."); // Folder index 1 is the Interpersonal Messages subtree, and this is defined in MS-OXCSTOR. uint publicfolderHandler = this.OxoruleAdapter.RopOpenFolder(publicFolderLogonHandler, logonResponse.FolderIds[1], out openFolderResponse); // Get the store object's entry ID. this.GetStoreObjectEntryID(StoreObjectType.PublicFolder, this.Server, this.User1ESSDN); RopCreateFolderResponse createFolderResponse; string newFolderName = Common.GenerateResourceName(this.Site, Constants.FolderDisplayName); uint newFolderHandle = this.OxoruleAdapter.RopCreateFolder(publicfolderHandler, newFolderName, Constants.FolderComment, out createFolderResponse); ulong newFolderID = createFolderResponse.FolderId; Site.Assert.AreEqual<uint>(0, createFolderResponse.ReturnValue, "Creating folder operation should succeed."); #endregion #region TestUser1 creates an FAI message. RopCreateMessageResponse ropCreateMessageResponse; uint extendedRuleMessageHandle = this.OxoruleAdapter.RopCreateMessage(newFolderHandle, newFolderID, Convert.ToByte(true), out ropCreateMessageResponse); Site.Assert.AreEqual<uint>(0, ropCreateMessageResponse.ReturnValue, "Creating the first FAI message should succeed."); #endregion #region TestUser1 adds the extended rule with NamedProperty successfully. string ruleConditionSubjectNameForAdd = Constants.RuleConditionSubjectContainString; NamedPropertyInfo namedPropertyInfo = new NamedPropertyInfo { NoOfNamedProps = 2, PropId = new uint[2] { 0x8001, 0x8002 } }; PropertyName testPropertyName = new PropertyName { Guid = System.Guid.NewGuid().ToByteArray(), Kind = 0x01, Name = Encoding.Unicode.GetBytes(Constants.NameOfPropertyName + "\0") }; // 0x01 means the property is identified by the name property. testPropertyName.NameSize = (byte)testPropertyName.Name.Length; PropertyName secondPropertyName = new PropertyName { Guid = System.Guid.NewGuid().ToByteArray(), Kind = 0x00, LID = 0x88888888 }; // 0x00 means the property is identified by the LID. namedPropertyInfo.NamedProperty = new PropertyName[2] { testPropertyName, secondPropertyName }; namedPropertyInfo.NamedPropertiesSize = (uint)(testPropertyName.Serialize().Length + secondPropertyName.Serialize().Length); string ruleName = Common.GenerateResourceName(this.Site, Constants.ExtendRulename1); TaggedPropertyValue[] extendedRulePropertiesForAdd = AdapterHelper.GenerateExtendedRuleTestData(ruleName, 0, (uint)RuleState.ST_ENABLED, Constants.PidTagRuleProvider, ActionType.OP_MARK_AS_READ, new DeleteMarkReadActionData(), ruleConditionSubjectNameForAdd, namedPropertyInfo); // Set properties for extended rule FAI message. RopSetPropertiesResponse ropSetPropertiesResponse = this.OxoruleAdapter.RopSetProperties(extendedRuleMessageHandle, extendedRulePropertiesForAdd); Site.Assert.AreEqual<uint>(0, ropSetPropertiesResponse.ReturnValue, "Setting property for Extended rule FAI message should succeed."); // Save changes of message. RopSaveChangesMessageResponse ropSaveChangesMessagResponse = this.OxoruleAdapter.RopSaveChangesMessage(extendedRuleMessageHandle); Site.Assert.AreEqual<uint>(0, ropSaveChangesMessagResponse.ReturnValue, "Saving Extend rule message should succeed."); // Specify the properties to be got. PropertyTag[] propertyTagArray = new PropertyTag[1]; // PidTagRuleMessageProvider propertyTagArray[0].PropertyId = (ushort)PropertyId.PidTagRuleMessageProvider; propertyTagArray[0].PropertyType = (ushort)PropertyType.PtypString; // Get the specific properties of the extended rule. RopGetPropertiesSpecificResponse ropGetPropertiesSpecificResponse = this.OxoruleAdapter.RopGetPropertiesSpecific(extendedRuleMessageHandle, propertyTagArray); Site.Assert.AreEqual<uint>(0, ropGetPropertiesSpecificResponse.ReturnValue, "Getting specific properties operation should succeed."); string pidTagRuleMessageProviderData = AdapterHelper.PropertyValueConvertToString(ropGetPropertiesSpecificResponse.RowData.PropertyValues[0].Value); Site.Assert.AreEqual<string>(Constants.PidTagRuleProvider, pidTagRuleMessageProviderData, "The rule provider data should be RuleOrganizer."); #endregion #region Modify the created rule. ruleName = Common.GenerateResourceName(this.Site, Constants.ExtendRulename2); TaggedPropertyValue[] extendedRulePropertiesForModify = AdapterHelper.GenerateExtendedRuleTestData(ruleName, 0, (uint)RuleState.ST_ENABLED, Constants.PidTagRuleProvider, ActionType.OP_MARK_AS_READ, new DeleteMarkReadActionData(), ruleConditionSubjectNameForAdd, namedPropertyInfo); // Set properties for extended rule FAI message. ropSetPropertiesResponse = this.OxoruleAdapter.RopSetProperties(extendedRuleMessageHandle, extendedRulePropertiesForModify); Site.Assert.AreEqual<uint>(0, ropSetPropertiesResponse.ReturnValue, "Setting property for Extended rule FAI message should succeed."); // Save changes of message. ropSaveChangesMessagResponse = this.OxoruleAdapter.RopSaveChangesMessage(extendedRuleMessageHandle); Site.Assert.AreEqual<uint>(0, ropSaveChangesMessagResponse.ReturnValue, "Saving Extend rule message should succeed."); // PidTagSubject propertyTagArray[0].PropertyId = (ushort)PropertyId.PidTagRuleMessageName; propertyTagArray[0].PropertyType = (ushort)PropertyType.PtypString; // Get the specific properties of the extended rule. ropGetPropertiesSpecificResponse = this.OxoruleAdapter.RopGetPropertiesSpecific(extendedRuleMessageHandle, propertyTagArray); Site.Assert.AreEqual<uint>(0, ropGetPropertiesSpecificResponse.ReturnValue, "Getting specific properties operation should succeed."); string messageName = AdapterHelper.PropertyValueConvertToString(ropGetPropertiesSpecificResponse.RowData.PropertyValues[0].Value); Site.Assert.AreEqual<string>(ruleName, messageName, "The rule subject should be {0}.", ruleName); #endregion #region Release the created message to delete the created rule. this.OxoruleAdapter.ReleaseRop(extendedRuleMessageHandle); // Get the specific properties of the extended rule. ropGetPropertiesSpecificResponse = this.OxoruleAdapter.RopGetPropertiesSpecific(extendedRuleMessageHandle, propertyTagArray); Site.Assert.IsNull(ropGetPropertiesSpecificResponse.RowData, "The property value of the extended rule should be null!"); #endregion #region Delete the folder. RopDeleteFolderResponse deleteFolder = this.OxoruleAdapter.RopDeleteFolder(publicfolderHandler, newFolderID); Site.Assert.AreEqual<uint>(0, deleteFolder.ReturnValue, "Deleting folder should succeed."); #endregion }