[Nunit-core] [Bug 519912] Re: Thread.CurrentPrincipal Set In TestFixtureSetUp Not Maintained Between Tests
** Changed in: nunit-3.0 Status: Fix Committed = Fix Released -- Thread.CurrentPrincipal Set In TestFixtureSetUp Not Maintained Between Tests https://bugs.launchpad.net/bugs/519912 You received this bug notification because you are a member of NUnit Developers, which is subscribed to NUnit V2. Status in NUnit Test Framework: Fix Released Status in NUnit V2 Test Framework: Fix Released Bug description: If I run the tests below in the NUnit GUI 2.5.2, both tests pass. If I run them in the 2.5.3 GUI, the second test to run fails. I think this is related to the code change here, http://bazaar.launchpad.net/~nunit-core/nunitv2/trunk/revision/3061.2.6#src/NUnitCore/core/TestContext.cs, to fix the issue Bug #459219 Changes to thread princpal cause failures under .NET 4.0, https://bugs.launchpad.net/nunitv2/+bug/459219 I think the changed behaviour happens because in the TestContext class, the constructor uses the static field current as being the context that existed at the beginning of running the test. But the static field gets set before the identity changes in TFSU, so when it's used at the TestMethod level, even though Thread.CurrentPrincipal is foo, the current principal in the current field is . So then, when we restore the prior context after running the test method, we restore Thread.CurrentPrincipal to instead of foo. This report originated from a thread on the NUnit-discuss group here, http://groups.google.co.uk/group/nunit-discuss/browse_thread/thread/d9d47eb87587152a using System.Security.Principal; using System.Threading; using NUnit.Framework; namespace ThreadStateTest { [TestFixture] public class ThreadIdentityTest2 { [TestFixtureSetUp] public void TestFixtureSetUp() { var identity = new GenericIdentity(foo); Thread.CurrentPrincipal = new GenericPrincipal(identity, new string[0]); } [Test] public void Test1() { Assert.AreEqual(foo, Thread.CurrentPrincipal.Identity.Name); } [Test] public void Test2() { Assert.AreEqual(foo, Thread.CurrentPrincipal.Identity.Name); } } } ___ Mailing list: https://launchpad.net/~nunit-core Post to : nunit-core@lists.launchpad.net Unsubscribe : https://launchpad.net/~nunit-core More help : https://help.launchpad.net/ListHelp
[Nunit-core] [Bug 519912] Re: Thread.CurrentPrincipal Set In TestFixtureSetUp Not Maintained Between Tests
** Branch linked: lp:nunit-3.0 -- Thread.CurrentPrincipal Set In TestFixtureSetUp Not Maintained Between Tests https://bugs.launchpad.net/bugs/519912 You received this bug notification because you are a member of NUnit Developers, which is subscribed to NUnit V2. Status in NUnit Test Framework: Fix Committed Status in NUnit V2 Test Framework: Fix Released Bug description: If I run the tests below in the NUnit GUI 2.5.2, both tests pass. If I run them in the 2.5.3 GUI, the second test to run fails. I think this is related to the code change here, http://bazaar.launchpad.net/~nunit-core/nunitv2/trunk/revision/3061.2.6#src/NUnitCore/core/TestContext.cs, to fix the issue Bug #459219 Changes to thread princpal cause failures under .NET 4.0, https://bugs.launchpad.net/nunitv2/+bug/459219 I think the changed behaviour happens because in the TestContext class, the constructor uses the static field current as being the context that existed at the beginning of running the test. But the static field gets set before the identity changes in TFSU, so when it's used at the TestMethod level, even though Thread.CurrentPrincipal is foo, the current principal in the current field is . So then, when we restore the prior context after running the test method, we restore Thread.CurrentPrincipal to instead of foo. This report originated from a thread on the NUnit-discuss group here, http://groups.google.co.uk/group/nunit-discuss/browse_thread/thread/d9d47eb87587152a using System.Security.Principal; using System.Threading; using NUnit.Framework; namespace ThreadStateTest { [TestFixture] public class ThreadIdentityTest2 { [TestFixtureSetUp] public void TestFixtureSetUp() { var identity = new GenericIdentity(foo); Thread.CurrentPrincipal = new GenericPrincipal(identity, new string[0]); } [Test] public void Test1() { Assert.AreEqual(foo, Thread.CurrentPrincipal.Identity.Name); } [Test] public void Test2() { Assert.AreEqual(foo, Thread.CurrentPrincipal.Identity.Name); } } } ___ Mailing list: https://launchpad.net/~nunit-core Post to : nunit-core@lists.launchpad.net Unsubscribe : https://launchpad.net/~nunit-core More help : https://help.launchpad.net/ListHelp
[Nunit-core] [Bug 519912] Re: Thread.CurrentPrincipal Set In TestFixtureSetUp Not Maintained Between Tests
** Changed in: nunitv2 Status: Fix Committed = Fix Released -- Thread.CurrentPrincipal Set In TestFixtureSetUp Not Maintained Between Tests https://bugs.launchpad.net/bugs/519912 You received this bug notification because you are a member of NUnit Developers, which is subscribed to NUnit V2. Status in NUnit Test Framework: Triaged Status in NUnit V2 Test Framework: Fix Released Bug description: If I run the tests below in the NUnit GUI 2.5.2, both tests pass. If I run them in the 2.5.3 GUI, the second test to run fails. I think this is related to the code change here, http://bazaar.launchpad.net/~nunit-core/nunitv2/trunk/revision/3061.2.6#src/NUnitCore/core/TestContext.cs, to fix the issue Bug #459219 Changes to thread princpal cause failures under .NET 4.0, https://bugs.launchpad.net/nunitv2/+bug/459219 I think the changed behaviour happens because in the TestContext class, the constructor uses the static field current as being the context that existed at the beginning of running the test. But the static field gets set before the identity changes in TFSU, so when it's used at the TestMethod level, even though Thread.CurrentPrincipal is foo, the current principal in the current field is . So then, when we restore the prior context after running the test method, we restore Thread.CurrentPrincipal to instead of foo. This report originated from a thread on the NUnit-discuss group here, http://groups.google.co.uk/group/nunit-discuss/browse_thread/thread/d9d47eb87587152a using System.Security.Principal; using System.Threading; using NUnit.Framework; namespace ThreadStateTest { [TestFixture] public class ThreadIdentityTest2 { [TestFixtureSetUp] public void TestFixtureSetUp() { var identity = new GenericIdentity(foo); Thread.CurrentPrincipal = new GenericPrincipal(identity, new string[0]); } [Test] public void Test1() { Assert.AreEqual(foo, Thread.CurrentPrincipal.Identity.Name); } [Test] public void Test2() { Assert.AreEqual(foo, Thread.CurrentPrincipal.Identity.Name); } } } ___ Mailing list: https://launchpad.net/~nunit-core Post to : nunit-core@lists.launchpad.net Unsubscribe : https://launchpad.net/~nunit-core More help : https://help.launchpad.net/ListHelp
[Nunit-core] [Bug 519912] Re: Thread.CurrentPrincipal Set In TestFixtureSetUp Not Maintained Between Tests
This turns out to also apply to changes to CurrentCulture or CurrentUICulture done in a TestFixtureSetUp method. The fix deals with these as well. ** Also affects: nunit-3.0 Importance: Undecided Status: New ** Changed in: nunit-3.0 Assignee: (unassigned) = Charlie Poole (charlie.poole) ** Changed in: nunit-3.0 Importance: Undecided = High ** Changed in: nunit-3.0 Status: New = Triaged ** Changed in: nunit-3.0 Milestone: None = 2.9.4 -- Thread.CurrentPrincipal Set In TestFixtureSetUp Not Maintained Between Tests https://bugs.launchpad.net/bugs/519912 You received this bug notification because you are a member of NUnit Developers, which is subscribed to NUnit V2. Status in NUnit Test Framework: Triaged Status in NUnit V2 Test Framework: In Progress Bug description: If I run the tests below in the NUnit GUI 2.5.2, both tests pass. If I run them in the 2.5.3 GUI, the second test to run fails. I think this is related to the code change here, http://bazaar.launchpad.net/~nunit-core/nunitv2/trunk/revision/3061.2.6#src/NUnitCore/core/TestContext.cs, to fix the issue Bug #459219 Changes to thread princpal cause failures under .NET 4.0, https://bugs.launchpad.net/nunitv2/+bug/459219 I think the changed behaviour happens because in the TestContext class, the constructor uses the static field current as being the context that existed at the beginning of running the test. But the static field gets set before the identity changes in TFSU, so when it's used at the TestMethod level, even though Thread.CurrentPrincipal is foo, the current principal in the current field is . So then, when we restore the prior context after running the test method, we restore Thread.CurrentPrincipal to instead of foo. This report originated from a thread on the NUnit-discuss group here, http://groups.google.co.uk/group/nunit-discuss/browse_thread/thread/d9d47eb87587152a using System.Security.Principal; using System.Threading; using NUnit.Framework; namespace ThreadStateTest { [TestFixture] public class ThreadIdentityTest2 { [TestFixtureSetUp] public void TestFixtureSetUp() { var identity = new GenericIdentity(foo); Thread.CurrentPrincipal = new GenericPrincipal(identity, new string[0]); } [Test] public void Test1() { Assert.AreEqual(foo, Thread.CurrentPrincipal.Identity.Name); } [Test] public void Test2() { Assert.AreEqual(foo, Thread.CurrentPrincipal.Identity.Name); } } } ___ Mailing list: https://launchpad.net/~nunit-core Post to : nunit-core@lists.launchpad.net Unsubscribe : https://launchpad.net/~nunit-core More help : https://help.launchpad.net/ListHelp
[Nunit-core] [Bug 519912] Re: Thread.CurrentPrincipal Set In TestFixtureSetUp Not Maintained Between Tests
** Changed in: nunitv2 Status: In Progress = Fix Committed -- Thread.CurrentPrincipal Set In TestFixtureSetUp Not Maintained Between Tests https://bugs.launchpad.net/bugs/519912 You received this bug notification because you are a member of NUnit Developers, which is subscribed to NUnit V2. Status in NUnit Test Framework: Triaged Status in NUnit V2 Test Framework: Fix Committed Bug description: If I run the tests below in the NUnit GUI 2.5.2, both tests pass. If I run them in the 2.5.3 GUI, the second test to run fails. I think this is related to the code change here, http://bazaar.launchpad.net/~nunit-core/nunitv2/trunk/revision/3061.2.6#src/NUnitCore/core/TestContext.cs, to fix the issue Bug #459219 Changes to thread princpal cause failures under .NET 4.0, https://bugs.launchpad.net/nunitv2/+bug/459219 I think the changed behaviour happens because in the TestContext class, the constructor uses the static field current as being the context that existed at the beginning of running the test. But the static field gets set before the identity changes in TFSU, so when it's used at the TestMethod level, even though Thread.CurrentPrincipal is foo, the current principal in the current field is . So then, when we restore the prior context after running the test method, we restore Thread.CurrentPrincipal to instead of foo. This report originated from a thread on the NUnit-discuss group here, http://groups.google.co.uk/group/nunit-discuss/browse_thread/thread/d9d47eb87587152a using System.Security.Principal; using System.Threading; using NUnit.Framework; namespace ThreadStateTest { [TestFixture] public class ThreadIdentityTest2 { [TestFixtureSetUp] public void TestFixtureSetUp() { var identity = new GenericIdentity(foo); Thread.CurrentPrincipal = new GenericPrincipal(identity, new string[0]); } [Test] public void Test1() { Assert.AreEqual(foo, Thread.CurrentPrincipal.Identity.Name); } [Test] public void Test2() { Assert.AreEqual(foo, Thread.CurrentPrincipal.Identity.Name); } } } ___ Mailing list: https://launchpad.net/~nunit-core Post to : nunit-core@lists.launchpad.net Unsubscribe : https://launchpad.net/~nunit-core More help : https://help.launchpad.net/ListHelp
[Nunit-core] [Bug 519912] Re: Thread.CurrentPrincipal Set In TestFixtureSetUp Not Maintained Between Tests
I think NUnit needs to set the CurrentPrincipal for each thread from the TestContext upon creating it. This affects several different locations in NUnit, so we should try to encapsulate it. ** Changed in: nunitv2 Importance: Undecided = High ** Changed in: nunitv2 Status: New = Triaged ** Changed in: nunitv2 Milestone: None = 2.5.4 -- Thread.CurrentPrincipal Set In TestFixtureSetUp Not Maintained Between Tests https://bugs.launchpad.net/bugs/519912 You received this bug notification because you are a member of NUnit Developers, which is subscribed to NUnit V2. Status in NUnit V2 Test Framework: Triaged Bug description: If I run the tests below in the NUnit GUI 2.5.2, both tests pass. If I run them in the 2.5.3 GUI, the second test to run fails. I think this is related to the code change here, http://bazaar.launchpad.net/~nunit-core/nunitv2/trunk/revision/3061.2.6#src/NUnitCore/core/TestContext.cs, to fix the issue Bug #459219 Changes to thread princpal cause failures under .NET 4.0, https://bugs.launchpad.net/nunitv2/+bug/459219 I think the changed behaviour happens because in the TestContext class, the constructor uses the static field current as being the context that existed at the beginning of running the test. But the static field gets set before the identity changes in TFSU, so when it's used at the TestMethod level, even though Thread.CurrentPrincipal is foo, the current principal in the current field is . So then, when we restore the prior context after running the test method, we restore Thread.CurrentPrincipal to instead of foo. This report originated from a thread on the NUnit-discuss group here, http://groups.google.co.uk/group/nunit-discuss/browse_thread/thread/d9d47eb87587152a using System.Security.Principal; using System.Threading; using NUnit.Framework; namespace ThreadStateTest { [TestFixture] public class ThreadIdentityTest2 { [TestFixtureSetUp] public void TestFixtureSetUp() { var identity = new GenericIdentity(foo); Thread.CurrentPrincipal = new GenericPrincipal(identity, new string[0]); } [Test] public void Test1() { Assert.AreEqual(foo, Thread.CurrentPrincipal.Identity.Name); } [Test] public void Test2() { Assert.AreEqual(foo, Thread.CurrentPrincipal.Identity.Name); } } } ___ Mailing list: https://launchpad.net/~nunit-core Post to : nunit-core@lists.launchpad.net Unsubscribe : https://launchpad.net/~nunit-core More help : https://help.launchpad.net/ListHelp