Action Data buffer format for ActionType: OP_DEFER_ACTION
Наследование: IActionData
        public void MSOXORULE_S01_TC06_AddMoveCopyAndBounceDeferredrules()
        {
            this.CheckMAPIHTTPTransportSupported();

            #region TestUser1 prepares value for ruleProperties variable.
            RuleProperties ruleProperties = AdapterHelper.GenerateRuleProperties(this.Site, Constants.RuleNameBounce);
            #endregion

            #region TestUser1 adds Bounce rule.
            BounceActionData bounceActionData = new BounceActionData
            {
                Bounce = BounceCode.CanNotDisplay
            };

            RuleData ruleBounce = AdapterHelper.GenerateValidRuleData(ActionType.OP_BOUNCE, TestRuleDataType.ForAdd, 0, RuleState.ST_ENABLED, bounceActionData, ruleProperties, null);
            RopModifyRulesResponse ropModifyRulesResponse = this.OxoruleAdapter.RopModifyRules(this.InboxFolderHandle, ModifyRuleFlag.Modify_ReplaceAll, new RuleData[] { ruleBounce });
            Site.Assert.AreEqual<uint>(0, ropModifyRulesResponse.ReturnValue, "Adding Bounce rule should succeed.");
            #endregion

            #region TestUser1 adds Deferred Action rule.
            ruleProperties.Name = Common.GenerateResourceName(this.Site, Constants.RuleNameDeferredAction);
            DeferredActionData deferredActionData = new DeferredActionData
            {
                Data = Common.GetBytesFromBinaryHexString(Constants.DeferredActionBufferData)
            };
            RuleData deferredActionRuleData = AdapterHelper.GenerateValidRuleData(ActionType.OP_DEFER_ACTION, TestRuleDataType.ForAdd, 1, RuleState.ST_ENABLED, deferredActionData, ruleProperties, null);

            RopModifyRulesResponse modifyRulesResponse = this.OxoruleAdapter.RopModifyRules(this.InboxFolderHandle, ModifyRuleFlag.Modify_OnExisting, new RuleData[] { deferredActionRuleData });
            Site.Assert.AreEqual<uint>(0, modifyRulesResponse.ReturnValue, "Adding deferred action rule to public folder should succeed.");
            #endregion

            if (Common.IsRequirementEnabled(294, this.Site))
            {
                #region TestUser1 creates a folder in server store.
                RopCreateFolderResponse createFolderResponse;
                string user1FolderName = Common.GenerateResourceName(this.Site, "User1Folder");
                uint folderHandle = this.OxoruleAdapter.RopCreateFolder(this.InboxFolderHandle, user1FolderName, "TestForOP_COPY", out createFolderResponse);
                ulong folderId = createFolderResponse.FolderId;
                Site.Assert.AreEqual<uint>(0, createFolderResponse.ReturnValue, "Creating folder operation should succeed.");
                #endregion

                #region TestUser1 prepares rules' data.
                MoveCopyActionData moveCopyActionData = new MoveCopyActionData();

                // Get the created folder entry ID.
                byte[] folderEId = this.OxoruleAdapter.GetFolderEntryId(StoreObjectType.Mailbox, folderHandle, folderId);

                // Get the store object's entry ID.
                byte[] storeEId = this.GetStoreObjectEntryID(StoreObjectType.Mailbox, this.Server, this.User1ESSDN);
                moveCopyActionData.FolderEID = folderEId;
                moveCopyActionData.StoreEID = storeEId;
                moveCopyActionData.FolderEIDSize = (ushort)folderEId.Length;
                moveCopyActionData.StoreEIDSize = (ushort)storeEId.Length;
                #endregion

                #region TestUSer1 generates test RuleData.
                ruleProperties.Name = Common.GenerateResourceName(this.Site, Constants.RuleNameCopy);
                RuleData ruleForCopy = AdapterHelper.GenerateValidRuleData(ActionType.OP_COPY, TestRuleDataType.ForAdd, 2, RuleState.ST_ENABLED, moveCopyActionData, ruleProperties, null);

                // Add rule for move with rule Provider Data.
                ruleProperties.ProviderData = Constants.PidTagRuleProviderData;
                ruleProperties.Name = Common.GenerateResourceName(this.Site, Constants.RuleNameMoveOne);
                RuleData ruleForMove = AdapterHelper.GenerateValidRuleData(ActionType.OP_MOVE, TestRuleDataType.ForAdd, 3, RuleState.ST_ENABLED, moveCopyActionData, ruleProperties, null);
                #endregion

                #region TestUser1 adds OP_MOVE and OP_COPY rules to the Inbox folder.
                modifyRulesResponse = this.OxoruleAdapter.RopModifyRules(this.InboxFolderHandle, ModifyRuleFlag.Modify_OnExisting, new RuleData[] { ruleForMove, ruleForCopy });

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

                // Verify MS-OXORULE requirement: MS-OXORULE_R680.
                // If the return value of the RopModifyRules response is 0x00, it means operation is successfully.
                Site.CaptureRequirementIfAreEqual<uint>(
                    0x00000000,
                    modifyRulesResponse.ReturnValue,
                    680,
                    @"[In RopModifyRules ROP Response Buffer] ReturnValue: To indicate success, the server returns 0x00000000.");

                // Wait for the mail to be received and the rule to take effect.
                Thread.Sleep(this.WaitForTheRuleToTakeEffect);
                #endregion

                RopDeleteFolderResponse deleteFolder = this.OxoruleAdapter.RopDeleteFolder(this.InboxFolderHandle, folderId);
                Site.Assert.AreEqual<uint>(0, deleteFolder.ReturnValue, "Deleting folder should succeed.");
            }

            #region TestUser1 gets rows from the rule table.
            RopGetRulesTableResponse ropGetRulesTableResponse;
            uint ruleTableHandle = this.OxoruleAdapter.RopGetRulesTable(this.InboxFolderHandle, TableFlags.Normal, out ropGetRulesTableResponse);
            Site.Assert.AreEqual<uint>(0, ropGetRulesTableResponse.ReturnValue, "RopGetRulesTable operation should succeed.");

            PropertyTag[] propertyListTag = new PropertyTag[4];

            // PidTagRuleActions property.
            propertyListTag[0].PropertyId = (ushort)PropertyId.PidTagRuleActions;
            propertyListTag[0].PropertyType = (ushort)PropertyType.PtypRuleAction;
            propertyListTag[1].PropertyId = (ushort)PropertyId.PidTagRuleName;
            propertyListTag[1].PropertyType = (ushort)PropertyType.PtypString;
            propertyListTag[2].PropertyId = (ushort)PropertyId.PidTagRuleProvider;
            propertyListTag[2].PropertyType = (ushort)PropertyType.PtypString;
            propertyListTag[3].PropertyId = (ushort)PropertyId.PidTagRuleProviderData;
            propertyListTag[3].PropertyType = (ushort)PropertyType.PtypBinary;

            // Set the query target to standardardRules.
            this.OxoruleAdapter.TargetOfRop = TargetOfRop.ForStandardRules;

            RopQueryRowsResponse getAllActionsResponse = this.OxoruleAdapter.QueryPropertiesInTable(ruleTableHandle, propertyListTag);
            Site.Assert.AreEqual<uint>(0, getAllActionsResponse.ReturnValue, "Getting rule properties should succeed.");

            // When R294 is enabled, there should be 4 rules exist on Inbox folder, otherwise only 2 rules exist.
            // If the rule table is got successfully and the rule count is correct, it means that the server is returning a table with the rule added by the test suite.
            if (Common.IsRequirementEnabled(294, this.Site))
            {
                Site.Assert.AreEqual(4, getAllActionsResponse.RowCount, @"There should be 4 rules returned, actual returned row count is {0}.", getAllActionsResponse.RowCount);
            }
            else
            {
                Site.Assert.AreEqual(2, getAllActionsResponse.RowCount, @"There should be 2 rules returned, actual returned row count is {0}.", getAllActionsResponse.RowCount);
            }

            this.VerifyRuleTable();

            // Clear the status of the adapter.
            this.OxoruleAdapter.TargetOfRop = TargetOfRop.OtherTarget;
            #endregion
        }
Пример #2
0
        public void MSOXORULE_S04_TC04_AddNotSupportedRule_OnPublicFolder()
        {
            this.CheckMAPIHTTPTransportSupported();

            #region TestUser2 logs on to the public folder.
            RopOpenFolderResponse openFolderResponse;
            RopLogonResponse      logonResponse;
            bool ret = this.OxoruleAdapter.Connect(ConnectionType.PublicFolderServer, this.User2Name, this.User2ESSDN, this.User2Password);
            Site.Assert.IsTrue(ret, "connect to public folder server should be successful");
            uint publicFolderLogonHandler = this.OxoruleAdapter.RopLogon(LogonType.PublicFolder, this.User2ESSDN, 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);
            ulong publicFolderID      = logonResponse.FolderIds[1];
            #endregion

            #region TestUser2 tests the unsupported rules in public folder.
            #region TestUser2 prepares value for ruleProperties variable.
            RuleProperties ruleProperties = AdapterHelper.GenerateRuleProperties(this.Site, Constants.RuleNameDeferredAction);
            #endregion

            #region TestUser2 adds a Rule set Action Type to OP_DEFER_ACTION.
            DeferredActionData deferredActionData = new DeferredActionData
            {
                Data = Common.GetBytesFromBinaryHexString(Constants.DeferredActionBufferData)
            };
            RuleData deferredActionRuleData = AdapterHelper.GenerateValidRuleData(ActionType.OP_DEFER_ACTION, TestRuleDataType.ForAdd, 5, RuleState.ST_ENABLED, deferredActionData, ruleProperties, null);
            RopModifyRulesResponse ropModifyRulesResponse = this.OxoruleAdapter.RopModifyRules(publicfolderHandler, ModifyRuleFlag.Modify_ReplaceAll, new RuleData[] { deferredActionRuleData });
            #endregion

            // Add the debug information.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R258: server returned value is {0}", ropModifyRulesResponse.ReturnValue);

            // Verify MS-OXORULE requirement: MS-OXORULE_R258.
            // If the ReturnValue is not 0x00000000, it means the server failed to add a public folder rule with this OP_DEFER_ACTION Type action.
            // So it is not used in a public folder rule.
            bool isVerifyR258 = ropModifyRulesResponse.ReturnValue != 0x00000000;

            Site.CaptureRequirementIfIsTrue(
                isVerifyR258,
                258,
                @"[In ActionBlock Structure] The meaning of action type OP_DEFER_ACTION: MUST NOT be used in a public folder rule (4).");

            #region TestUser2 prepares rules' data.
            MoveCopyActionData moveCopyActionData = new MoveCopyActionData();

            // Get the Inbox folder entry ID.
            byte[] folderEId = this.OxoruleAdapter.GetFolderEntryId(StoreObjectType.PublicFolder, publicfolderHandler, publicFolderID);

            // Get the store object's entry ID.
            byte[] storeEId = this.GetStoreObjectEntryID(StoreObjectType.PublicFolder, this.Server, this.User1ESSDN);
            moveCopyActionData.FolderEID     = folderEId;
            moveCopyActionData.StoreEID      = storeEId;
            moveCopyActionData.FolderEIDSize = (ushort)folderEId.Length;
            moveCopyActionData.StoreEIDSize  = (ushort)storeEId.Length;
            #endregion

            #region TestUser2 prepares value for ruleProperties variable.
            ruleProperties = AdapterHelper.GenerateRuleProperties(this.Site, Constants.RuleNameMoveOne);
            #endregion

            #region TestUser2 adds OP_MOVE rule to the public folder.
            ruleProperties.Name = Common.GenerateResourceName(this.Site, Constants.RuleNameMoveOne);
            RuleData ruleForMove = AdapterHelper.GenerateValidRuleData(ActionType.OP_MOVE, TestRuleDataType.ForAdd, 0, RuleState.ST_ENABLED, moveCopyActionData, ruleProperties, null);
            RopModifyRulesResponse modifyRulesResponse = this.OxoruleAdapter.RopModifyRules(publicfolderHandler, ModifyRuleFlag.Modify_ReplaceAll, new RuleData[] { ruleForMove });
            #endregion

            // Add the debug information.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R839: server returned value is {0}", modifyRulesResponse.ReturnValue);

            // Verify MS-OXORULE requirement: MS-OXORULE_R839.
            // If the returnValue is not 0x00000000, it means this OP_MOVE Type used in a public folder rule is failed,
            // so it is not used in a public folder rule.
            bool isVerifyR839 = modifyRulesResponse.ReturnValue != 0x00000000;

            Site.CaptureRequirementIfIsTrue(
                isVerifyR839,
                839,
                @"[In ActionBlock Structure] The meaning of action type OP_MOVE: MUST NOT be used in a public folder rule (4).");

            #region TestUser2 adds OP_COPY rule to the public folder.
            ruleProperties.Name = Common.GenerateResourceName(this.Site, Constants.RuleNameMoveTwo);
            RuleData ruleForCopy = AdapterHelper.GenerateValidRuleData(ActionType.OP_COPY, TestRuleDataType.ForAdd, 1, RuleState.ST_ENABLED, moveCopyActionData, ruleProperties, null);
            modifyRulesResponse = this.OxoruleAdapter.RopModifyRules(publicfolderHandler, ModifyRuleFlag.Modify_ReplaceAll, new RuleData[] { ruleForCopy });
            #endregion

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R840: server returned value is {0}", modifyRulesResponse.ReturnValue);

            // Verify MS-OXORULE requirement: MS-OXORULE_R840.
            // If the ReturnValue is not 0x00000000, it means this OP_COPY Type used in a public folder rule is failed,
            // so it is not used in a public folder rule.
            bool isVerifyR840 = modifyRulesResponse.ReturnValue != 0x00000000;

            Site.CaptureRequirementIfIsTrue(
                isVerifyR840,
                840,
                @"[In ActionBlock Structure] The meaning of action type OP_COPY: MUST NOT be used in a public folder rule (4).");
            #endregion
        }
        public void MSOXORULE_S04_TC04_AddNotSupportedRule_OnPublicFolder()
        {
            this.CheckMAPIHTTPTransportSupported();

            #region TestUser2 logs on to the public folder.
            RopOpenFolderResponse openFolderResponse;
            RopLogonResponse logonResponse;
            bool ret = this.OxoruleAdapter.Connect(ConnectionType.PublicFolderServer, this.User2Name, this.User2ESSDN, this.User2Password);
            Site.Assert.IsTrue(ret, "connect to public folder server should be successful");
            uint publicFolderLogonHandler = this.OxoruleAdapter.RopLogon(LogonType.PublicFolder, this.User2ESSDN, 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);
            ulong publicFolderID = logonResponse.FolderIds[1];
            #endregion

            #region TestUser2 tests the unsupported rules in public folder.
            #region TestUser2 prepares value for ruleProperties variable.
            RuleProperties ruleProperties = AdapterHelper.GenerateRuleProperties(this.Site, Constants.RuleNameDeferredAction);
            #endregion

            #region TestUser2 adds a Rule set Action Type to OP_DEFER_ACTION.
            DeferredActionData deferredActionData = new DeferredActionData
            {
                Data = Common.GetBytesFromBinaryHexString(Constants.DeferredActionBufferData)
            };
            RuleData deferredActionRuleData = AdapterHelper.GenerateValidRuleData(ActionType.OP_DEFER_ACTION, TestRuleDataType.ForAdd, 5, RuleState.ST_ENABLED, deferredActionData, ruleProperties, null);
            RopModifyRulesResponse ropModifyRulesResponse = this.OxoruleAdapter.RopModifyRules(publicfolderHandler, ModifyRuleFlag.Modify_ReplaceAll, new RuleData[] { deferredActionRuleData });
            #endregion

            // Add the debug information.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R258: server returned value is {0}", ropModifyRulesResponse.ReturnValue);

            // Verify MS-OXORULE requirement: MS-OXORULE_R258.
            // If the ReturnValue is not 0x00000000, it means the server failed to add a public folder rule with this OP_DEFER_ACTION Type action.
            // So it is not used in a public folder rule.
            bool isVerifyR258 = ropModifyRulesResponse.ReturnValue != 0x00000000;

            Site.CaptureRequirementIfIsTrue(
                isVerifyR258,
                258,
                @"[In ActionBlock Structure] The meaning of action type OP_DEFER_ACTION: MUST NOT be used in a public folder rule (2).");

            #region TestUser2 prepares rules' data.
            MoveCopyActionData moveCopyActionData = new MoveCopyActionData();

            // Get the Inbox folder entry ID.
            byte[] folderEId = this.OxoruleAdapter.GetFolderEntryId(StoreObjectType.PublicFolder, publicfolderHandler, publicFolderID);

            // Get the store object's entry ID.
            byte[] storeEId = this.GetStoreObjectEntryID(StoreObjectType.PublicFolder, this.Server, this.User1ESSDN);
            moveCopyActionData.FolderEID = folderEId;
            moveCopyActionData.StoreEID = storeEId;
            moveCopyActionData.FolderEIDSize = (ushort)folderEId.Length;
            moveCopyActionData.StoreEIDSize = (ushort)storeEId.Length;
            #endregion

            #region TestUser2 prepares value for ruleProperties variable.
            ruleProperties = AdapterHelper.GenerateRuleProperties(this.Site, Constants.RuleNameMoveOne);
            #endregion

            #region TestUser2 adds OP_MOVE rule to the public folder.
            ruleProperties.Name = Common.GenerateResourceName(this.Site, Constants.RuleNameMoveOne);
            RuleData ruleForMove = AdapterHelper.GenerateValidRuleData(ActionType.OP_MOVE, TestRuleDataType.ForAdd, 0, RuleState.ST_ENABLED, moveCopyActionData, ruleProperties, null);
            RopModifyRulesResponse modifyRulesResponse = this.OxoruleAdapter.RopModifyRules(publicfolderHandler, ModifyRuleFlag.Modify_ReplaceAll, new RuleData[] { ruleForMove });
            #endregion

            // Add the debug information.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R839: server returned value is {0}", modifyRulesResponse.ReturnValue);

            // Verify MS-OXORULE requirement: MS-OXORULE_R839.
            // If the returnValue is not 0x00000000, it means this OP_MOVE Type used in a public folder rule is failed,
            // so it is not used in a public folder rule.
            bool isVerifyR839 = modifyRulesResponse.ReturnValue != 0x00000000;

            Site.CaptureRequirementIfIsTrue(
                isVerifyR839,
                839,
                @"[In ActionBlock Structure] The meaning of action type OP_MOVE: MUST NOT be used in a public folder rule (2).");

            #region TestUser2 adds OP_COPY rule to the public folder.
            ruleProperties.Name = Common.GenerateResourceName(this.Site, Constants.RuleNameMoveTwo);
            RuleData ruleForCopy = AdapterHelper.GenerateValidRuleData(ActionType.OP_COPY, TestRuleDataType.ForAdd, 1, RuleState.ST_ENABLED, moveCopyActionData, ruleProperties, null);
            modifyRulesResponse = this.OxoruleAdapter.RopModifyRules(publicfolderHandler, ModifyRuleFlag.Modify_ReplaceAll, new RuleData[] { ruleForCopy });
            #endregion

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R840: server returned value is {0}", modifyRulesResponse.ReturnValue);

            // Verify MS-OXORULE requirement: MS-OXORULE_R840.
            // If the ReturnValue is not 0x00000000, it means this OP_COPY Type used in a public folder rule is failed,
            // so it is not used in a public folder rule.
            bool isVerifyR840 = modifyRulesResponse.ReturnValue != 0x00000000;

            Site.CaptureRequirementIfIsTrue(
                isVerifyR840,
                840,
                @"[In ActionBlock Structure] The meaning of action type OP_COPY: MUST NOT be used in a public folder rule (2).");
            #endregion
        }