コード例 #1
0
ファイル: ARunFrequentlyTask.cs プロジェクト: enif77/TaskMan
        /// <summary>
        /// Calculates the NextRunAt based on the DateTime.Now property.
        /// </summary>
        /// <param name="isFirstRun">If true, this task will run for the first time. (Is being scheduled.)</param>
        /// <returns>True, if a new run time was calculated.</returns>
        public override bool UpdateNextRunAt(bool isFirstRun)
        {
            var now = DateTime.Now;

            // If this task was never executed, or if it was executed long time ago.
            if (LatstExecutionTime < now.AddMinutes(-(MinutesBetweenRuns * 2)))
            {
                // Long time ago, so schedule it for now.
                LatstExecutionTime = now.AddMinutes(-MinutesBetweenRuns);

                // If the RunAt is set to something in the future, use it.
                if (LatstExecutionTime < RunAt)
                {
                    LatstExecutionTime = RunAt.AddMinutes(-MinutesBetweenRuns);
                }
            }

            var atTime = LatstExecutionTime.AddMinutes(MinutesBetweenRuns);

            // We missed the time, lets do it later.
            while (now > atTime)
            {
                atTime = atTime.AddMinutes(MinutesBetweenRuns);
            }

            NextRunAt = atTime;

            return(true);
        }
コード例 #2
0
ファイル: TestData.cs プロジェクト: killbug2004/WSProf
		public List<Snapshot> Run(IPolicyEngineFactory agent, ProcessLevel level, RunAt runAt, bool forceGc)
		{
			GC.Collect();
			GC.WaitForPendingFinalizers();
			GC.Collect();

			IContentScanner scanner = agent.CreateContentScanner(null);
			IContentEnforcer enforcer = m_Enforce ? agent.CreateContentEnforcer(null) : null;
			List<Snapshot> snapshots = new List<Snapshot>();

			for (int iteration = 0; iteration < m_Iterations; ++iteration)
			{
				snapshots.Add(new Snapshot("PreLoadRequest", forceGc));
				Request request = ContractSerialization.LoadRequest(m_RequestPath);
				snapshots.Add(new Snapshot("PreScan", forceGc));
				Response response = scanner.Scan(request, null, level, runAt);

				if (enforcer != null)
				{
					snapshots.Add(new Snapshot("PreEnforce", forceGc));
					enforcer.Enforce(request, response);
					snapshots.Add(new Snapshot("PostEnforce", forceGc));
				}
				else
				{
					snapshots.Add(new Snapshot("PostScan", forceGc));
				}
			}

			snapshots.Add(new Snapshot("PostGcFinal", true));

			return snapshots;
		}
コード例 #3
0
ファイル: Action.cs プロジェクト: killbug2004/WSProf
 private void SetDefaults(string assembly, string className, RunAt runAtMode, bool overrideMode, int precedence, bool readOnly)
 {
     m_assembly = assembly;
     m_className = className;
     m_runAtMode = runAtMode;
     m_override = overrideMode;
     m_precedence = precedence;
     m_dataElements = new PolicyObjectCollection<IDataElement>(readOnly);
     m_fileTypes = new PolicyObjectCollection<IActionFiletype>(readOnly);
 }
コード例 #4
0
        public TimeSpan?DetermininateNextRun()
        {
            var now = DateTime.UtcNow;

            if (_lastRun.Date == DateTime.UtcNow.Date)
            {
                var nextRun = RunAt.Add(new TimeSpan(1, 0, 0, 0)).Subtract(now.TimeOfDay);
                return(nextRun);
            }

            return(RunAt - now.TimeOfDay);
        }
コード例 #5
0
		private void Initialise(RunAt[] runat, PolicyType[] policytype)
		{
			if (runat != null)
			{
				runAtHints.AddRange(runat);
			}

			if (policytype != null)
			{
				policyTypeHints.AddRange(policytype);
			}
		}
コード例 #6
0
 public AbstractUserActionInstaller(RunAt[] runat, PolicyType[] policytype)
 {
     if (runat != null)
         foreach (RunAt r in runat)
         {
             runAtHints.Add(r);
         }
     if (policytype != null)
         foreach (PolicyType p in policytype)
         {
             policyTypeHints.Add(p);
         }
 }
コード例 #7
0
 public bool Equals(ScheduledJob other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Id == other.Id && Priority == other.Priority && Attempts == other.Attempts &&
            string.Equals(LastError, other.LastError) &&
            RunAt.Equals(other.RunAt) && SucceededAt.Equals(other.SucceededAt) && FailedAt.Equals(other.FailedAt) &&
            LockedAt.Equals(other.LockedAt) && string.Equals(LockedBy, other.LockedBy) &&
            CreatedAt.Equals(other.CreatedAt) && UpdatedAt.Equals(other.UpdatedAt));
 }
コード例 #8
0
ファイル: UroPolicyEngine.cs プロジェクト: killbug2004/WSProf
		public void Monitor(RunAt runat, IUniversalRequestObject uro, bool ProcessRoutingsAlso)
		{
			try
			{
				IPolicyResponseObject upi = ProcessConditions(runat, uro);
				if (ProcessRoutingsAlso)
					ProcessRoutings(upi);
			}
			catch (System.Exception e)
			{
				Logger.LogError(e);
#if DEBUG
				Logger.LogError(PolicyResponseLogHelper.GetDisplayNames(m_Pro));
#endif
				throw;
			}
		}
コード例 #9
0
ファイル: PerfTestHelp.cs プロジェクト: killbug2004/WSProf
        /// <summary>
        /// Gets the response time (in millisec) for the engine to process the given file.
        /// </summary>
        /// <param name="filePath">The file you are testing</param>
        /// <returns>measurement in milliseconds</returns>
        internal static long GetResponseTimeForFile(IContentScanner scanner, string filePath, ProcessLevel level, RunAt runAt)
        {
            using (var cs = new ContractSerialization())
            {
                Request request = cs.LoadRequest(filePath);

                Response response = null;

                TimeSpan timeSpan = Measure(delegate()
                                                {
                                                    response = scanner.Scan(request, null, level, runAt);
                                                });

                AssertValidResponse(response); //Essential to validate, but it should not be part of what is timed.

                return Convert.ToInt64(timeSpan.TotalMilliseconds);
            }
        }
コード例 #10
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Id;
         hashCode = (hashCode * 397) ^ Priority;
         hashCode = (hashCode * 397) ^ Attempts;
         hashCode = (hashCode * 397) ^ (LastError != null ? LastError.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ RunAt.GetHashCode();
         hashCode = (hashCode * 397) ^ SucceededAt.GetHashCode();
         hashCode = (hashCode * 397) ^ FailedAt.GetHashCode();
         hashCode = (hashCode * 397) ^ LockedAt.GetHashCode();
         hashCode = (hashCode * 397) ^ (LockedBy != null ? LockedBy.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ CreatedAt.GetHashCode();
         hashCode = (hashCode * 397) ^ UpdatedAt.GetHashCode();
         return(hashCode);
     }
 }
コード例 #11
0
ファイル: UroPolicyEngine.cs プロジェクト: killbug2004/WSProf
		public IUniversalRequestObject Enforce(RunAt runat, IUniversalRequestObject uro)
		{
			try
			{
				IPolicyResponseObject upi = ProcessConditions(runat, uro);
				ProcessRoutings(upi);
				ProcessActions(upi);
				uro = ExecuteActions(upi);

				return uro;
			}
			catch (System.Exception e)
			{
				Logger.LogError(e);
#if DEBUG
				Logger.LogError(PolicyResponseLogHelper.GetDisplayNames(m_Pro));
#endif
				throw;
			}
		}
コード例 #12
0
		public BaseContentScanner(string name, IPolicySetVersionCache cache, PolicyType policyType, string runAt)
		{
			SkipDiscovery = false;
			m_policySetName = name;
			m_cache = cache; //keep it for cloning.

			m_runAt = (RunAt) Enum.Parse(typeof(RunAt), runAt);
			m_policyType = policyType;

			string channel = GetChannelForPolicyType(policyType);

			//Get the primary compiled cache
			ICompiledPolicySetCache icpsc = cache.GetCompiledPolicySet(channel, runAt);
			m_gpp = InitialiseGPP(icpsc);

			//For performance, a separate cache is available for messages with 0 attachments - this will be passed to a 
			//separate policy processor.  
			if (PolicyType.ClientEmail == policyType ||
				PolicyType.Mta == policyType)
			{
				foreach (ICompiledPolicySetCache compiled in cache.CompiledPolicySets)
				{
					//Ignore any other channels that we come across.
					if (channel != compiled.Channel)
						continue;

					//Perfect matches on 'target' should be discarded - we already found the primary cache in the call to GetCompiledPolicySet.
					if (0 == string.Compare(runAt, compiled.Target, StringComparison.InvariantCultureIgnoreCase))
						continue;

					if (compiled.Target.Contains(runAt))
					{
						m_zeroAttachmentGpp = InitialiseGPP(compiled);
						break;
						//Assumes that (for example) the 'Client - reduced policy set' compiled cache will always contain the word 'Client'
					}
				}
			}
		}
コード例 #13
0
ファイル: ContentScanner.cs プロジェクト: killbug2004/WSProf
		public Response Scan(Request request, string user, ProcessLevel level, RunAt runat)
		{
			Logger.LogDebug(Properties.Resources.LOG_SCAN_BEGIN);

			if (PolicyCache.Instance().IsCacheEmpty)
			{
				Logger.LogInfo(Properties.Resources.LOG_CATEGORY_NO_MATCHES);
				return null;
			}
						
			try
			{
				return HandleContentScanning(request, user, level, runat, SkipDiscovery, TotalAttachmentSize);
			}
			catch (Exception ex)
			{
				Logger.LogError(ex);
                return ErrorResponse(ex);
			}
			finally
			{
				Logger.LogDebug(Properties.Resources.LOG_SCAN_END);
			}
		}
コード例 #14
0
		private void ProcessFileAgainstPolicyEngines(PolicyResponseObject pro, RunAt runat, string[] addresses, ContentItem contentItem)
		{
			try
			{
				ChannelType channel = PolicyTypeMappings.Lookup[pro.UniversalRequestObject.PolicyType];

				Dictionary<string, PolicyEngine> engines = m_policyEngineCache.GetPolicyEnginesForChannel(channel.ToString());
				foreach (KeyValuePair<string, PolicyEngine> policyEnginePair in engines)
				{
					AddressUtilities.SetPolicyEngineAddresses(pro, policyEnginePair.Value, addresses);

					Logger.LogDebug("About to process: " + policyEnginePair.Key.ToString() + "/" + contentItem.File.DisplayName);
#if DEBUG
					Logger.LogDebug(PolicyResponseLogHelper.GetDisplayNames(pro));
#endif

					OnPolicyProgress(new ExecuteEventArgs(null, "", status.Started));

					policyEnginePair.Value.ProcessFileInfo(runat, contentItem);
				}
			}
			catch (System.Exception ex)
			{
				Logger.LogError(ex);
#if DEBUG
				Logger.LogError(PolicyResponseLogHelper.GetDisplayNames(pro));
#endif

				throw new ProcessConditionsException(contentItem.File.DisplayName, ex.Message, ex);
			}
		}
コード例 #15
0
		public PolicyResponseObject Process(RunAt runat, IUniversalRequestObject uro, out IContainer container)
		{
			if (null == uro)
				throw new PolicyEngineException("An invalid Universal Request Object was passed to the PolicyEngine.");

			PolicyResponseObject pro = new PolicyResponseObject();
			pro.RunAt = runat;
			pro.UniversalRequestObject = uro;
			pro.PolicyType = uro.PolicyType;
			pro.ChannelDetail = uro.Properties.ContainsKey("RequestChannel") ? uro.Properties["RequestChannel"] : "";

			// Conditions may use some routing information
			// hence it is populated here.
			PopulateRoutingInfo(pro);

			Logger.LogDebug(PolicyResponseLogHelper.BuildUroMessage("ProcessConditions. input uro: ", uro));

			OnPolicyProgress(new ExecuteEventArgs(null, "", status.Started));

			ChannelType channel = PolicyTypeMappings.Lookup[uro.PolicyType];

			m_policyEngineCache.SetPolicyEnginesCompiledPolicySetCache(pro, channel.ToString());

			Logger.LogDebug("Process Conditions: PolicySetCacheSet");
#if DEBUG
			Logger.LogDebug(PolicyResponseLogHelper.GetDisplayNames(pro));
#endif

			OnPolicyProgress(new ExecuteEventArgs(null, "", status.Started));

			Logger.LogDebug("Process Conditions: Properties Added");
#if DEBUG
			Logger.LogDebug(PolicyResponseLogHelper.GetDisplayNames(pro));
#endif

			AddFiles(pro, out container);

			Logger.LogDebug("Process Conditions: Files Added");
#if DEBUG
			Logger.LogDebug(PolicyResponseLogHelper.GetDisplayNames(pro));
#endif
			OnPolicyProgress(new ExecuteEventArgs(null, "", status.Started));

			string[] addresses = AddressUtilities.GetRecipientAddressList(pro);

			Logger.LogDebug("Process Conditions: Addresses Set");
#if DEBUG
			Logger.LogDebug(PolicyResponseLogHelper.GetDisplayNames(pro));
#endif

			OnPolicyProgress(new ExecuteEventArgs(null, "", status.Started));

			if (0 == m_policyEngineCache.GetPolicyEnginesForChannel(channel.ToString()).Count)
			{
				Logger.LogInfo("Warning: Processing content against no policy sets.");

				return pro;
			}

			Logger.LogDebug("Process Conditions: About to process fileinfo objects");
#if DEBUG
			Logger.LogDebug(PolicyResponseLogHelper.GetDisplayNames(pro));
#endif
			foreach (ContentItem fi in pro.ContentCollection)
			{
				StartPerformanceCounterForFileType(fi.File.FileType);

				ProcessFileAgainstPolicyEngines(pro, runat, addresses, fi);

				StopPerformanceCounterForFileType(fi.File.FileType, fi.Size);
			}

			Logger.LogDebug("Process Conditions: Completed");
#if DEBUG
			Logger.LogDebug(PolicyResponseLogHelper.GetDisplayNames(pro));
#endif
			return pro;
		}
コード例 #16
0
ファイル: PolicyEngine.cs プロジェクト: killbug2004/WSProf
        /// <summary>
        /// </summary>
        public void ProcessFileInfo(RunAt runat, IContentItem fileinfo)
        {
            if (fileinfo == null)
            {
                Utilities.ErrorMessage errorMessage = new Utilities.ErrorMessage(
                    "INVALID_FILE",
                    "Workshare.Policy.Engine.Properties.Resources",
                    Assembly.GetExecutingAssembly());
                Logger.LogError(errorMessage.LogString);
                throw new PolicyEngineException(errorMessage.DisplayString);
            }
            if (m_CompiledPolicySetCache == null)
            {
                Utilities.ErrorMessage errorMessage = new Utilities.ErrorMessage(
                    "POLICYSET_UNINITIALISED",
                    "Workshare.Policy.Engine.Properties.Resources",
                    Assembly.GetExecutingAssembly());
				Logger.LogError(errorMessage.LogString);
				throw new PolicyEngineException(errorMessage.DisplayString);
            }
            
            string objectsxml = m_CompiledPolicySetCache.ObjectReferences;
            string rulesxml = m_CompiledPolicySetCache.Content;
            string languagexml = GetCurrentCulturesLanguageFile();

            if (languagexml != "") // This is to maintain backward compatibility with old rules files.
            {
                PolicySetLanguageMerger lm = new PolicySetLanguageMerger();
                rulesxml = lm.Merge(rulesxml, languagexml);
            }

            m_GeneralPolicyProcessor.Initialise(runat, rulesxml, objectsxml);

            m_GeneralPolicyProcessor.ProcessFileInfo(fileinfo);
        }
コード例 #17
0
ファイル: UroPolicyEngine.cs プロジェクト: killbug2004/WSProf
		public IPolicyResponseObject ProcessPolicies(RunAt runat, IUniversalRequestObject uro, Workshare.Policy.Interfaces.ProcessLevel level)
		{
			try
			{
				PerformanceCounters.Instance.StartTimer(PerformanceCounters.CounterType.Total);
				PerformanceCounters.Instance.StartTimer(PerformanceCounters.CounterType.Policy_Process);

				IPolicyResponseObject upi = null;

				if (level >= Workshare.Policy.Interfaces.ProcessLevel.Expressions)
					upi = ProcessConditions(runat, uro);

				if (level >= Workshare.Policy.Interfaces.ProcessLevel.Routing)
					ProcessRoutings(upi);

				if (level >= Workshare.Policy.Interfaces.ProcessLevel.Actions)
					ProcessActions(upi);

				PerformanceCounters.Instance.StopTimer(PerformanceCounters.CounterType.Policy_Process, 0);

				double requestsize = 0;
				foreach (ContentItem fi in upi.ContentCollection)
					requestsize += fi.File.FileSize;

				PerformanceCounters.Instance.StopTimer(PerformanceCounters.CounterType.Total, requestsize);

				return upi;
			}
			catch (System.Exception e)
			{
				Logger.LogError(e);
#if DEBUG
				Logger.LogError(PolicyResponseLogHelper.GetDisplayNames(m_Pro));
#endif
				throw;
			}
		}
