8189291: Test policy should extend the default system policy
Reviewed-by: mchung
This commit is contained in:
parent
aae091f644
commit
ab49e12b7f
test/jdk/java
lang
StackWalker
System/LoggerFinder/internal
BaseDefaultLoggerFinderTest
BootstrapLogger
LoggerFinderLoaderTest
reflect/Proxy/nonPublicProxy
net/URLPermission/nstest
util
concurrent/atomic
logging
LogManager/Configuration/updateConfiguration
Logger/setResourceBundle
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -42,6 +42,7 @@ import java.util.function.Supplier;
|
||||
* StackWalker::getCallerClass can't be called from @CallerSensitive method.
|
||||
*/
|
||||
public class CallerSensitiveTest {
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
private static final String NON_CSM_CALLER_METHOD = "getCallerClass";
|
||||
private static final String CSM_CALLER_METHOD = "caller";
|
||||
|
||||
@ -54,7 +55,8 @@ public class CallerSensitiveTest {
|
||||
Policy.setPolicy(new Policy() {
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission p) {
|
||||
return perms.implies(p);
|
||||
return perms.implies(p) ||
|
||||
DEFAULT_POLICY.implies(domain, p);
|
||||
}
|
||||
});
|
||||
System.setSecurityManager(new SecurityManager());
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8140450 8152893
|
||||
* @bug 8140450 8152893 8189291
|
||||
* @summary Basic test for StackWalker.getCallerClass()
|
||||
* @run main/othervm GetCallerClassTest
|
||||
* @run main/othervm GetCallerClassTest sm
|
||||
@ -45,6 +45,7 @@ import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
public class GetCallerClassTest {
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
private final StackWalker walker;
|
||||
private final boolean expectUOE;
|
||||
|
||||
@ -59,7 +60,8 @@ public class GetCallerClassTest {
|
||||
Policy.setPolicy(new Policy() {
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission p) {
|
||||
return perms.implies(p);
|
||||
return perms.implies(p) ||
|
||||
DEFAULT_POLICY.implies(domain, p);
|
||||
}
|
||||
});
|
||||
System.setSecurityManager(new SecurityManager());
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -58,7 +58,7 @@ import sun.util.logging.PlatformLogger;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8140364 8145686
|
||||
* @bug 8140364 8145686 8189291
|
||||
* @summary JDK implementation specific unit test for the base DefaultLoggerFinder.
|
||||
* Tests the behavior of DefaultLoggerFinder and SimpleConsoleLogger
|
||||
* implementation.
|
||||
@ -75,6 +75,7 @@ import sun.util.logging.PlatformLogger;
|
||||
*/
|
||||
public class BaseDefaultLoggerFinderTest {
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
static final RuntimePermission LOGGERFINDER_PERMISSION =
|
||||
new RuntimePermission("loggerFinder");
|
||||
final static boolean VERBOSE = false;
|
||||
@ -959,7 +960,8 @@ public class BaseDefaultLoggerFinderTest {
|
||||
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission permission) {
|
||||
return getPermissions().implies(permission);
|
||||
return getPermissions().implies(permission) ||
|
||||
DEFAULT_POLICY.implies(domain, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -46,7 +46,7 @@ import jdk.internal.logger.LazyLoggers;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8140364
|
||||
* @bug 8140364 8189291
|
||||
* @author danielfuchs
|
||||
* @summary JDK implementation specific unit test for JDK internal artifacts.
|
||||
Tests the behavior of bootstrap loggers (and SimpleConsoleLoggers
|
||||
@ -60,6 +60,7 @@ import jdk.internal.logger.LazyLoggers;
|
||||
*/
|
||||
public class BootstrapLoggerTest {
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
static final Method isAlive;
|
||||
static final Field logManagerInitialized;
|
||||
static {
|
||||
@ -365,7 +366,8 @@ public class BootstrapLoggerTest {
|
||||
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission permission) {
|
||||
return getPermissions(domain).implies(permission);
|
||||
return getPermissions(domain).implies(permission) ||
|
||||
DEFAULT_POLICY.implies(domain, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
8
test/jdk/java/lang/System/LoggerFinder/internal/LoggerFinderLoaderTest/LoggerFinderLoaderTest.java
8
test/jdk/java/lang/System/LoggerFinder/internal/LoggerFinderLoaderTest/LoggerFinderLoaderTest.java
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -56,7 +56,7 @@ import jdk.internal.logger.SimpleConsoleLogger;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8140364
|
||||
* @bug 8140364 8189291
|
||||
* @summary JDK implementation specific unit test for LoggerFinderLoader.
|
||||
* Tests the behavior of LoggerFinderLoader with respect to the
|
||||
* value of the internal diagnosability switches. Also test the
|
||||
@ -96,6 +96,7 @@ import jdk.internal.logger.SimpleConsoleLogger;
|
||||
*/
|
||||
public class LoggerFinderLoaderTest {
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
static final RuntimePermission LOGGERFINDER_PERMISSION =
|
||||
new RuntimePermission("loggerFinder");
|
||||
final static boolean VERBOSE = false;
|
||||
@ -866,7 +867,8 @@ public class LoggerFinderLoaderTest {
|
||||
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission permission) {
|
||||
return getPermissions().implies(permission);
|
||||
return getPermissions().implies(permission) ||
|
||||
DEFAULT_POLICY.implies(domain, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -39,7 +39,7 @@ import java.util.*;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8004260
|
||||
* @bug 8004260 8189291
|
||||
* @summary Test proxy classes that implement non-public interface
|
||||
*
|
||||
* @build p.Foo
|
||||
@ -48,6 +48,8 @@ import java.util.*;
|
||||
* @run main/othervm NonPublicProxyClass
|
||||
*/
|
||||
public class NonPublicProxyClass {
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
public interface PublicInterface {
|
||||
void foo();
|
||||
}
|
||||
@ -200,7 +202,8 @@ public class NonPublicProxyClass {
|
||||
}
|
||||
|
||||
public boolean implies(ProtectionDomain domain, Permission perm) {
|
||||
return permissions.implies(perm);
|
||||
return permissions.implies(perm) ||
|
||||
DEFAULT_POLICY.implies(domain, perm);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -54,6 +54,7 @@ import static java.nio.charset.StandardCharsets.US_ASCII;
|
||||
|
||||
public class LookupTest {
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
static int port;
|
||||
static volatile ServerSocket serverSocket;
|
||||
|
||||
@ -210,7 +211,7 @@ public class LookupTest {
|
||||
}
|
||||
|
||||
public boolean implies(ProtectionDomain domain, Permission perm) {
|
||||
return perms.implies(perm);
|
||||
return perms.implies(perm) || DEFAULT_POLICY.implies(domain, perm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 7103570
|
||||
* @bug 7103570 8189291
|
||||
* @author David Holmes
|
||||
* @run main/othervm AtomicUpdaters
|
||||
* @run main/othervm AtomicUpdaters UseSM
|
||||
@ -47,6 +47,8 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
|
||||
|
||||
public class AtomicUpdaters {
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
enum TYPE { INT, LONG, REF }
|
||||
|
||||
static class Config {
|
||||
@ -216,7 +218,8 @@ public class AtomicUpdaters {
|
||||
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain pd, Permission p) {
|
||||
return Policy.UNSUPPORTED_EMPTY_COLLECTION.implies(p);
|
||||
return Policy.UNSUPPORTED_EMPTY_COLLECTION.implies(p) ||
|
||||
DEFAULT_POLICY.implies(pd, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -50,13 +50,14 @@ import java.util.logging.LoggingPermission;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8033661
|
||||
* @bug 8033661 8189291
|
||||
* @summary tests LogManager.updateConfiguration(InputStream, Function) method
|
||||
* @run main/othervm SimpleUpdateConfigWithInputStreamTest UNSECURE
|
||||
* @run main/othervm SimpleUpdateConfigWithInputStreamTest SECURE
|
||||
* @author danielfuchs
|
||||
*/
|
||||
public class SimpleUpdateConfigWithInputStreamTest {
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
/**
|
||||
* We will test updateConfiguration in
|
||||
@ -655,7 +656,8 @@ public class SimpleUpdateConfigWithInputStreamTest {
|
||||
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission permission) {
|
||||
return getPermissions(domain).implies(permission);
|
||||
return getPermissions(domain).implies(permission) ||
|
||||
DEFAULT_POLICY.implies(domain, permission);
|
||||
}
|
||||
|
||||
public PermissionCollection permissions() {
|
||||
|
9
test/jdk/java/util/logging/LogManager/Configuration/updateConfiguration/UpdateConfigurationTest.java
9
test/jdk/java/util/logging/LogManager/Configuration/updateConfiguration/UpdateConfigurationTest.java
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -59,7 +59,7 @@ import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8033661
|
||||
* @bug 8033661 8189291
|
||||
* @summary tests LogManager.updateConfiguration(bin)
|
||||
* @modules java.logging/java.util.logging:open
|
||||
* @run main/othervm UpdateConfigurationTest UNSECURE
|
||||
@ -68,6 +68,8 @@ import java.util.stream.Stream;
|
||||
*/
|
||||
public class UpdateConfigurationTest {
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
/**
|
||||
* We will test the handling of abstract logger nodes with file handlers in
|
||||
* two configurations:
|
||||
@ -594,7 +596,8 @@ public class UpdateConfigurationTest {
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission permission) {
|
||||
if (allowAll.get().get()) return allPermissions.implies(permission);
|
||||
return permissions.implies(permission);
|
||||
return permissions.implies(permission) ||
|
||||
DEFAULT_POLICY.implies(domain, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -39,7 +39,7 @@ import resources.ListBundle;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8013839
|
||||
* @bug 8013839 8189291
|
||||
* @summary tests Logger.setResourceBundle;
|
||||
* @build TestSetResourceBundle resources.ListBundle resources.ListBundle_fr
|
||||
* @run main/othervm TestSetResourceBundle UNSECURE
|
||||
@ -49,6 +49,7 @@ import resources.ListBundle;
|
||||
*/
|
||||
public class TestSetResourceBundle {
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
static final String LIST_BUNDLE_NAME = "resources.ListBundle";
|
||||
static final String PROPERTY_BUNDLE_NAME = "resources.PropertyBundle";
|
||||
|
||||
@ -479,7 +480,8 @@ public class TestSetResourceBundle {
|
||||
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission permission) {
|
||||
return permissions.implies(permission);
|
||||
return permissions.implies(permission) ||
|
||||
DEFAULT_POLICY.implies(domain, permission);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user