diff --git a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java index 90353263706bbb63c92f4a287cf07f02149c655d..fbddfa8d6c72abf2281876345f359b7999352975 100644 --- a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java +++ b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java @@ -30,6 +30,7 @@ import hudson.*; import hudson.Util; import hudson.model.*; import hudson.model.Queue.Executable; +import hudson.security.ACL; import hudson.security.AbstractPasswordBasedSecurityRealm; import hudson.security.GroupDetails; import hudson.security.SecurityRealm; @@ -100,6 +101,7 @@ import net.sourceforge.htmlunit.corejs.javascript.ContextFactory.Listener; import org.acegisecurity.AuthenticationException; import org.acegisecurity.BadCredentialsException; import org.acegisecurity.GrantedAuthority; +import org.acegisecurity.context.SecurityContextHolder; import org.acegisecurity.userdetails.UserDetails; import org.acegisecurity.userdetails.UsernameNotFoundException; import org.apache.commons.httpclient.NameValuePair; @@ -316,6 +318,8 @@ public abstract class HudsonTestCase extends TestCase implements RootAction { @Override protected void runTest() throws Throwable { System.out.println("=== Starting "+ getClass().getSimpleName() + "." + getName()); + // so that test code has all the access to the system + SecurityContextHolder.getContext().setAuthentication(ACL.SYSTEM); super.runTest(); } diff --git a/test/src/test/java/hudson/model/QueueTest.java b/test/src/test/java/hudson/model/QueueTest.java index 9f79987e16e404867e26d1482da64aa8bcc40b50..b7deff28346aec1298b28e6b387d599900e4c731 100644 --- a/test/src/test/java/hudson/model/QueueTest.java +++ b/test/src/test/java/hudson/model/QueueTest.java @@ -206,8 +206,8 @@ public class QueueTest extends HudsonTestCase { StringBuilder causes = new StringBuilder(); for (Cause c : ca.getCauses()) causes.append(c.getShortDescription() + "\n"); assertEquals("Build causes should have all items, even duplicates", - "Started by user anonymous\nStarted by an SCM change\n" - + "Started by user anonymous\nStarted by timer\n" + "Started by user SYSTEM\nStarted by an SCM change\n" + + "Started by user SYSTEM\nStarted by timer\n" + "Started by remote host 1.2.3.4 with note: test\n" + "Started by remote host 4.3.2.1 with note: test\n" + "Started by an SCM change\n" @@ -220,7 +220,7 @@ public class QueueTest extends HudsonTestCase { WebClient wc = new WebClient(); String buildPage = wc.getPage(build, "").asText().replace('\n',' '); assertTrue("Build page should combine duplicates and show counts: " + buildPage, - buildPage.contains("Started by user anonymous (2 times) " + buildPage.contains("Started by user SYSTEM (2 times) " + "Started by an SCM change (3 times) " + "Started by timer (2 times) " + "Started by remote host 1.2.3.4 with note: test (2 times) "