You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Fredrik Wendt (JIRA)" <ji...@codehaus.org> on 2008/12/12 17:58:19 UTC

[jira] Commented: (SUREFIRE-34) Using security manager in a fork mode causes an AccessControlException

    [ http://jira.codehaus.org/browse/SUREFIRE-34?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=157857#action_157857 ] 

Fredrik Wendt commented on SUREFIRE-34:
---------------------------------------

Not supporting Ashcroft (or other alternative SecurityManagers) is blocking me from making sure that my coders write unit tests that follow the rules the project's set up (such as no Unit test is allowed to touch the filesystem, network, take longer than x milliseconds, ...). I've seen that jboss uses a maven profile to set jvm arguments like this:

profiles > profile > properites:
         <surefire.jvm.args>-Djava.security.manager -Djava.security.policy=${policy.file} ${test.env}</surefire.jvm.args>

http://repository.jboss.org/maven2/org/jboss/security/jbosssx-parent/2.0.2.CR1/jbosssx-parent-2.0.2.CR1.pom

That forces one to rely on maven profiles. I had hoped this would work:

<project><build><plugins>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <skip>true</skip>
        </configuration>
        <executions>
          <execution>
            <id>unit-tests</id>
            <phase>test</phase>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <skip>false</skip>
              <excludes>
                <exclude>**/*IntegrationTest.java</exclude>
              </excludes>
              <systemProperties>
                <property>
                  <name>java.security.manager</name>
                  <value>this.is.where.ashcroft.would.be.nice.or.some.other.UnitTestSecurityManager</value>
                </property>
              </systemProperties>
            </configuration>
          </execution>
          <execution>
            <id>integration-tests</id>
            <phase>integration-test</phase>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <skip>false</skip>
              <includes>
                <include>**/*IntegrationTest.java</include>
              </includes>
            </configuration>
          </execution>
        </executions>
      </plugin>

Another option of course would be to put tests that must run outside the Ashcroft security manager in another project. But it's sad to base that decision on the shortcomings of Surefire.

> Using security manager in a fork mode causes an AccessControlException
> ----------------------------------------------------------------------
>
>                 Key: SUREFIRE-34
>                 URL: http://jira.codehaus.org/browse/SUREFIRE-34
>             Project: Maven Surefire
>          Issue Type: Bug
>          Components: process forking
>    Affects Versions: 1.5.3 (2.1.3 plugin)
>            Reporter: Vincent Siveton
>            Priority: Critical
>             Fix For: 2.x
>
>         Attachments: SUREFIRE-34.diff
>
>
> Using securityManager in a forkmode causes java.security.AccessControlException in the createClassLoader() method
> Same things with setSystemProperties() 
> Example:
> <plugin>
>   <groupId>org.apache.maven.plugins</groupId>
>   <artifactId>maven-surefire-plugin</artifactId>
>   <configuration>
>      <forkMode>pertest</forkMode>
>      <argLine>-Djava.security.manager</argLine>
>   </configuration>
> </plugin>

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira