public void CallingThreadPrincipal_WhenUserIsSet_DoesNotChange() { var currentThreadPrincipal = Thread.CurrentPrincipal; var runtime = new CoreRuntime(new RuntimeConfiguration()); runtime.Execute(new ExecutionMetadata { JobType = typeof(TestJob).AssemblyQualifiedName, UserId = "bla" }); Assert.AreEqual(currentThreadPrincipal, Thread.CurrentPrincipal); }
public void ConfigurableServiceProviderIsSet_WhenExecuting_RegistrationIsCalled() { var serviceProvider = new CustomActivator(); var runtime = new CoreRuntime(new RuntimeConfiguration { ServiceProvider = serviceProvider }); runtime.Execute(new ExecutionMetadata { JobType = typeof(TestJob).AssemblyQualifiedName }); #pragma warning disable CS0618 // Type or member is obsolete Assert.AreEqual(1, serviceProvider.RegisteredInstances.OfType <RuntimeContext>().Count(), "There should be a single registration of the RuntimeContext"); #pragma warning restore CS0618 // Type or member is obsolete }
public void ExecutingThreadPrincipal_WhenUserIsSet_DoesChangePrincipal() { IPrincipal executingThreadPrincipal = null; RunCallBackTestJob.Callback = () => executingThreadPrincipal = Thread.CurrentPrincipal; var runtime = new CoreRuntime(new RuntimeConfiguration()); runtime.Execute(new ExecutionMetadata { JobType = typeof(RunCallBackTestJob).AssemblyQualifiedName, UserId = "anything" }); RunCallBackTestJob.Reset(); Assert.AreNotEqual(executingThreadPrincipal.Identity.Name, Thread.CurrentPrincipal.Identity.Name); }
public void ExecutingThreadPrincipal_WhenExecuting_CallbackIsCalled() { IPrincipal executingThreadPrincipal = null; RunCallBackTestJob.Callback = () => executingThreadPrincipal = Thread.CurrentPrincipal; var runtime = new CoreRuntime(new RuntimeConfiguration()); runtime.Execute(new ExecutionMetadata { JobType = typeof(RunCallBackTestJob).AssemblyQualifiedName }); RunCallBackTestJob.Reset(); Assert.IsNotNull(executingThreadPrincipal); }
public void ThreadPrincipal_InExecutingThread_AuthenticationTypeIsSet() { IPrincipal executingThreadPrincipal = null; RunCallBackTestJob.Callback = () => executingThreadPrincipal = Thread.CurrentPrincipal; var userName = "******"; var runtime = new CoreRuntime(new RuntimeConfiguration()); runtime.Execute(new ExecutionMetadata { JobType = typeof(RunCallBackTestJob).AssemblyQualifiedName, UserId = userName }); RunCallBackTestJob.Reset(); Assert.AreEqual("JobbrIdentity", executingThreadPrincipal.Identity.AuthenticationType); }
public void ConfigurableServiceProviderIsSet_WhenExecuting_ContextMatchesMetaInfo() { var serviceProvider = new CustomActivator(); var userName = "******"; var userDisplay = "Schnyder, Michael"; var runtime = new CoreRuntime(new RuntimeConfiguration { ServiceProvider = serviceProvider }); runtime.Execute(new ExecutionMetadata { JobType = typeof(TestJob).AssemblyQualifiedName, UserId = userName, UserDisplayName = userDisplay }); #pragma warning disable CS0618 // Type or member is obsolete var ctx = serviceProvider.RegisteredInstances.OfType <RuntimeContext>().Single(); Assert.AreEqual(userName, ctx.UserId); Assert.AreEqual(userDisplay, ctx.UserDisplayName); #pragma warning restore CS0618 // Type or member is obsolete }