Exemplo n.º 1
0
        public void AuthorizationFailedFires2WmiEvents()
        {
            AzManAuthorizationProvider instrumentedAzman = new AzManAuthorizationProvider(data.StoreLocation, data.Application, data.AuditIdentifierPrefix, data.Scope);
            AuthorizationProviderInstrumentationListener listener = new AuthorizationProviderInstrumentationListener("foo", false, false, true);

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

            using (WmiEventWatcher eventWatcher = new WmiEventWatcher(2))
            {
                bool res = instrumentedAzman.Authorize(cryptographyProviderCollection, unauthorizedTask);

                eventWatcher.WaitForEvents();

                Assert.AreEqual(2, eventWatcher.EventsReceived.Count);

                Assert.AreEqual("AuthorizationCheckPerformedEvent", eventWatcher.EventsReceived[0].ClassPath.ClassName);
                Assert.AreEqual("foo", eventWatcher.EventsReceived[0].Properties["InstanceName"].Value);
                Assert.AreEqual(cryptographyProviderCollection.Identity.Name, eventWatcher.EventsReceived[0].Properties["UserName"].Value);
                Assert.AreEqual(unauthorizedTask, eventWatcher.EventsReceived[0].Properties["TaskName"].Value);

                Assert.AreEqual("AuthorizationCheckFailedEvent", eventWatcher.EventsReceived[1].ClassPath.ClassName);
                Assert.AreEqual("foo", eventWatcher.EventsReceived[1].Properties["InstanceName"].Value);
                Assert.AreEqual(cryptographyProviderCollection.Identity.Name, eventWatcher.EventsReceived[1].Properties["UserName"].Value);
                Assert.AreEqual(unauthorizedTask, eventWatcher.EventsReceived[1].Properties["TaskName"].Value);
            }
        }
		public void SetUp()
		{
			formatter = new AppDomainNameFormatter();
			formattedInstanceName = formatter.CreateName(instanceName);
			instrumentationProvider = new AuthorizationProviderInstrumentationProvider();
			enabledInstrumentationListener = new AuthorizationProviderInstrumentationListener(instanceName, true, true, true, formatter);
			disabledInstrumentationListener = new AuthorizationProviderInstrumentationListener(instanceName, false, false, false, formatter);
		}
Exemplo n.º 3
0
        public void AuthorizeFiresWmiEvent()
        {
            AzManAuthorizationProvider instrumentedAzman = new AzManAuthorizationProvider(data.StoreLocation, data.Application, data.AuditIdentifierPrefix, data.Scope);
            AuthorizationProviderInstrumentationListener listener = new AuthorizationProviderInstrumentationListener("foo", false, false, true);

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

            using (WmiEventWatcher eventWatcher = new WmiEventWatcher(1))
            {
                bool res = instrumentedAzman.Authorize(cryptographyProviderCollection, authorizedTask);

                eventWatcher.WaitForEvents();
				Thread.Sleep(500);

                Assert.AreEqual(1, eventWatcher.EventsReceived.Count);
                Assert.AreEqual("foo", eventWatcher.EventsReceived[0].Properties["InstanceName"].Value);
                Assert.AreEqual(cryptographyProviderCollection.Identity.Name, eventWatcher.EventsReceived[0].Properties["UserName"].Value);
                Assert.AreEqual(authorizedTask, eventWatcher.EventsReceived[0].Properties["TaskName"].Value);
            }
        }