Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-1674

[classlib][luni/security] Tests depend on presence of ~/.java.policy file

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • None
    • Classlib
    • None

    Description

      Some security-related testcases are vulnerable to presence of ~/.java.policy file.
      To reproduce, create ".java.policy" file in your home dir with the following context:

      grant

      { permission java.security.AllPermission; }

      ;

      Then run all tests of classlib:

      <testcase classname="org.apache.harmony.luni.tests.java.lang.SecurityManagerTest" name="test_checkMemberAccessLjava_lang_ClassI" time="0.006">
      <failure message="This should throw a SecurityException." type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError: This should throw a SecurityException.
      at org.apache.harmony.luni.tests.java.lang.SecurityManagerTest.test_checkMemberAccessLjava_lang_ClassI(SecurityManagerTest.java:39)
      at java.lang.reflect.AccessibleObject.invokeV(AccessibleObject.java:25)
      </failure>
      </testcase>
      <testcase classname="org.apache.harmony.luni.tests.java.lang.SecurityManagerTest" name="test_checkPermissionLjava_security_Permission" time="0.002">
      <failure message="This should throw a SecurityException" type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError: This should throw a SecurityException
      at org.apache.harmony.luni.tests.java.lang.SecurityManagerTest.test_checkPermissionLjava_security_Permission(SecurityManagerTest.java:59)
      at java.lang.reflect.AccessibleObject.invokeV(AccessibleObject.java:25)
      </failure>
      </testcase>
      <testcase classname="tests.api.java.net.InetAddressTest" name="test_getAllByNameLjava_lang_String" time="5.875">
      <failure message="expected SecurityException" type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError: expected SecurityException
      at tests.api.java.net.InetAddressTest.test_getAllByNameLjava_lang_String(InetAddressTest.java:191)
      at java.lang.reflect.AccessibleObject.invokeV(AccessibleObject.java:25)
      </failure>
      </testcase>
      <testcase classname="org.apache.harmony.security.tests.java.security.AccessController2Test" name="test_doPrivilegedLjava_security_PrivilegedAction" time="0.029">
      <failure message="Got AllPermission by passing in a null PD" type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError: Got AllPermission by passing in a null PD
      at org.apache.harmony.security.tests.java.security.AccessController2Test.test_doPrivilegedLjava_security_PrivilegedAction(AccessController2Test.java:49)
      at java.lang.reflect.AccessibleObject.invokeV(AccessibleObject.java:25)
      </failure>
      </testcase>
      <testcase classname="org.apache.harmony.security.tests.java.security.Policy2Test" name="test_getPolicy" time="0.001">
      <failure message="We shouldn't have been able to get the policy with a SecurityManager in place!" type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError: We shouldn't have been able to get the policy with a SecurityManager in place!
      at org.apache.harmony.security.tests.java.security.Policy2Test.test_getPolicy(Policy2Test.java:63)
      at java.lang.reflect.AccessibleObject.invokeV(AccessibleObject.java:25)
      </failure>
      </testcase>

      Attachments

        1. patch-security.txt
          5 kB
          Boris Kuznetsov
        2. patch-luni.txt
          5 kB
          Boris Kuznetsov

        Activity

          People

            tellison Tim Ellison
            varlax Alexey Varlamov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: