Harmony
  1. Harmony
  2. HARMONY-1674

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

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Classlib
    • Labels:
      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>

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

        Activity

        Show
        Boris Kuznetsov added a comment - Please see discussion [1] on harmony-dev. [1] http://mail-archives.apache.org/mod_mbox/incubator-harmony-dev/200610.mbox/%3cb266b8670610040224h4a09967dpf23be81e72637d13@mail.gmail.com%3e
        Hide
        Boris Kuznetsov added a comment -

        Patches to fix tests in luni and security modules.

        Show
        Boris Kuznetsov added a comment - Patches to fix tests in luni and security modules.
        Hide
        Tim Ellison added a comment -

        Thanks Alexey.

        Patch applied to LUNI and SECURITY modules at repo revision r469230.

        Please check that the patch was applied as you expected.

        Show
        Tim Ellison added a comment - Thanks Alexey. Patch applied to LUNI and SECURITY modules at repo revision r469230. Please check that the patch was applied as you expected.
        Hide
        Alexey Varlamov added a comment -

        Verified on DRLVM.

        Show
        Alexey Varlamov added a comment - Verified on DRLVM.
        Hide
        Tim Ellison added a comment -

        Verified by Alexey.

        Show
        Tim Ellison added a comment - Verified by Alexey.

          People

          • Assignee:
            Tim Ellison
            Reporter:
            Alexey Varlamov
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development