コード例 #18
0
		/// <summary>
		/// Asserts the IPolicyResponse data for the Swearing policy in ComplexPolicySet
		/// </summary>
		/// <param name="policyResponse">The IPolicyResponse object to evaluate</param>
		/// <param name="expectedTriggered">The expected value of the Triggered property on the IPolicyResponse object</param>
		private void AssertSwearingPolicyResponse_ComplexPolicySet(IPolicyResponse policyResponse, bool expectedTriggered, RunAt runAt)
		{
			//data on PolicyResponse
			Assert.AreEqual("Don't swear", policyResponse.Name, "Incorrect name on policy response");
			Assert.AreEqual("Any document containing swearing will be blocked.", policyResponse.Description, "Incorrect description on policy response");
			Assert.AreEqual(expectedTriggered, policyResponse.Triggered, "Incorrect triggered on policy response");
			Assert.AreEqual(false, policyResponse.Audit, "Incorrect audit on policy response");
			Assert.AreEqual(1, policyResponse.ExpressionCollection.Count, "Incorrect number of expression responses on policy response");

			//data on PolicyResponse.ExpressionCollection[0]
			IExpressionResponse expressionResponse = policyResponse.ExpressionCollection[0];
			Assert.AreEqual("You shouldn't swear.", expressionResponse.Description, "Incorrect description on expression response");
			Assert.AreEqual("Swearing detected", expressionResponse.Name, "Incorrect name on expression response");
			Assert.AreEqual("Medium", expressionResponse.Rating, "Incorrect rating on expression response");
			Assert.AreEqual(expectedTriggered, expressionResponse.Triggered, "Incorrect triggered on expression response");
			Assert.AreEqual(0, expressionResponse.Properties.Count, "Incorrect number of properties on expression response");

			//data on PolicyReposponse.ExpressionCollection[0].ExpressionDetailCollection[0]
			if (expectedTriggered)
			{
				Assert.AreEqual(1, expressionResponse.ExpressionDetailCollection.Count, "Incorrect number of expression details on expression response");
				IExpressionDetail expressionDetail = expressionResponse.ExpressionDetailCollection[0];
				Assert.AreEqual("Paragraph", expressionDetail.Name, "Incorrect name on expression detail");
				Assert.AreEqual("swearing", expressionDetail.Value, "Incorrect value on expression detail");
			}
			else
			{
				Assert.AreEqual(0, expressionResponse.ExpressionDetailCollection.Count, "Incorrect number of expression details on expression response");
			}

			//data on PolicyResponse.Routing
			IRoutingResponse routingResponse = policyResponse.Routing;
			if (expectedTriggered)
			{
				Assert.AreEqual(null, routingResponse.Description, "Incorrect description on routing response"); //ok, as this is an optional property
				Assert.AreEqual("Sent to External Recipients", routingResponse.Name, "Incorrect name on routing response");
				Assert.AreEqual("Low", routingResponse.Rating, "Incorrect rating on routing response");
				Assert.AreEqual(0, routingResponse.Properties.Count, "Incorrect number of properties on routing response");
			}
			else
			{
				Assert.IsNull(routingResponse, "Incorrect routing response on policy response");
			}

			//data on PolicyResponse.ActionCollection
			if (expectedTriggered)
			{
				if (RunAt.Client == runAt)
				{
					//only expect actions if running on client
					Assert.AreEqual(2, policyResponse.ActionCollection.Count, "Incorrect number of policy response action objects on policy response");

					IPolicyResponseAction policyResponseAction = policyResponse.ActionCollection[0];
					Assert.AreEqual("Block Action", policyResponseAction.Name, "Incorrect name on policy response action");
					Assert.AreEqual("Block", policyResponseAction.Type, "Incorrect type on policy response action");
					Assert.AreEqual(false, policyResponseAction.Overridden, "Incorrect overridden on policy response action");
					Assert.AreEqual(true, policyResponseAction.Processed, "Incorrect processed on policy response action");
					Assert.AreEqual(1, policyResponseAction.Properties.Count, "Incorrect number of properties on policy response action");
					Assert.AreEqual("False", policyResponseAction.Properties["ExceptionAction"], "Incorrect number of properties on policy response action");

					//data on PolicyResponse.ActionCollection[0].ActionPropertyCollection
					Assert.AreEqual(2, policyResponseAction.ActionPropertyCollection.Count, "Incorrect number of properties on policy response action");
					IActionPropertyResponse actionPropertyResponse = policyResponseAction.ActionPropertyCollection[0];
					Assert.AreEqual("EXECUTE", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[1];
					Assert.AreEqual("Description", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("Can't send because of searing", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");

					policyResponseAction = policyResponse.ActionCollection[1];
					Assert.AreEqual("Block Action", policyResponseAction.Name, "Incorrect name on policy response action");
					Assert.AreEqual("Block", policyResponseAction.Type, "Incorrect type on policy response action");
					Assert.AreEqual(false, policyResponseAction.Overridden, "Incorrect overridden on policy response action");
					Assert.AreEqual(false, policyResponseAction.Processed, "Incorrect processed on policy response action");
					Assert.AreEqual(1, policyResponseAction.Properties.Count, "Incorrect number of properties on policy response action");
					Assert.AreEqual("True", policyResponseAction.Properties["ExceptionAction"], "Incorrect number of properties on policy response action");

					//data on PolicyResponse.ActionCollection[1].ActionPropertyCollection
					Assert.AreEqual(2, policyResponseAction.ActionPropertyCollection.Count, "Incorrect number of properties on policy response action");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[0];
					Assert.AreEqual("EXECUTE", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[1];
					Assert.AreEqual("Description", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("Exception action", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
				}
				else
				{
					//only expect actions if running on client
					Assert.AreEqual(0, policyResponse.ActionCollection.Count, "Incorrect number of policy response action objects on policy response");
				}
			}
			else
			{
				Assert.IsNull(policyResponse.ActionCollection, "Incorrect number of policy response action objects on policy response");
			}
		}
コード例 #19
0
		/// <summary>
		/// Asserts the IPolicyResponse data for the ZipBigFile policy in ComplexPolicySet
		/// </summary>
		/// <param name="policyResponse">The IPolicyResponse object to evaluate</param>
		/// <param name="expectedTriggered">The expected value of the Triggered property on the IPolicyResponse object</param>
		private void AssertZipBigFilePolicyResponse_ComplexPolicySet(IPolicyResponse policyResponse, bool expectedTriggered, RunAt runAt)
		{
			//data on PolicyResponse
			Assert.AreEqual("Zip big files", policyResponse.Name, "Incorrect name on policy response");
			Assert.AreEqual("", policyResponse.Description, "Incorrect description on policy response");
			Assert.AreEqual(expectedTriggered, policyResponse.Triggered, "Incorrect triggered on policy response");
			Assert.AreEqual(false, policyResponse.Audit, "Incorrect audit on policy response");
			Assert.AreEqual(1, policyResponse.ExpressionCollection.Count, "Incorrect number of expression responses on policy response");

			//data on PolicyResponse.ExpressionCollection[0]
			IExpressionResponse expressionResponse = policyResponse.ExpressionCollection[0];
			Assert.AreEqual("", expressionResponse.Description, "Incorrect description on expression response");
			Assert.AreEqual("File > 200k", expressionResponse.Name, "Incorrect name on expression response");
			Assert.AreEqual("Medium", expressionResponse.Rating, "Incorrect rating on expression response");
			Assert.AreEqual(expectedTriggered, expressionResponse.Triggered, "Incorrect triggered on expression response");
			Assert.AreEqual(0, expressionResponse.Properties.Count, "Incorrect number of properties on expression response");

			//data on PolicyResponse.ExpressionCollection[0].ExpressionDetailCollection[0]
			if (expectedTriggered)
			{
				Assert.AreEqual(1, expressionResponse.ExpressionDetailCollection.Count, "Incorrect number of expression details on expression response");
				IExpressionDetail expressionDetail = expressionResponse.ExpressionDetailCollection[0];
				Assert.AreEqual("ConditionSummary", expressionDetail.Name, "Incorrect name on expression detail");
				Assert.AreEqual("File size is greater than 200Kb", expressionDetail.Value, "Incorrect value on expression detail");
			}
			else
			{
				if ((null != policyResponse.ActionCollection) && !HasZipAction(policyResponse.ActionCollection))
				{
					Assert.Fail("Incorrect number of policy response action objects on policy response");
				}
			}

			//data on PolicyResponse.Routing
			IRoutingResponse routingResponse = policyResponse.Routing;
			if (expectedTriggered)
			{
				Assert.AreEqual(null, routingResponse.Description, "Incorrect description on routing response"); //ok, as this is an optional property
				Assert.AreEqual("Sent to External Recipients", routingResponse.Name, "Incorrect name on routing response");
				Assert.AreEqual("Low", routingResponse.Rating, "Incorrect rating on routing response");
				Assert.AreEqual(0, routingResponse.Properties.Count, "Incorrect number of properties on routing response");
			}
			else
			{
				if ((null != policyResponse) && (null != policyResponse.ActionCollection) && !HasZipAction(policyResponse.ActionCollection))
				{
					Assert.Fail("Incorrect routing response on policy response");
				}
			}

			//data on PolicyResponse.ActionCollection
			if (expectedTriggered)
			{
				if (RunAt.Client == runAt)
				{
					//only expect actions if running on client
					Assert.AreEqual(2, policyResponse.ActionCollection.Count, "Incorrect number of policy response action objects on policy response");

					IPolicyResponseAction policyResponseAction = policyResponse.ActionCollection[0];
					Assert.AreEqual("Zip Action", policyResponseAction.Name, "Incorrect name on policy response action");
					Assert.AreEqual("Zip", policyResponseAction.Type, "Incorrect type on policy response action");
					Assert.AreEqual(false, policyResponseAction.Overridden, "Incorrect overridden on policy response action");
					Assert.AreEqual(false, policyResponseAction.Processed, "Incorrect processed on policy response action");
					Assert.AreEqual(1, policyResponseAction.Properties.Count, "Incorrect number of properties on policy response action");
					Assert.AreEqual("False", policyResponseAction.Properties["ExceptionAction"], "Incorrect number of properties on policy response action");

					//data on PolicyResponse.ActionCollection[0].ActionPropertyCollection
					Assert.AreEqual(7, policyResponseAction.ActionPropertyCollection.Count, "Incorrect number of properties on policy response action");
					IActionPropertyResponse actionPropertyResponse = policyResponseAction.ActionPropertyCollection[0];
					Assert.AreEqual("EXECUTE", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[1];
					Assert.AreEqual("PasswordRequired", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("False", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[2];
					Assert.AreEqual("EnforceStrongPassword", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("False", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[3];
					Assert.AreEqual("Password", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[4];
					Assert.AreEqual("ZIPAttachedFiles", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("False", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[5];
					Assert.AreEqual("AES128", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("False", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");

					policyResponseAction = policyResponse.ActionCollection[1];
					Assert.AreEqual("Block Action", policyResponseAction.Name, "Incorrect name on policy response action");
					Assert.AreEqual("Block", policyResponseAction.Type, "Incorrect type on policy response action");
					Assert.AreEqual(false, policyResponseAction.Overridden, "Incorrect overridden on policy response action");
					Assert.AreEqual(false, policyResponseAction.Processed, "Incorrect processed on policy response action");
					Assert.AreEqual(1, policyResponseAction.Properties.Count, "Incorrect number of properties on policy response action");
					Assert.AreEqual("True", policyResponseAction.Properties["ExceptionAction"], "Incorrect number of properties on policy response action");

					//data on PolicyResponse.ActionCollection[1].ActionPropertyCollection
					Assert.AreEqual(2, policyResponseAction.ActionPropertyCollection.Count, "Incorrect number of properties on policy response action");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[0];
					Assert.AreEqual("EXECUTE", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[1];
					Assert.AreEqual("Description", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("Exception action", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
				}
				else
				{
					//only expect actions if running on client
					Assert.AreEqual(0, policyResponse.ActionCollection.Count, "Incorrect number of policy response action objects on policy response");
				}
			}
			else
			{
				if ((null != policyResponse.ActionCollection) && !HasZipAction(policyResponse.ActionCollection))
				{
					Assert.Fail("Incorrect number of policy response action objects on policy response");
				}
			}        
		}
コード例 #20
0
ファイル: TestRun.cs プロジェクト: varapreddy/Minerva
 public string GetHumanRunAt()
 {
     return(RunAt.Humanize());
 }
コード例 #21
0
		/// <summary>
		/// Testing of Test PRO Policy Set.policy. Asserts all the data within Test PRO Policy Set.policy. 
		/// </summary>
		/// <param name="engineRunAt">Determines whether the engine should run as server or client</param>
		private void AssertProPolicySet(RunAt engineRunAt)
		{
			// This test has the mail message and 5 attachments. The policies are:
			// Clean doc/ppt/xls
			// PDF doc
			// Block "swearing"
			// Alert "test"
			// Zip > 200k

			DateTime startDate = DateTime.Now;

			//test setup
			string[] policySetFile = new string[] { Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\Projects\Hygiene\src\TestDocuments\Test PRO Policy Set.policy") };
			Workshare.Policy.Engine.UroPolicyEngine policyEngine = CreatePolicyEngineWithRealPolicy(policySetFile);
			Assert.IsTrue(1 == policyEngine.PolicyCache.PolicySets.Count, "Test setup failure - expected one policyset");
			UniversalRequestObject uro = TestHelpers.GetUro(false);

			TestHelpers.AddAttachment(uro, "Doc", Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\TestDocuments\Swearing.doc"), "Swearing.doc");
			TestHelpers.AddAttachment(uro, "Xls", Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\TestDocuments\small.xls"), "small.xls");
			TestHelpers.AddAttachment(uro, "Ppt", Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\TestDocuments\test.ppt"), "test.ppt");
			TestHelpers.AddAttachment(uro, "Xls", Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\TestDocuments\big.xls"), "big.xls");
			TestHelpers.AddAttachment(uro, "txt", Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\TestDocuments\test.txt"), "test.txt");
			
			IPolicyResponseObject pro = policyEngine.ProcessPolicies(engineRunAt, uro, ProcessLevel.Actions);
			DateTime endDate = DateTime.Now;

			//ok, now for the testing...

			//PolicyResponseObject data on pro
			//Assert.AreEqual(ChannelType.SMTP, pro.ChannelType, "Incorrect channel type on policy response object");
			Assert.AreEqual(4, pro.Properties.Count, "Incorrect number of properties on policy response object");
			Assert.IsTrue((startDate <= pro.ResponseDate) && (endDate >= pro.ResponseDate), "Incorrect response date on policy response object");
			Assert.AreEqual(engineRunAt, pro.RunAt, "Incorrect runat on policy response object");

			//PolicyResponseObject data on pro.Properties
			Assert.AreEqual("Stuff", pro.Properties["FileHeader"], "Incorrect FileHeader property on pro");
			Assert.AreEqual("4408 0412 3456 7890", pro.Properties["Body"], "Incorrect Body property on pro");
			Assert.AreEqual("Subject line", pro.Properties["Subject"], "Incorrect Subject property on pro");
			Assert.AreEqual(string.Empty, pro.Properties["Attachments"], "Incorrect Attachments property on pro");

			//RoutingInformation data
			Assert.AreEqual(2, pro.RoutingInformation.Count, "Incorrect number of routing entities");

			//RoutingInformation data on pro.RoutingInformation[0]
			IUniversalRoutingEntity routingEntity = pro.RoutingInformation[0];
			Assert.AreEqual("Source", routingEntity.RoutingType, "Incorrect routing type");
			Assert.AreEqual(PolicyType.ClientEmail, routingEntity.PolicyType, "Incorrect request type");

			//RoutingInformation data on pro.RoutingInformation[0].Items[0]
			IRoutingItem routingItem = routingEntity.Items[0];
			Assert.AreEqual("*****@*****.**", routingItem.Content, "Incorrect content on routing item");
			Assert.AreEqual(1, routingItem.Properties.Count, "Incorrect number of properties on routing item");
			//Assert.AreEqual(null, routingItem.Properties["DisplayName"], "Incorrect DisplayName property on routing item");
			Assert.AreEqual("From", routingItem.Properties["AddressType"], "Incorrect AddressType property on routing item");

			//RoutingInformation data on pro.RoutingInformation[1]
			routingEntity = pro.RoutingInformation[1];
			Assert.AreEqual("Destination", routingEntity.RoutingType, "Incorrect routing type");
			Assert.AreEqual(PolicyType.ClientEmail, routingEntity.PolicyType, "Incorrect request type");
			Assert.AreEqual(4, routingEntity.Items.Count, "Incorrect number of routing items");

			//RoutingInformation data on pro.RoutingInformation[1].Items[0]
			routingItem = routingEntity.Items[0];
			Assert.AreEqual("sam test", routingItem.Content, "Incorrect content on routing item");
			Assert.AreEqual(1, routingItem.Properties.Count, "Incorrect number of properties on routing item");
			//Assert.AreEqual(null, routingItem.Properties["DisplayName"], "Incorrect DisplayName property on routing item");
			Assert.AreEqual("To", routingItem.Properties["AddressType"], "Incorrect AddressType property on routing item");

			//RoutingInformation data on pro.RoutingInformation[1].Items[1]
			routingItem = routingEntity.Items[1];
			Assert.AreEqual("*****@*****.**", routingItem.Content, "Incorrect content on routing item");
			Assert.AreEqual(1, routingItem.Properties.Count, "Incorrect number of properties on routing item");
			//Assert.AreEqual(null, routingItem.Properties["DisplayName"], "Incorrect DisplayName property on routing item");
			Assert.AreEqual("CC", routingItem.Properties["AddressType"], "Incorrect AddressType property on routing item");

			//RoutingInformation data on pro.RoutingInformation[1].Items[2]
			routingItem = routingEntity.Items[2];
			Assert.AreEqual("*****@*****.**", routingItem.Content, "Incorrect content on routing item");
			Assert.AreEqual(1, routingItem.Properties.Count, "Incorrect number of properties on routing item");
			//Assert.AreEqual(null, routingItem.Properties["DisplayName"], "Incorrect DisplayName property on routing item");
			Assert.AreEqual("CC", routingItem.Properties["AddressType"], "Incorrect AddressType property on routing item");

			//RoutingInformation data on pro.RoutingInformation[1].Items[3]
			routingItem = routingEntity.Items[3];
			Assert.AreEqual("*****@*****.**", routingItem.Content, "Incorrect content on routing item");
			Assert.AreEqual(1, routingItem.Properties.Count, "Incorrect number of properties on routing item");
			//Assert.AreEqual(null, routingItem.Properties["DisplayName"], "Incorrect DisplayName property on routing item");
			Assert.AreEqual("BCC", routingItem.Properties["AddressType"], "Incorrect AddressType property on routing item");

			//ContentList data
			Assert.AreEqual(6, pro.ContentCollection.Count, "Incorrect number of content items in content list");

			//ContentList data on pro.ContentCollection[0] - email
			IContentItem contentItem = pro.ContentCollection[0];
			Assert.IsFalse(contentItem.Encrypted, "Incorrect encryption on content item");
			Assert.AreEqual("message subject/body", contentItem.Name, "Incorrect name on content item");
			Assert.AreEqual(408.0, contentItem.Size, "Incorrect size on content item");
			Assert.AreEqual("Email", contentItem.Type, "Incorrect type on content item");
			Assert.AreEqual(2, contentItem.Properties.Count, "Incorrect number of properties on content item");
			Assert.AreEqual(1, contentItem.PolicySetCollection.Count, "Incorrect number of policy set response objects on content item");
			//ContentList data on pro.ContentCollection[0].Properties
			Assert.AreEqual("Subject line", contentItem.Properties["Subject"], "Incorrect property on content item");
			//ContentList data on pro.ContentCollection[0].PolicySetCollection[0]
			IPolicySetResponse policySetResponse = contentItem.PolicySetCollection[0];
			AssertPolicySetResponse_ComplexPolicySet(policySetResponse, startDate, endDate);
			//ContentList data on pro.ContentCollection[0].PolicySetCollection[0].PolicyReportCollection
			AssertCleanOfficeDocPolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[0], false, engineRunAt);
			AssertSwearingPolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[1], false, engineRunAt);
			AssertConvertWordToPdfPolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[2], false, engineRunAt);
			AssertZipBigFilePolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[3], false, engineRunAt);
			AssertTestPolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[4], false, engineRunAt, null);

			//ContentList data on pro.ContentCollection[1] - swearing.doc
			contentItem = pro.ContentCollection[1];
			Assert.IsFalse(contentItem.Encrypted, "Incorrect encryption on content item");
			Assert.AreEqual("Swearing.doc", Path.GetFileName(contentItem.Name), "Incorrect name on content item");
			Assert.AreEqual(19968.0, contentItem.Size, "Incorrect size on content item");
			Assert.AreEqual("WordDocument", contentItem.Type, "Incorrect type on content item");
			Assert.AreEqual(1, contentItem.Properties.Count, "Incorrect number of properties on content item");
			Assert.AreEqual(1, contentItem.PolicySetCollection.Count, "Incorrect number of policy set response objects on content item");
			//ContentList data on pro.ContentCollection[1].PolicySetCollection[0]
			policySetResponse = contentItem.PolicySetCollection[0];
			AssertPolicySetResponse_ComplexPolicySet(policySetResponse, startDate, endDate);
			//ContentList data on pro.ContentCollection[1].PolicySetCollection[0].PolicyReportCollection
			AssertCleanOfficeDocPolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[0], true, engineRunAt);
			AssertSwearingPolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[1], true, engineRunAt);
			AssertConvertWordToPdfPolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[2], true, engineRunAt);
			AssertZipBigFilePolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[3], false, engineRunAt);
			AssertTestPolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[4], false, engineRunAt, null);

			//ContentList data on pro.ContentCollection[2] - small.xls
			contentItem = pro.ContentCollection[2];
			Assert.IsFalse(contentItem.Encrypted, "Incorrect encryption on content item");
			Assert.AreEqual("small.xls", Path.GetFileName(contentItem.Name), "Incorrect name on content item");
			Assert.AreEqual(13824.0, contentItem.Size, "Incorrect size on content item");
			Assert.AreEqual("ExcelSheet", contentItem.Type, "Incorrect type on content item");
			Assert.AreEqual(1, contentItem.Properties.Count, "Incorrect number of properties on content item");
			Assert.AreEqual(1, contentItem.PolicySetCollection.Count, "Incorrect number of policy set response objects on content item");
			//ContentList data on pro.ContentCollection[2].PolicySetCollection[0]
			policySetResponse = contentItem.PolicySetCollection[0];
			AssertPolicySetResponse_ComplexPolicySet(policySetResponse, startDate, endDate);
			//ContentList data on pro.ContentCollection[2].PolicySetCollection[0].PolicyReportCollection
			AssertCleanOfficeDocPolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[0], true, engineRunAt);
			AssertSwearingPolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[1], false, engineRunAt);
			AssertConvertWordToPdfPolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[2], false, engineRunAt);
			AssertZipBigFilePolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[3], false, engineRunAt);
			AssertTestPolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[4], false, engineRunAt, null);

			//ContentList data on pro.ContentCollection[3] - test.ppt
			contentItem = pro.ContentCollection[3];
			Assert.IsFalse(contentItem.Encrypted, "Incorrect encryption on content item");
			Assert.AreEqual("test.ppt", Path.GetFileName(contentItem.Name), "Incorrect name on content item");
			Assert.AreEqual(9728.0, contentItem.Size, "Incorrect size on content item");
			Assert.AreEqual("PowerPoint", contentItem.Type, "Incorrect type on content item");
			Assert.AreEqual(1, contentItem.Properties.Count, "Incorrect number of properties on content item");
			Assert.AreEqual(1, contentItem.PolicySetCollection.Count, "Incorrect number of policy set response objects on content item");
			//ContentList data on pro.ContentCollection[3].PolicySetCollection[0]
			policySetResponse = contentItem.PolicySetCollection[0];
			AssertPolicySetResponse_ComplexPolicySet(policySetResponse, startDate, endDate);
			//ContentList data on pro.ContentCollection[3].PolicySetCollection[0].PolicyReportCollection
			AssertCleanOfficeDocPolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[0], true, engineRunAt);
			AssertSwearingPolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[1], false, engineRunAt);
			AssertConvertWordToPdfPolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[2], false, engineRunAt);
			AssertZipBigFilePolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[3], false, engineRunAt);
			AssertTestPolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[4], true, engineRunAt, "TextBox");

			//ContentList data on pro.ContentCollection[4] - big.xls
			contentItem = pro.ContentCollection[4];
			Assert.IsFalse(contentItem.Encrypted, "Incorrect encryption on content item");
			Assert.AreEqual("big.xls", Path.GetFileName(contentItem.Name), "Incorrect name on content item");
			Assert.AreEqual(224256.0, contentItem.Size, "Incorrect size on content item");
			Assert.AreEqual("ExcelSheet", contentItem.Type, "Incorrect type on content item");
			Assert.AreEqual(1, contentItem.Properties.Count, "Incorrect number of properties on content item");
			Assert.AreEqual(1, contentItem.PolicySetCollection.Count, "Incorrect number of policy set response objects on content item");
			//ContentList data on pro.ContentCollection[4].PolicySetCollection[0]
			policySetResponse = contentItem.PolicySetCollection[0];
			AssertPolicySetResponse_ComplexPolicySet(policySetResponse, startDate, endDate);
			//ContentList data on pro.ContentCollection[4].PolicySetCollection[0].PolicyReportCollection
			AssertCleanOfficeDocPolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[0], true, engineRunAt);
			AssertSwearingPolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[1], false, engineRunAt);
			AssertConvertWordToPdfPolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[2], false, engineRunAt);
			AssertZipBigFilePolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[3], true, engineRunAt);
			AssertTestPolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[4], false, engineRunAt, null);

			//ContentList data on pro.ContentCollection[5] - test.txt
			contentItem = pro.ContentCollection[5];
			Assert.IsFalse(contentItem.Encrypted, "Incorrect encryption on content item");
			Assert.AreEqual("test.txt", Path.GetFileName(contentItem.Name), "Incorrect name on content item");
			Assert.AreEqual(155.0, contentItem.Size, "Incorrect size on content item");
			Assert.AreEqual("TextDocument", contentItem.Type, "Incorrect type on content item");
			Assert.AreEqual(1, contentItem.Properties.Count, "Incorrect number of properties on content item");
			Assert.AreEqual(1, contentItem.PolicySetCollection.Count, "Incorrect number of policy set response objects on content item");
			//ContentList data on pro.ContentCollection[5].PolicySetCollection[0]
			policySetResponse = contentItem.PolicySetCollection[0];
			AssertPolicySetResponse_ComplexPolicySet(policySetResponse, startDate, endDate);
			//ContentList data on pro.ContentCollection[5].PolicySetCollection[0].PolicyReportCollection
			AssertCleanOfficeDocPolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[0], false, engineRunAt);
			AssertSwearingPolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[1], false, engineRunAt);
			AssertConvertWordToPdfPolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[2], false, engineRunAt);
			AssertZipBigFilePolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[3], false, engineRunAt);
			AssertTestPolicyResponse_ComplexPolicySet(policySetResponse.PolicyReportCollection[4], true, engineRunAt, "Paragraph");

			//ResolvedActionsList
			if (RunAt.Server == engineRunAt)
			{
				Assert.AreEqual(0, pro.ResolvedActionCollection.Count, "Incorrect number of resolved actions");
			}
			else
			{
				Assert.IsTrue(pro.ResolvedActionCollection.Count == 5, "5 actions should have been triggered");

				bool cleanTriggered = false;
				bool alertTriggered = false;
				bool blockTriggered = false;
				bool pdfTriggered = false;
				bool zipTriggered = false;
				foreach (IResolvedAction resolvedAction in pro.ResolvedActionCollection)
				{
					// The Clean action should should have been applied to 4 files (Swearing.doc, test.ppt, small.xls and big.xls)
					if (resolvedAction.ResponseAction.Type == "Clean")
					{
						Assert.IsFalse(cleanTriggered, "Clean action occurs more than once in the resolved action list");
						cleanTriggered = true;
						Assert.IsTrue(resolvedAction.ContentCollection.Count == 4, "Clean action should have been applied 4 times");
						Assert.AreEqual("Swearing.doc", Path.GetFileName(resolvedAction.ContentCollection[0].Name));
						Assert.AreEqual("small.xls", Path.GetFileName(resolvedAction.ContentCollection[1].Name));
						Assert.AreEqual("test.ppt", Path.GetFileName(resolvedAction.ContentCollection[2].Name));
						Assert.AreEqual("big.xls", Path.GetFileName(resolvedAction.ContentCollection[3].Name));
						continue;
					}
					// The PDF action should have been applied to 1 file (Swearing.doc)
					if (resolvedAction.ResponseAction.Type == "PDF")
					{
						Assert.IsFalse(pdfTriggered, "PDF action occurs more than once in the resolved action list");
						pdfTriggered = true;
						Assert.IsTrue(resolvedAction.ContentCollection.Count == 1, "PDF action should have been applied 1 time");
						Assert.AreEqual("Swearing.doc", Path.GetFileName(resolvedAction.ContentCollection[0].Name));
						continue;
					}

					// The Block action should have been applied on all the files (even though it was triggered by just Swearing.doc)
					if (resolvedAction.ResponseAction.Type == "Block")
					{
						Assert.IsFalse(blockTriggered, "Block action occurs more than once in the resolved action list");
						blockTriggered = true;
						Assert.AreEqual(5, resolvedAction.ContentCollection.Count, "Block action should have been applied 5 times");
						Assert.AreEqual("Swearing.doc", Path.GetFileName(resolvedAction.ContentCollection[0].Name));
						Assert.AreEqual("small.xls", Path.GetFileName(resolvedAction.ContentCollection[1].Name));
						Assert.AreEqual("test.ppt", Path.GetFileName(resolvedAction.ContentCollection[2].Name));
						Assert.AreEqual("big.xls", Path.GetFileName(resolvedAction.ContentCollection[3].Name));
						Assert.AreEqual("test.txt", Path.GetFileName(resolvedAction.ContentCollection[4].Name));
						continue;
					}

					// The Alert action should have been applied on 2 files (test.ppt and test.txt)
					if (resolvedAction.ResponseAction.Type == "Alert")
					{
						Assert.IsFalse(alertTriggered, "Alert action occurs more than once in the resolved action list");
						alertTriggered = true;
						Assert.AreEqual(2, resolvedAction.ContentCollection.Count, "Alert action should have been applied 2 times");
						Assert.AreEqual("test.ppt", Path.GetFileName(resolvedAction.ContentCollection[0].Name));
						Assert.AreEqual("test.txt", Path.GetFileName(resolvedAction.ContentCollection[1].Name));
						continue;
					}

					// The Zip action should have been applied on 1 file (big.xls)
					if (resolvedAction.ResponseAction.Type == "Zip")
					{
						Assert.IsFalse(zipTriggered, "Zip action occurs more than once in the resolved action list");
						zipTriggered = true;
						Assert.AreEqual(1, resolvedAction.ContentCollection.Count, "Zip action should have been applied once");
						Assert.AreEqual("big.xls", Path.GetFileName(resolvedAction.ContentCollection[0].Name));
						continue;
					}
				}

				Assert.IsTrue(cleanTriggered, "Clean action not triggered");
				Assert.IsTrue(blockTriggered, "Block action not triggered");
				Assert.IsTrue(pdfTriggered, "PDF action not triggered");
				Assert.IsTrue(zipTriggered, "Zip action not triggered");
				Assert.IsTrue(alertTriggered, "Alert action not triggered");
			}
		}
