Skip to content

Commit ad6ac7d

Browse files
committed
tests too
1 parent 094f470 commit ad6ac7d

File tree

3 files changed

+4
-28
lines changed

3 files changed

+4
-28
lines changed

server/src/test/java/org/elasticsearch/common/logging/DeprecationLoggerTests.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717
import org.elasticsearch.test.ESTestCase;
1818
import org.mockito.Mockito;
1919

20-
import java.security.AccessControlContext;
21-
import java.security.AccessController;
22-
import java.security.Permissions;
23-
import java.security.PrivilegedAction;
24-
import java.security.ProtectionDomain;
2520
import java.util.concurrent.atomic.AtomicBoolean;
2621

2722
import static org.hamcrest.Matchers.equalTo;
@@ -75,13 +70,7 @@ public void testLogPermissions() {
7570

7671
DeprecationLogger deprecationLogger = DeprecationLogger.getLogger("name");
7772

78-
AccessControlContext noPermissionsAcc = new AccessControlContext(
79-
new ProtectionDomain[] { new ProtectionDomain(null, new Permissions()) }
80-
);
81-
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
82-
deprecationLogger.warn(DeprecationCategory.API, "key", "foo", "bar");
83-
return null;
84-
}, noPermissionsAcc);
73+
deprecationLogger.warn(DeprecationCategory.API, "key", "foo", "bar");
8574
assertThat("supplier called", supplierCalled.get(), is(true));
8675
} finally {
8776
LogManager.setFactory(originalFactory);

server/src/test/java/org/elasticsearch/search/lookup/LeafDocLookupTests.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
import org.junit.Before;
2525

2626
import java.io.IOException;
27-
import java.security.AccessControlContext;
28-
import java.security.AccessController;
29-
import java.security.PrivilegedAction;
30-
import java.security.ProtectionDomain;
3127
import java.util.Map;
3228
import java.util.function.BiFunction;
3329
import java.util.function.Consumer;
@@ -427,12 +423,7 @@ public void testParallelCache() {
427423
public void testLookupPrivilegesAdvanceDoc() {
428424
nextDocCallback = i -> SpecialPermission.check();
429425

430-
// mimic the untrusted codebase, which gets no permissions
431-
var restrictedContext = new AccessControlContext(new ProtectionDomain[] { new ProtectionDomain(null, null) });
432-
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
433-
ScriptDocValues<?> fetchedDocValues = docLookup.get("field");
434-
assertEquals(docValues, fetchedDocValues);
435-
return null;
436-
}, restrictedContext);
426+
ScriptDocValues<?> fetchedDocValues = docLookup.get("field");
427+
assertEquals(docValues, fetchedDocValues);
437428
}
438429
}

server/src/test/java/org/elasticsearch/transport/TransportHandshakerRawMessageTests.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
import java.net.ServerSocket;
2828
import java.net.Socket;
2929
import java.nio.charset.StandardCharsets;
30-
import java.security.AccessController;
31-
import java.security.PrivilegedExceptionAction;
3230

3331
import static org.hamcrest.Matchers.allOf;
3432
import static org.hamcrest.Matchers.greaterThan;
@@ -193,8 +191,6 @@ public void testOutboundHandshake() throws Exception {
193191

194192
private Socket openTransportConnection() throws Exception {
195193
final var transportAddress = randomFrom(getInstanceFromNode(TransportService.class).boundAddress().boundAddresses()).address();
196-
return AccessController.doPrivileged(
197-
(PrivilegedExceptionAction<Socket>) (() -> new Socket(transportAddress.getAddress(), transportAddress.getPort()))
198-
);
194+
return new Socket(transportAddress.getAddress(), transportAddress.getPort());
199195
}
200196
}

0 commit comments

Comments
 (0)