コード例 #1
0
		public void SetUp()
		{
			formatter = new AppDomainNameFormatter();
			formattedInstanceName = formatter.CreateName(instanceName);
			instrumentationProvider = new SecurityCacheProviderInstrumentationProvider();
			enabledInstrumentationListener = new SecurityCacheProviderInstrumentationListener(instanceName, true, true, true, formatter);
			disabledInstrumentationListener = new SecurityCacheProviderInstrumentationListener(instanceName, false, false, false, formatter);
		}
コード例 #2
0
        public void RetrieveCachedIdentityFiresWmiEvent()
        {
            SecurityCacheProvider securityCache = SecurityCacheFactory.GetSecurityCacheProvider() as SecurityCacheProvider;
            SecurityCacheProviderInstrumentationListener listener = new SecurityCacheProviderInstrumentationListener("foo", false, false, true);

            ReflectionInstrumentationBinder binder = new ReflectionInstrumentationBinder();
            binder.Bind(securityCache.GetInstrumentationEventProvider(), listener);

            using (WmiEventWatcher eventWatcher = new WmiEventWatcher(1))
            {
                IToken token = new GuidToken();
                object profile = securityCache.GetIdentity(token);
                eventWatcher.WaitForEvents();

                Assert.AreEqual(1, eventWatcher.EventsReceived.Count);
                Assert.AreEqual("SecurityCacheReadPerformedEvent", eventWatcher.EventsReceived[0].ClassPath.ClassName);
                Assert.AreEqual(SecurityEntityType.Identity.ToString(), eventWatcher.EventsReceived[0].Properties["EntityType"].Value);
                Assert.AreEqual("foo", eventWatcher.EventsReceived[0].Properties["InstanceName"].Value);
                Assert.AreEqual(token.Value, eventWatcher.EventsReceived[0].Properties["TokenUsed"].Value);

            }
        }