コード例 #22
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            ActionUIItem auii = comboBoxActions.SelectedItem as ActionUIItem;
            if (auii == null)
                return;

            m_baseAction = auii.ActionName;
            m_myName = textBoxMyName.Text;

            ActionObjectDefinition aoDef = m_actions[((ActionUIItem)comboBoxActions.SelectedItem).ActionName];
            m_assemblyName = aoDef.AssemblyName;
            m_className = aoDef.ClassName;
			m_baseAction = aoDef.Type;
			m_basePrecedence = GetSequenceFromResourceActionForType(m_baseAction);
            m_precedence = aoDef.Precedence;			

            m_runAt = ConvertRunAt(comboBoxRunAt.SelectedItem.ToString());

            m_listItems = new Dictionary<string, ActionDataElement>();            
            foreach (ListViewItem lvi in actionOptionsListView.Items)
            {
                if (lvi.Tag.ToString().CompareTo("Select All") == 0 ||
                    lvi.Tag.ToString().CompareTo("Separator") == 0)
                    continue;

                Guid id = (Guid) lvi.Tag;

                ActionDataElement ade = m_displayedActionDataElements[id];
                Control embeddedControl = actionOptionsListView.GetEmbeddedControl(1, lvi.Index);
                if (embeddedControl != null && embeddedControl.GetType().Name == "TextBox")
                {
                    ade.Value = embeddedControl.Text;
                }
                else if (embeddedControl != null && embeddedControl.GetType().Name == "CheckBox")
                {
                    ade.Value = ((CheckBox)embeddedControl).Checked;
                }
                else if (embeddedControl != null && embeddedControl.GetType().Name == "DateTimePicker")
                {
                    ade.Value = ((DateTimePicker)embeddedControl).Value;
                }
                else if (embeddedControl != null && embeddedControl.GetType().Name == "CheckedListBox")
                {
                    ade.Value = GetStringsFromCheckedListBox((CheckedListBox)embeddedControl);
                }
                else if (embeddedControl != null && embeddedControl.GetType().Name == "ButtonWithValue")
                {
                    ade.Value = (embeddedControl as ButtonWithValue).Value;
                }
                else
                {
                    ade.IsDataSource = (aoDef.ActionProperties[id].Value is IDataSource);
                    ade.IsSystemProperty = (aoDef.ActionProperties[id].Value is ISystemProperty);
                    ade.Value = aoDef.ActionProperties[id].Value;
                }

                if (actionOptionsListView.Columns.Count > 2)
                {
                    CheckBox checkBox = actionOptionsListView.GetEmbeddedControl(2, lvi.Index) as CheckBox;
                    ade.Override = checkBox.Checked;
                    checkBox = actionOptionsListView.GetEmbeddedControl(3, lvi.Index) as CheckBox;
                    ade.Visible = checkBox.Checked;
                }

                ade.Name = aoDef.ActionProperties[id].Name;
                ade.DisplayName = aoDef.ActionProperties[id].DisplayName;
                ade.Identifier = id;

                m_listItems[lvi.Text] = ade;
            }

            //now, get the ActionDataElements that we chose not to display. These won't have changed.
            foreach (Guid key in m_nonDisplayedActionDataElements.Keys)
            {
                ActionDataElement ade = m_nonDisplayedActionDataElements[key]; 
                //ade.IsDataSource = (ade.Value is IDataSource);
                //ade.IsSystemProperty = (ade.Value is ISystemProperty);

                m_listItems[ade.DisplayName] = ade;
            }

            m_fileItems = new Dictionary<string, ActionFiletype>();
            foreach (ListViewItem item in fileTypesListView.Items)
            {
                Guid guid = (Guid)item.Tag;
                //TODO: shouldn't have our own file type enumeration in the policy designer!
				Workshare.Policy.FileType designerFileType = FileTypeBridge.GetFileType(item.Text.ToString());
                FileType fileType = (FileType)Enum.Parse(typeof(FileType), designerFileType.ToString());
                ActionFiletype fType = new ActionFiletype(guid, fileType, true);
                m_fileItems[fileType.ToString()] = fType;
            }

            GetSupportedPoliciesForActionForType(m_baseAction);

            Transparent = cbProcessTransparently.Checked;
            //AutoExpand = cbAutoExpand.Checked;
            ExecutionOption = ((ExecutionOptionItem)cmbExecutionOption.SelectedItem).ExecutionOption;
        }
コード例 #23
0
ファイル: ContentScanner.cs プロジェクト: killbug2004/WSProf
		private static Response HandleContentScanning(Request request, string user, ProcessLevel level, RunAt runat, bool skipDiscovery, Int64 totalAttachmentSize)
		{
			PolicyType policyType = (PolicyType)Enum.Parse(typeof(PolicyType), request.PolicyType );

			List<string> users = new List<string>();
			users.Add(user);

			Collection<Lease<EngineLookupKey, IBaseContentScanner>> scanners = PolicyCacheManager.Instance.GetScanners(
					policyType,
					users.ToArray(),
					runat.ToString());

			if ( 0 == scanners.Count )
			{
				string userParam = string.IsNullOrEmpty(user) ? "NULL" : user;

				Logger.LogInfo( string.Format(CultureInfo.InvariantCulture, Properties.Resources.LOG_CATEGORY_NO_MATCHES, policyType.ToString(), userParam));

				return new Response();
			}

			List<IDisposable> disposeList = new List<IDisposable>();
			try
			{
				IUniversalRequestObject uro = RequestAdaptor.GetURO(request);
				
				disposeList.Add(uro as IDisposable);

                List<IPolicyResponseObject> pros = new List<IPolicyResponseObject>();

                bool verified = VerifyRequest(request);

                foreach (Lease<EngineLookupKey, IBaseContentScanner> scannerLease in scanners)
                {
                    using (scannerLease)
                    {
                        IBaseContentScanner scanner = scannerLease.Object;
                        if (scanner != null)
                        {
                            scanner.TotalAttachmentSize = totalAttachmentSize;
                        }
                        IPolicyResponseObject pro = GetPolicyResponseFromScanner(scannerLease.Object, uro, level, skipDiscovery);

                        if (verified)
                            pro.VerifiedOnClient = true;

                        pros.Add(pro);
                        disposeList.Add(pro as IDisposable);
                        scannerLease.Object.PrepareForRecycle();
                    }
                }

                IPolicyResponseObject consolidatedPro = PROConsolidator.Consolidate(pros);

                disposeList.Add(consolidatedPro as IDisposable);

                UpdateIncidentProperties(consolidatedPro);
                Response result = ResponseAdaptor.GetResponse(consolidatedPro);

                //Copy Routing over from Request
                result.Routing = new RoutingEntity[] { request.Source, request.Destination };

                PopulateRunAt(result, runat);

                DocumentReaderCache.Instance.Clear();

                RemoveExpressionDetail(result);
				return result;
			}
			finally
			{
				foreach (IDisposable disposable in disposeList)
				{
					if ( disposable != null)
						disposable.Dispose();
				}
				disposeList.Clear();
			}
		}
コード例 #24
0
ファイル: ContentScanner.cs プロジェクト: killbug2004/WSProf
		private static void PopulateRunAt(Response response, RunAt runat)
		{
			List<CustomProperty> props = new List<CustomProperty>(response.Properties);
			
			props.Add( new CustomProperty("RunAt", runat.ToString()));

			response.Properties = props.ToArray();
		}
コード例 #25
0
ファイル: Attributes.cs プロジェクト: kod3r/il2js
 public RunAtAttribute(RunAt runAt)
 {
     this.RunAt = runAt;
 }
コード例 #26
0
 public static void AddExecutionTarget(XmlNode actionClassNode, string capabilitiesOrSettings, RunAt[] executionTargets)
 {
     XmlDocument xmlDocument = actionClassNode.OwnerDocument;
     XmlNode executionTargetsNode = xmlDocument.CreateElement(capabilitiesOrSettings);
     foreach (RunAt executionTarget in executionTargets)
     {
         XmlNode runAtNode = xmlDocument.CreateElement("RunAt");
         runAtNode.InnerText = executionTarget.ToString();
         executionTargetsNode.AppendChild(runAtNode);
     }
     actionClassNode.AppendChild(executionTargetsNode);
 }
コード例 #27
0
		private void TestPolicyResponseObject_ServerActions(RunAt engineRunningAs)
		{
			//We assume that much of the data is correct - we test all the data in the PolicyResponseObject 
			//in TestPolicyResponseObject_ClientActionsOnClient and TestPolicyResponseObject_ClientActionsOnServer
			//All we're particularly interested in here is that server actions are not returned by the engine running as a client

			//test setup
			DateTime startDate = DateTime.Now;
			string[] policySetFile = new string[] { Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\Projects\Hygiene\src\TestDocuments\ServerActionsPolicySet.policy") };
			Workshare.Policy.Engine.UroPolicyEngine policyEngine = CreatePolicyEngineWithRealPolicy(policySetFile);
			Assert.IsTrue(1 == policyEngine.PolicyCache.PolicySets.Count, "Test setup failure - expected one policyset");
			UniversalRequestObject uro = TestHelpers.GetUro(false);
			uro.Source.Properties.Add(SMTPPropertyKeys.RequestChannel, "Outlook");
			uro.Destination.Properties.Add(SMTPPropertyKeys.RequestChannel, "Outlook");
			TestHelpers.AddAttachment(uro, "Doc", Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\TestDocuments\TestProfanity.doc"), "TestProfanity.doc");
			IPolicyResponseObject pro = policyEngine.ProcessPolicies(engineRunningAs, uro, ProcessLevel.Actions);
			DateTime endDate = DateTime.Now;

			//ok, now for the testing...

			//PolicyResponseObject data on pro
			//Assert.AreEqual(ChannelType.SMTP, pro.ChannelType, "Incorrect channel type on policy response object");
			Assert.AreEqual(4, pro.Properties.Count, "Incorrect number of properties on policy response object");
			Assert.IsTrue((startDate <= pro.ResponseDate) && (endDate >= pro.ResponseDate), "Incorrect response date on policy response object");
			Assert.AreEqual(engineRunningAs, pro.RunAt, "Incorrect runat on policy response object");

			//PolicyResponseObject data on pro.Properties
			Assert.AreEqual("Stuff", pro.Properties["FileHeader"], "Incorrect FileHeader property on pro");
			Assert.AreEqual("4408 0412 3456 7890", pro.Properties["Body"], "Incorrect Body property on pro");
			Assert.AreEqual("Subject line", pro.Properties["Subject"], "Incorrect Subject property on pro");
			Assert.AreEqual(string.Empty, pro.Properties["Attachments"], "Incorrect Attachments property on pro");

			//RoutingInformation data
			Assert.AreEqual(2, pro.RoutingInformation.Count, "Incorrect number of routing entities");
			//don't care about testing the rest or the routing contents here

			//ContentList data
			Assert.AreEqual(2, pro.ContentCollection.Count, "Incorrect number of content items in content list");

			//ContentList data on pro.ContentCollection[1] - swearing.doc
			IContentItem contentItem = pro.ContentCollection[1];
			Assert.IsFalse(contentItem.Encrypted, "Incorrect encryption on content item");
			Assert.AreEqual("TestProfanity.doc", Path.GetFileName(contentItem.Name), "Incorrect name on content item");
			Assert.AreEqual(24064.0, contentItem.Size, "Incorrect size on content item");
			Assert.AreEqual("WordDocument", contentItem.Type, "Incorrect type on content item");
			Assert.AreEqual(1, contentItem.Properties.Count, "Incorrect number of properties on content item");
			Assert.AreEqual(1, contentItem.PolicySetCollection.Count, "Incorrect number of policy set response objects on content item");

			//ContentList data on pro.ContentCollection[0].PolicySetCollection[0]
			IPolicySetResponse policySetResponse = contentItem.PolicySetCollection[0];

			//triggered policy has action data. TestProfanity.doc, Profanity policy
			Assert.IsTrue(policySetResponse.PolicyReportCollection[2].Triggered, "Incorrect triggered on policy response");
			if (engineRunningAs == RunAt.Server)
			{
				Assert.IsTrue(2 == policySetResponse.PolicyReportCollection[2].ActionCollection.Count, "Incorrect action collection on policy response");
			}
			else
			{
				Assert.IsTrue(0 == policySetResponse.PolicyReportCollection[2].ActionCollection.Count, "Incorrect action collection on policy response");
			}

			//untriggered policy has null action collection. TestProfanity.doc, Confidential and Financial policy
			Assert.IsFalse(policySetResponse.PolicyReportCollection[0].Triggered, "Incorrect triggered on policy response");
			Assert.IsNull(policySetResponse.PolicyReportCollection[0].ActionCollection, "Incorrect action collection on policy response");

			//ResolvedActionList
			if (engineRunningAs == RunAt.Server)
			{
				Assert.IsTrue(1 == pro.ResolvedActionCollection.Count, "Incorrect count on pro.ResolvedActionCollection");
			}
			else
			{
				Assert.IsTrue(0 == pro.ResolvedActionCollection.Count, "Incorrect count on pro.ResolvedActionCollection");
			}
		}
コード例 #28
0
        /// <summary>
        /// Converts a RunAt enumeration to a localised displayable value
        /// </summary>
        /// <param name="runAt">The RunAt enumeration to evaluate</param>
        /// <returns>The localised displayable representation of the RunAt enumeration</returns>
        private string ConvertRunAt(RunAt runAt)
        {
            switch (runAt)
            {
                case RunAt.Client: return Properties.Resources.RUNAT_CLIENT;
                case RunAt.Server: return Properties.Resources.RUNAT_SERVER;
                case RunAt.Both: return Properties.Resources.RUNAT_BOTH;
                default:
                    ErrorMessage errorMessage = new ErrorMessage(
                        "RUNAT_INVALID",
                        "Workshare.PolicyDesigner.Properties.Resources",
                        Assembly.GetExecutingAssembly());
                    Logger.LogError(errorMessage.LogString);
					throw new Exception(errorMessage.DisplayString);
            }
        }
コード例 #29
0
		private void TestPolicyResponseObject_ClientServerActions(RunAt engineRunningAs)
		{
			// This test had me baffled and I felt like running out the door with my hands in the air.
			// To save you the same torture, here is what you have to do.
			//
			// If this test fails, do the following:
			//  1) Stop the service - "Workshare Client Caching Service"
			//  2) Rename C:\Documents and Settings\All Users\Application Data\Workshare\Protect Enterprise\Policy.Resources
			//     to C:\Documents and Settings\All Users\Application Data\Workshare\Protect Enterprise\Policy.Resources.back
			//  3) Copy P:\Projects\Hygiene\src\TestDocuments\ServerActionsPolicySet.Resources 
			//     to C:\Documents and Settings\All Users\Application Data\Workshare\Protect Enterprise\Policy.Resources
			//  4) Restart the service - "Workshare Client Caching Service"
			//  5) Open P:\Projects\Hygiene\src\TestDocuments\ServerActionsPolicySet.policy in the Policy Designer and 
			//     republish it.
			//  6) Close Policy Designer
			//  7) Stop the service - "Workshare Client Caching Service"
			//  8) Delete C:\Documents and Settings\All Users\Application Data\Workshare\Protect Enterprise\Policy.Resources
			//  9) Rename C:\Documents and Settings\All Users\Application Data\Workshare\Protect Enterprise\Policy.Resources.back
			//     to C:\Documents and Settings\All Users\Application Data\Workshare\Protect Enterprise\Policy.Resources
			// 10) Restart the service - "Workshare Client Caching Service"
			// 11) Re-run the tests - if it still fails, you broke it. Fit it you will! :)

			//We assume that much of the data is correct - we test all the data in the PolicyResponseObject 
			//in TestPolicyResponseObject_ClientActionsOnClient and TestPolicyResponseObject_ClientActionsOnServer
			//All we're particularly interested in here is that actions that are designed to run on client and server
			//really are run on the client and server

			DateTime startDate = DateTime.Now;
			//test setup
			string[] policySetFile = new string[] { Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\Projects\Hygiene\src\TestDocuments\ServerActionsPolicySet.policy") };
			Workshare.Policy.Engine.UroPolicyEngine policyEngine = CreatePolicyEngineWithRealPolicy(policySetFile);
			Assert.IsTrue(1 == policyEngine.PolicyCache.PolicySets.Count, "Test setup failure - expected one policyset");
			UniversalRequestObject uro = TestHelpers.GetUro(false);

			TestHelpers.AddAttachment(uro, "Doc", Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\TestDocuments\TestDoc_Confidential.doc"), "TestDoc_Confidential.doc");

			
			IPolicyResponseObject pro = policyEngine.ProcessPolicies(engineRunningAs, uro, ProcessLevel.Actions);
			DateTime endDate = DateTime.Now;

			//ok, now for the testing...

			//PolicyResponseObject data on pro
			//Assert.AreEqual(ChannelType.SMTP, pro.ChannelType, "Incorrect channel type on policy response object");
			Assert.AreEqual(4, pro.Properties.Count, "Incorrect number of properties on policy response object");
			Assert.IsTrue((startDate <= pro.ResponseDate) && (endDate >= pro.ResponseDate), "Incorrect response date on policy response object");
			Assert.AreEqual(engineRunningAs, pro.RunAt, "Incorrect runat on policy response object");

			//PolicyResponseObject data on pro.Properties
			Assert.AreEqual("Stuff", pro.Properties["FileHeader"], "Incorrect FileHeader property on pro");
			Assert.AreEqual("4408 0412 3456 7890", pro.Properties["Body"], "Incorrect Body property on pro");
			Assert.AreEqual("Subject line", pro.Properties["Subject"], "Incorrect Subject property on pro");
			Assert.AreEqual(string.Empty, pro.Properties["Attachments"], "Incorrect Attachments property on pro");

			//RoutingInformation data
			Assert.AreEqual(2, pro.RoutingInformation.Count, "Incorrect number of routing entities");
			//don't care about testing the rest or the routing contents here

			//ContentList data
			Assert.AreEqual(2, pro.ContentCollection.Count, "Incorrect number of content items in content list");

			//ContentList data on pro.ContentCollection[1] - swearing.doc
			IContentItem contentItem = pro.ContentCollection[1];
			Assert.IsFalse(contentItem.Encrypted, "Incorrect encryption on content item");
			Assert.AreEqual("TestDoc_Confidential.doc", Path.GetFileName(contentItem.Name), "Incorrect name on content item");
			Assert.AreEqual(19968.0, contentItem.Size, "Incorrect size on content item");
			Assert.AreEqual("WordDocument", contentItem.Type, "Incorrect type on content item");
			Assert.AreEqual(1, contentItem.Properties.Count, "Incorrect number of properties on content item");
			Assert.AreEqual(1, contentItem.PolicySetCollection.Count, "Incorrect number of policy set response objects on content item");

			//ContentList data on pro.ContentCollection[1].PolicySetCollection[0]
			IPolicySetResponse policySetResponse = contentItem.PolicySetCollection[0];

			//triggered policy has action data. 
			Assert.IsTrue(pro.ContentCollection[1].PolicySetCollection[0].PolicyReportCollection[0].Triggered, "Incorrect triggered on policy response");
			if (engineRunningAs == RunAt.Server)
			{
				Assert.IsTrue(2 == pro.ContentCollection[1].PolicySetCollection[0].PolicyReportCollection[0].ActionCollection.Count, "Incorrect action collection on policy response");
			}
			else
			{
				//exception action only runs on server
				Assert.IsTrue(1 == pro.ContentCollection[1].PolicySetCollection[0].PolicyReportCollection[0].ActionCollection.Count, "Incorrect action collection on policy response");
			}

			//ResolvedActionList
			if (engineRunningAs == RunAt.Server)
			{
				Assert.IsTrue(1 == pro.ResolvedActionCollection.Count, "Incorrect count on pro.ResolvedActionCollection");
			}
			else
			{
				Assert.IsTrue(1 == pro.ResolvedActionCollection.Count, "Incorrect count on pro.ResolvedActionCollection");
			}
		}
コード例 #30
0
		private string GetStringNameFor(RunAt runAt)
		{
            switch (runAt)
            {
                case RunAt.Both:
                    return Properties.AdminUIResources.RUNAT_BOTH;
                case RunAt.Client:
                    return Properties.AdminUIResources.RUNAT_CLIENT;
                case RunAt.Server:
                    return Properties.AdminUIResources.RUNAT_SERVER;
            }

            return Properties.AdminUIResources.RUNAT_INVALID;
		}
コード例 #31
0
		/// <summary>
		/// Asserts the IPolicyResponse data for the CleanOfficeDoc policy in ComplexPolicySet
		/// </summary>
		/// <param name="policyResponse">The IPolicyResponse object to evaluate</param>
		/// <param name="expectedTriggered">The expected value of the Triggered property on the IPolicyResponse object</param>
		private void AssertCleanOfficeDocPolicyResponse_ComplexPolicySet(IPolicyResponse policyResponse, bool expectedTriggered, RunAt runAt)
		{
			//data on PolicyResponse
			Assert.AreEqual("Clean office docs", policyResponse.Name, "Incorrect name on policy response");
			Assert.AreEqual("All office docs must be cleaned", policyResponse.Description, "Incorrect description on policy response");
			Assert.AreEqual(expectedTriggered, policyResponse.Triggered, "Incorrect triggered on policy response");
			Assert.AreEqual(false, policyResponse.Audit, "Incorrect audit on policy response");
			Assert.AreEqual(1, policyResponse.ExpressionCollection.Count, "Incorrect number of expression responses on policy response");

			//data on PolicyResponse.ExpressionCollection[0]
			IExpressionResponse expressionResponse = policyResponse.ExpressionCollection[0];
			Assert.AreEqual("The files is either a word document, excel spreadsheet or powerpoint slideshow", expressionResponse.Description, "Incorrect description on expression response");
			Assert.AreEqual("File is an office document", expressionResponse.Name, "Incorrect name on expression response");
			Assert.AreEqual("Medium", expressionResponse.Rating, "Incorrect rating on expression response");
			Assert.AreEqual(expectedTriggered, expressionResponse.Triggered, "Incorrect triggered on expression response");
			Assert.AreEqual(0, expressionResponse.Properties.Count, "Incorrect number of properties on expression response");

			//data on PolicyResponse.ExpressionCollection[0].ExpressionDetailCollection[0]
			if (expectedTriggered)
			{
				Assert.AreEqual(1, expressionResponse.ExpressionDetailCollection.Count, "Incorrect number of expression details on expression response");
				IExpressionDetail expressionDetail = expressionResponse.ExpressionDetailCollection[0];
				Assert.AreEqual("ConditionSummary", expressionDetail.Name, "Incorrect name on expression detail");
				Assert.AreEqual("File type is Word (.doc), Excel Spreadsheet (.xls), PowerPoint (.ppt)", expressionDetail.Value, "Incorrect value on expression detail");
			}
			else
			{
				Assert.AreEqual(0, expressionResponse.ExpressionDetailCollection.Count, "Incorrect number of expression details on expression response");
			}

			//data on PolicyResponse.Routing
			IRoutingResponse routingResponse = policyResponse.Routing;
			if (expectedTriggered)
			{
				Assert.AreEqual(null, routingResponse.Description, "Incorrect description on routing response"); //ok, as this is an optional property
				Assert.AreEqual("Sent to External Recipients", routingResponse.Name, "Incorrect name on routing response");
				Assert.AreEqual("Low", routingResponse.Rating, "Incorrect rating on routing response");
				Assert.AreEqual(0, routingResponse.Properties.Count, "Incorrect number of properties on routing response");
			}
			else
			{
				Assert.IsNull(routingResponse, "Incorrect routing response on policy response");
			}

			//data on PolicyResponse.ActionCollection
			if (expectedTriggered)
			{
				if (RunAt.Client == runAt)
				{
					//only expect actions if running on client
					Assert.AreEqual(2, policyResponse.ActionCollection.Count, "Incorrect number of policy response action objects on policy response");

					//data on PolicyResponse.ActionCollection[0]
					IPolicyResponseAction policyResponseAction = policyResponse.ActionCollection[0];
					Assert.AreEqual("Clean Action", policyResponseAction.Name, "Incorrect name on policy response action");
					Assert.AreEqual("Clean", policyResponseAction.Type, "Incorrect type on policy response action");
					Assert.AreEqual(false, policyResponseAction.Overridden, "Incorrect overridden on policy response action");
					Assert.AreEqual(false, policyResponseAction.Processed, "Incorrect processed on policy response action");
					Assert.AreEqual(1, policyResponseAction.Properties.Count, "Incorrect number of properties on policy response action");
					Assert.AreEqual("False", policyResponseAction.Properties["ExceptionAction"], "Incorrect number of properties on policy response action");

					//data on PolicyResponse.ActionCollection[0].ActionPropertyCollection
					Assert.AreEqual(29, policyResponseAction.ActionPropertyCollection.Count, "Incorrect number of properties on policy response action");
					IActionPropertyResponse actionPropertyResponse = policyResponseAction.ActionPropertyCollection[0];
					Assert.AreEqual("EXECUTE", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[1];
					Assert.AreEqual("AllowOverride", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[2];
					Assert.AreEqual("Footnotes", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[3];
					Assert.AreEqual("DocumentStatistics", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[4];
					Assert.AreEqual("BuiltInProperties", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[5];
					Assert.AreEqual("Headers", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[6];
					Assert.AreEqual("Footers", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[7];
					Assert.AreEqual("SmartTags", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[8];
					Assert.AreEqual("Template", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[9];
					Assert.AreEqual("CustomProperties", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[10];
					Assert.AreEqual("DocumentVariables", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[11];
					Assert.AreEqual("Fields", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[12];
					Assert.AreEqual("Macros", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[13];
					Assert.AreEqual("RoutingSlip", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[14];
					Assert.AreEqual("SpeakerNotes", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[15];
					Assert.AreEqual("Links", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[16];
					Assert.AreEqual("Reviewers", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[17];
					Assert.AreEqual("TrackChanges", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[18];
					Assert.AreEqual("Comments", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[19];
					Assert.AreEqual("SmallText", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[20];
					Assert.AreEqual("WhiteText", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[21];
					Assert.AreEqual("HiddenText", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[22];
					Assert.AreEqual("Authors", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[23];
					Assert.AreEqual("HiddenSlides", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[24];
					Assert.AreEqual("AutoVersion", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[25];
					Assert.AreEqual("Versions", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");

					//data on PolicyResponse.ActionCollection[1]
					policyResponseAction = policyResponse.ActionCollection[1];
					Assert.AreEqual("Block Action", policyResponseAction.Name, "Incorrect name on policy response action");
					Assert.AreEqual("Block", policyResponseAction.Type, "Incorrect type on policy response action");
					Assert.AreEqual(false, policyResponseAction.Overridden, "Incorrect overridden on policy response action");
					Assert.AreEqual(false, policyResponseAction.Processed, "Incorrect processed on policy response action");
					Assert.AreEqual(1, policyResponseAction.Properties.Count, "Incorrect number of properties on policy response action");
					Assert.AreEqual("True", policyResponseAction.Properties["ExceptionAction"], "Incorrect number of properties on policy response action");

					//data on PolicyResponse.ActionCollection[1].ActionPropertyCollection
					Assert.AreEqual(2, policyResponseAction.ActionPropertyCollection.Count, "Incorrect number of properties on policy response action");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[0];
					Assert.AreEqual("EXECUTE", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[1];
					Assert.AreEqual("Description", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("Exception action", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
				}
				else
				{
					//only expect actions if running on client
					Assert.AreEqual(0, policyResponse.ActionCollection.Count, "Incorrect number of policy response action objects on policy response");
				}
			}
			else
			{
				Assert.IsNull(policyResponse.ActionCollection, "Incorrect number of policy response action objects on policy response");
			}

		}
コード例 #32
0
ファイル: Attributes.cs プロジェクト: JimmyJune/il2js
 public RunAtAttribute(RunAt runAt)
 {
     this.RunAt = runAt;
 }
コード例 #33
0
		/// <summary>
		/// Asserts the IPolicyResponse data for the ConvertWordToPdf policy in ComplexPolicySet
		/// </summary>
		/// <param name="policyResponse">The IPolicyResponse object to evaluate</param>
		/// <param name="expectedTriggered">The expected value of the Triggered property on the IPolicyResponse object</param>
		private void AssertConvertWordToPdfPolicyResponse_ComplexPolicySet(IPolicyResponse policyResponse, bool expectedTriggered, RunAt runAt)
		{
			//data on PolicyResponse
			Assert.AreEqual("PDF word docs", policyResponse.Name, "Incorrect name on policy response");
			Assert.AreEqual("All word documents should be converted to PDF", policyResponse.Description, "Incorrect description on policy response");
			Assert.AreEqual(expectedTriggered, policyResponse.Triggered, "Incorrect triggered on policy response");
			Assert.AreEqual(false, policyResponse.Audit, "Incorrect audit on policy response");
			Assert.AreEqual(1, policyResponse.ExpressionCollection.Count, "Incorrect number of expression responses on policy response");

			//data on PolicyResponse.ExpressionCollection[0]
			IExpressionResponse expressionResponse = policyResponse.ExpressionCollection[0];
			Assert.AreEqual("", expressionResponse.Description, "Incorrect description on expression response");
			Assert.AreEqual("File is word document", expressionResponse.Name, "Incorrect name on expression response");
			Assert.AreEqual("Medium", expressionResponse.Rating, "Incorrect rating on expression response");
			Assert.AreEqual(expectedTriggered, expressionResponse.Triggered, "Incorrect triggered on expression response");
			Assert.AreEqual(0, expressionResponse.Properties.Count, "Incorrect number of properties on expression response");

			//data on PolicyResponse.ExpressionCollection[0].ExpressionDetailCollection[0]
			if (expectedTriggered)
			{
				Assert.AreEqual(1, expressionResponse.ExpressionDetailCollection.Count, "Incorrect number of expression details on expression response");
				IExpressionDetail expressionDetail = expressionResponse.ExpressionDetailCollection[0];
				Assert.AreEqual("ConditionSummary", expressionDetail.Name, "Incorrect name on expression detail");
				Assert.AreEqual("File type is Word (.doc)", expressionDetail.Value, "Incorrect value on expression detail");
			}
			else
			{
				Assert.AreEqual(0, expressionResponse.ExpressionDetailCollection.Count, "Incorrect number of expression details on expression response");
			}

			//data on PolicyResponse.Routing
			IRoutingResponse routingResponse = policyResponse.Routing;
			if (expectedTriggered)
			{
				Assert.AreEqual(null, routingResponse.Description, "Incorrect description on routing response"); //ok, as this is an optional property
				Assert.AreEqual("Sent to External Recipients", routingResponse.Name, "Incorrect name on routing response");
				Assert.AreEqual("Low", routingResponse.Rating, "Incorrect rating on routing response");
				Assert.AreEqual(0, routingResponse.Properties.Count, "Incorrect number of properties on routing response");
			}
			else
			{
				Assert.IsNull(routingResponse, "Incorrect routing response on policy response");
			}

			//data on PolicyResponse.ActionCollection
			if (expectedTriggered)
			{
				if (RunAt.Client == runAt)
				{
					//only expect actions if running on client
					Assert.AreEqual(2, policyResponse.ActionCollection.Count, "Incorrect number of policy response action objects on policy response");

					IPolicyResponseAction policyResponseAction = policyResponse.ActionCollection[0];
					Assert.AreEqual("PDF Action", policyResponseAction.Name, "Incorrect name on policy response action");
					Assert.AreEqual("PDF", policyResponseAction.Type, "Incorrect type on policy response action");
					Assert.AreEqual(false, policyResponseAction.Overridden, "Incorrect overridden on policy response action");
					Assert.AreEqual(false, policyResponseAction.Processed, "Incorrect processed on policy response action");
					Assert.AreEqual(1, policyResponseAction.Properties.Count, "Incorrect number of properties on policy response action");
					Assert.AreEqual("False", policyResponseAction.Properties["ExceptionAction"], "Incorrect number of properties on policy response action");

					//data on PolicyResponse.ActionCollection[0].ActionPropertyCollection
					Assert.AreEqual(12, policyResponseAction.ActionPropertyCollection.Count, "Incorrect number of properties on policy response action");
					IActionPropertyResponse actionPropertyResponse = policyResponseAction.ActionPropertyCollection[0];
					Assert.AreEqual("EXECUTE", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[1];
					Assert.AreEqual("ProhibitPrinting", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[2];
					Assert.AreEqual("ProhibitEdit", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[3];
					Assert.AreEqual("ProhibitCopy", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[4];
					Assert.AreEqual("ProhibitComments", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[5];
					Assert.AreEqual("PasswordRequired", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("False", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[6];
					Assert.AreEqual("EnforceStrongPassword", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("False", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[7];
					Assert.AreEqual("Password", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");

					policyResponseAction = policyResponse.ActionCollection[1];
					Assert.AreEqual("Block Action", policyResponseAction.Name, "Incorrect name on policy response action");
					Assert.AreEqual("Block", policyResponseAction.Type, "Incorrect type on policy response action");
					Assert.AreEqual(false, policyResponseAction.Overridden, "Incorrect overridden on policy response action");
					Assert.AreEqual(false, policyResponseAction.Processed, "Incorrect processed on policy response action");
					Assert.AreEqual(1, policyResponseAction.Properties.Count, "Incorrect number of properties on policy response action");
					Assert.AreEqual("True", policyResponseAction.Properties["ExceptionAction"], "Incorrect number of properties on policy response action");

					//data on PolicyResponse.ActionCollection[1].ActionPropertyCollection
					Assert.AreEqual(2, policyResponseAction.ActionPropertyCollection.Count, "Incorrect number of properties on policy response action");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[0];
					Assert.AreEqual("EXECUTE", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[1];
					Assert.AreEqual("Description", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("Exception action", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
				}
				else
				{
					//only expect actions if running on client
					Assert.AreEqual(0, policyResponse.ActionCollection.Count, "Incorrect number of policy response action objects on policy response");
				}
			}
			else
			{
				Assert.IsNull(policyResponse.ActionCollection, "Incorrect number of policy response action objects on policy response");
			}        
		}
コード例 #34
0
ファイル: Action.cs プロジェクト: killbug2004/WSProf
 public Action(Guid identifier, IPolicyLanguageItem name, string assembly, string className, RunAt runAtMode, bool overrideMode, int precedence)
     : base(identifier, name)
 {
     SetDefaults(assembly, className, runAtMode, overrideMode, precedence, false);
 }
コード例 #35
0
		/// <summary>
		/// Asserts the IPolicyResponse data for the Test policy in ComplexPolicySet
		/// </summary>
		/// <param name="policyResponse">The IPolicyResponse object to evaluate</param>
		/// <param name="expectedTriggered">The expected value of the Triggered property on the IPolicyResponse object</param>
		/// <param name="expectedDocumentContext">The expected document context. This differs depending on the document that has triggered the policy.</param>
		public void AssertTestPolicyResponse_ComplexPolicySet(IPolicyResponse policyResponse, bool expectedTriggered, RunAt runAt, string expectedDocumentContext)
		{
			//data on PolicyResponse
			Assert.AreEqual("Test", policyResponse.Name, "Incorrect name on policy response");
			Assert.AreEqual("", policyResponse.Description, "Incorrect description on policy response");
			Assert.AreEqual(expectedTriggered, policyResponse.Triggered, "Incorrect triggered on policy response");
			Assert.AreEqual(false, policyResponse.Audit, "Incorrect audit on policy response");
			Assert.AreEqual(1, policyResponse.ExpressionCollection.Count, "Incorrect number of expression responses on policy response");

			//data on PolicyResponse.ExpressionCollection[0]
			IExpressionResponse expressionResponse = policyResponse.ExpressionCollection[0];
			Assert.AreEqual("", expressionResponse.Description, "Incorrect description on expression response");
			Assert.AreEqual("test detected", expressionResponse.Name, "Incorrect name on expression response");
			Assert.AreEqual("Medium", expressionResponse.Rating, "Incorrect rating on expression response");
			Assert.AreEqual(expectedTriggered, expressionResponse.Triggered, "Incorrect triggered on expression response");
			Assert.AreEqual(0, expressionResponse.Properties.Count, "Incorrect properties on expressionResponse");

			//data on PolicyResponse.ExpressionCollection[0].ExpressionDetailCollection            
			if (expectedTriggered)
			{
				Assert.AreEqual(2, expressionResponse.ExpressionDetailCollection.Count, "Incorrect expression detail object on expression response");
				IExpressionDetail expressionDetail = expressionResponse.ExpressionDetailCollection[0];
				Assert.AreEqual(expectedDocumentContext, expressionDetail.Name, "Incorrect name on expression detail");
				Assert.AreEqual("test", expressionDetail.Value, "Incorrect value on expression detail");
				expressionDetail = expressionResponse.ExpressionDetailCollection[1];
				Assert.AreEqual(expectedDocumentContext, expressionDetail.Name, "Incorrect name on expression detail");
				Assert.AreEqual("test", expressionDetail.Value, "Incorrect value on expression detail");
			}
			else
			{
				Assert.AreEqual(0, expressionResponse.ExpressionDetailCollection.Count, "Incorrect expression detail object on expression response");
			}

			//data on PolicyResponse.Routing
			IRoutingResponse routingResponse = policyResponse.Routing;
			if (expectedTriggered)
			{
				Assert.AreEqual(null, routingResponse.Description, "Incorrect description on routing response"); //ok, as this is an optional property
				Assert.AreEqual("Sent to External Recipients", routingResponse.Name, "Incorrect name on routing response");
				Assert.AreEqual("Low", routingResponse.Rating, "Incorrect rating on routing response");
				Assert.AreEqual(0, routingResponse.Properties.Count, "Incorrect number of properties on routing response");
			}
			else
			{
				Assert.IsNull(routingResponse, "Incorrect routing response on policy response");
			}

			//data on PolicyResponse.ActionCollection
			if (expectedTriggered)
			{
				if (RunAt.Client == runAt)
				{
					//only expect actions if running on client
					Assert.AreEqual(2, policyResponse.ActionCollection.Count, "Incorrect number of policy response action objects on policy response");

					IPolicyResponseAction policyResponseAction = policyResponse.ActionCollection[0];
					Assert.AreEqual("Alert Action", policyResponseAction.Name, "Incorrect name on policy response action");
					Assert.AreEqual("Alert", policyResponseAction.Type, "Incorrect type on policy response action");
					Assert.AreEqual(false, policyResponseAction.Overridden, "Incorrect overridden on policy response action");
					Assert.AreEqual(false, policyResponseAction.Processed, "Incorrect processed on policy response action");
					Assert.AreEqual(1, policyResponseAction.Properties.Count, "Incorrect number of properties on policy response action");
					Assert.AreEqual("False", policyResponseAction.Properties["ExceptionAction"], "Incorrect number of properties on policy response action");

					//data on PolicyResponse.ActionCollection[0].ActionPropertyCollection
					Assert.AreEqual(2, policyResponseAction.ActionPropertyCollection.Count, "Incorrect number of properties on policy response action");
					IActionPropertyResponse actionPropertyResponse = policyResponseAction.ActionPropertyCollection[0];
					Assert.AreEqual("EXECUTE", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[1];
					Assert.AreEqual("Description", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("Alert description", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");

					policyResponseAction = policyResponse.ActionCollection[1];
					Assert.AreEqual("Block Action", policyResponseAction.Name, "Incorrect name on policy response action");
					Assert.AreEqual("Block", policyResponseAction.Type, "Incorrect type on policy response action");
					Assert.AreEqual(false, policyResponseAction.Overridden, "Incorrect overridden on policy response action");
					Assert.AreEqual(false, policyResponseAction.Processed, "Incorrect processed on policy response action");
					Assert.AreEqual(1, policyResponseAction.Properties.Count, "Incorrect number of properties on policy response action");
					Assert.AreEqual("True", policyResponseAction.Properties["ExceptionAction"], "Incorrect number of properties on policy response action");

					//data on PolicyResponse.ActionCollection[1].ActionPropertyCollection
					Assert.AreEqual(2, policyResponseAction.ActionPropertyCollection.Count, "Incorrect number of properties on policy response action");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[0];
					Assert.AreEqual("EXECUTE", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[1];
					Assert.AreEqual("Description", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("Exception action", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
				}
				else
				{
					//only expect actions if running on client
					Assert.AreEqual(0, policyResponse.ActionCollection.Count, "Incorrect number of policy response action objects on policy response");
				}
			}
			else
			{
				Assert.IsNull(policyResponse.ActionCollection, "Incorrect number of policy response action objects on policy response");
			} 
		}
コード例 #36
0
ファイル: ContentEnforcer.cs プロジェクト: killbug2004/WSProf
		public ScanAndEnforceResponse ScanAndEnforce(Request request, string [] categories, string user, RunAt runat)
		{
			return new ScanAndEnforceResponse();
		}