Example #1
0
 public static void DefaultPrincipalPolicyTest_Desktop()
 {
     DummyClass.RemoteInvoke(() =>
     {
         Assert.Equal(string.Empty, Thread.CurrentPrincipal.Identity.Name);
     }).Dispose();
 }
Example #2
0
 public static void ApartmentState_NoAttributePresent_STA_Unix()
 {
     DummyClass.RemoteInvoke(() =>
     {
         Assert.Throws <PlatformNotSupportedException>(() => Thread.CurrentThread.SetApartmentState(ApartmentState.STA));
     }).Dispose();
 }
Example #3
0
 public static void DefaultPrincipalPolicyTest()
 {
     DummyClass.RemoteInvoke(() =>
     {
         Assert.Null(Thread.CurrentPrincipal);
     }).Dispose();
 }
Example #4
0
 public static void ApartmentState_NoAttributePresent_DefaultState_Nano()
 {
     DummyClass.RemoteInvoke(() =>
     {
         Assert.Throws <InvalidOperationException>(() => Thread.CurrentThread.SetApartmentState(ApartmentState.STA));
         Assert.Equal(ApartmentState.MTA, Thread.CurrentThread.GetApartmentState());
     }).Dispose();
 }
Example #5
0
 public static void ApartmentState_NoAttributePresent_DefaultState_Unix()
 {
     DummyClass.RemoteInvoke(() =>
     {
         Assert.Equal(ApartmentState.Unknown, Thread.CurrentThread.GetApartmentState());
         Assert.Throws <PlatformNotSupportedException>(() => Thread.CurrentThread.SetApartmentState(ApartmentState.MTA));
     }).Dispose();
 }
Example #6
0
 public static void UnauthenticatedPrincipalTest()
 {
     DummyClass.RemoteInvoke(() =>
     {
         AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.UnauthenticatedPrincipal);
         Assert.Equal(string.Empty, Thread.CurrentPrincipal.Identity.Name);
     }).Dispose();
 }
Example #7
0
 public static void WindowsPrincipalPolicyTest_Unix()
 {
     DummyClass.RemoteInvoke(() =>
     {
         AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
         Assert.Throws <PlatformNotSupportedException>(() => Thread.CurrentPrincipal);
     }).Dispose();
 }
Example #8
0
 public static void WindowsPrincipalPolicyTest_Windows()
 {
     DummyClass.RemoteInvoke(() =>
     {
         AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
         Assert.Equal(Environment.UserDomainName + @"\" + Environment.UserName, Thread.CurrentPrincipal.Identity.Name);
     }).Dispose();
 }
Example #9
0
        public static void CurrentPrincipal_SetNull()
        {
            // We run test on remote process because we need to set same principal policy
            // On netfx default principal policy is PrincipalPolicy.UnauthenticatedPrincipal
            DummyClass.RemoteInvoke(() =>
            {
                AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.NoPrincipal);

                Assert.Null(Thread.CurrentPrincipal);

                Thread.CurrentPrincipal = null;
                Assert.Null(Thread.CurrentPrincipal);

                Thread.CurrentPrincipal = new ClaimsPrincipal();
                Assert.IsType <ClaimsPrincipal>(Thread.CurrentPrincipal);

                Thread.CurrentPrincipal = null;
                Assert.Null(Thread.CurrentPrincipal);

                Thread.CurrentPrincipal = new ClaimsPrincipal();
                Assert.IsType <ClaimsPrincipal>(Thread.CurrentPrincipal);
            }).Dispose();
        }