Skip to content

Commit 4981394

Browse files
move to using new constructor part 2
1 parent 99d7319 commit 4981394

File tree

2 files changed

+63
-54
lines changed

2 files changed

+63
-54
lines changed

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/SecurityServerTransportInterceptor.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.elasticsearch.license.XPackLicenseState;
2020
import org.elasticsearch.tasks.Task;
2121
import org.elasticsearch.threadpool.ThreadPool;
22-
import org.elasticsearch.transport.RemoteConnectionManager;
2322
import org.elasticsearch.transport.RemoteConnectionManager.RemoteClusterAliasWithCredentials;
2423
import org.elasticsearch.transport.SendRequestTransportException;
2524
import org.elasticsearch.transport.Transport;
@@ -74,31 +73,6 @@ public SecurityServerTransportInterceptor(
7473
this.profileFilters = this.remoteClusterTransportInterceptor.getProfileFilters(profileConfigurations, destructiveOperations);
7574
}
7675

77-
public SecurityServerTransportInterceptor(
78-
Settings settings,
79-
ThreadPool threadPool,
80-
AuthenticationService authcService,
81-
AuthorizationService authzService,
82-
SSLService sslService,
83-
SecurityContext securityContext,
84-
DestructiveOperations destructiveOperations,
85-
CrossClusterAccessAuthenticationService crossClusterAccessAuthcService,
86-
XPackLicenseState licenseState
87-
) {
88-
this(
89-
settings,
90-
threadPool,
91-
authcService,
92-
authzService,
93-
sslService,
94-
securityContext,
95-
destructiveOperations,
96-
crossClusterAccessAuthcService,
97-
licenseState,
98-
RemoteConnectionManager::resolveRemoteClusterAliasWithCredentials
99-
);
100-
}
101-
10276
SecurityServerTransportInterceptor(
10377
Settings settings,
10478
ThreadPool threadPool,

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/SecurityServerTransportInterceptorTests.java

Lines changed: 63 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -205,16 +205,21 @@ public void testSendAsyncSwitchToSystem() throws Exception {
205205
SecurityServerTransportInterceptor interceptor = new SecurityServerTransportInterceptor(
206206
settings,
207207
threadPool,
208-
mock(AuthenticationService.class),
209-
mock(AuthorizationService.class),
210208
mockSslService(),
211209
securityContext,
212210
new DestructiveOperations(
213211
Settings.EMPTY,
214212
new ClusterSettings(Settings.EMPTY, Collections.singleton(DestructiveOperations.REQUIRES_NAME_SETTING))
215213
),
216-
mock(CrossClusterAccessAuthenticationService.class),
217-
mockLicenseState
214+
new CrossClusterAccessTransportInterceptor(
215+
mock(CrossClusterAccessAuthenticationService.class),
216+
mock(AuthenticationService.class),
217+
mock(AuthorizationService.class),
218+
mockLicenseState,
219+
securityContext,
220+
threadPool,
221+
settings
222+
)
218223
);
219224
ClusterServiceUtils.setState(clusterService, clusterService.state()); // force state update to trigger listener
220225

@@ -249,16 +254,21 @@ public void testSendWithoutUser() throws Exception {
249254
SecurityServerTransportInterceptor interceptor = new SecurityServerTransportInterceptor(
250255
settings,
251256
threadPool,
252-
mock(AuthenticationService.class),
253-
mock(AuthorizationService.class),
254257
mockSslService(),
255258
securityContext,
256259
new DestructiveOperations(
257260
Settings.EMPTY,
258261
new ClusterSettings(Settings.EMPTY, Collections.singleton(DestructiveOperations.REQUIRES_NAME_SETTING))
259262
),
260-
mock(CrossClusterAccessAuthenticationService.class),
261-
mockLicenseState
263+
new CrossClusterAccessTransportInterceptor(
264+
mock(CrossClusterAccessAuthenticationService.class),
265+
mock(AuthenticationService.class),
266+
mock(AuthorizationService.class),
267+
mockLicenseState,
268+
securityContext,
269+
threadPool,
270+
settings
271+
)
262272
) {
263273
@Override
264274
void assertNoAuthentication(String action) {}
@@ -311,16 +321,21 @@ public void testSendToNewerVersionSetsCorrectVersion() throws Exception {
311321
SecurityServerTransportInterceptor interceptor = new SecurityServerTransportInterceptor(
312322
settings,
313323
threadPool,
314-
mock(AuthenticationService.class),
315-
mock(AuthorizationService.class),
316324
mockSslService(),
317325
securityContext,
318326
new DestructiveOperations(
319327
Settings.EMPTY,
320328
new ClusterSettings(Settings.EMPTY, Collections.singleton(DestructiveOperations.REQUIRES_NAME_SETTING))
321329
),
322-
mock(CrossClusterAccessAuthenticationService.class),
323-
mockLicenseState
330+
new CrossClusterAccessTransportInterceptor(
331+
mock(CrossClusterAccessAuthenticationService.class),
332+
mock(AuthenticationService.class),
333+
mock(AuthorizationService.class),
334+
mockLicenseState,
335+
securityContext,
336+
threadPool,
337+
settings
338+
)
324339
);
325340
ClusterServiceUtils.setState(clusterService, clusterService.state()); // force state update to trigger listener
326341

@@ -379,16 +394,21 @@ public void testSendToOlderVersionSetsCorrectVersion() throws Exception {
379394
SecurityServerTransportInterceptor interceptor = new SecurityServerTransportInterceptor(
380395
settings,
381396
threadPool,
382-
mock(AuthenticationService.class),
383-
mock(AuthorizationService.class),
384397
mockSslService(),
385398
securityContext,
386399
new DestructiveOperations(
387400
Settings.EMPTY,
388401
new ClusterSettings(Settings.EMPTY, Collections.singleton(DestructiveOperations.REQUIRES_NAME_SETTING))
389402
),
390-
mock(CrossClusterAccessAuthenticationService.class),
391-
mockLicenseState
403+
new CrossClusterAccessTransportInterceptor(
404+
mock(CrossClusterAccessAuthenticationService.class),
405+
mock(AuthenticationService.class),
406+
mock(AuthorizationService.class),
407+
mockLicenseState,
408+
securityContext,
409+
threadPool,
410+
settings
411+
)
392412
);
393413
ClusterServiceUtils.setState(clusterService, clusterService.state()); // force state update to trigger listener
394414

@@ -445,16 +465,21 @@ public void testSetUserBasedOnActionOrigin() {
445465
SecurityServerTransportInterceptor interceptor = new SecurityServerTransportInterceptor(
446466
settings,
447467
threadPool,
448-
mock(AuthenticationService.class),
449-
mock(AuthorizationService.class),
450468
mockSslService(),
451469
securityContext,
452470
new DestructiveOperations(
453471
Settings.EMPTY,
454472
new ClusterSettings(Settings.EMPTY, Collections.singleton(DestructiveOperations.REQUIRES_NAME_SETTING))
455473
),
456-
mock(CrossClusterAccessAuthenticationService.class),
457-
mockLicenseState
474+
new CrossClusterAccessTransportInterceptor(
475+
mock(CrossClusterAccessAuthenticationService.class),
476+
mock(AuthenticationService.class),
477+
mock(AuthorizationService.class),
478+
mockLicenseState,
479+
securityContext,
480+
threadPool,
481+
settings
482+
)
458483
);
459484

460485
final AtomicBoolean calledWrappedSender = new AtomicBoolean(false);
@@ -1155,16 +1180,21 @@ public void testProfileFiltersCreatedDifferentlyForDifferentTransportAndRemoteCl
11551180
final var securityServerTransportInterceptor = new SecurityServerTransportInterceptor(
11561181
builder.build(),
11571182
threadPool,
1158-
mock(AuthenticationService.class),
1159-
mock(AuthorizationService.class),
11601183
sslService,
11611184
securityContext,
11621185
new DestructiveOperations(
11631186
Settings.EMPTY,
11641187
new ClusterSettings(Settings.EMPTY, Collections.singleton(DestructiveOperations.REQUIRES_NAME_SETTING))
11651188
),
1166-
mock(CrossClusterAccessAuthenticationService.class),
1167-
mockLicenseState
1189+
new CrossClusterAccessTransportInterceptor(
1190+
mock(CrossClusterAccessAuthenticationService.class),
1191+
mock(AuthenticationService.class),
1192+
mock(AuthorizationService.class),
1193+
mockLicenseState,
1194+
securityContext,
1195+
threadPool,
1196+
builder.build()
1197+
)
11681198
);
11691199

11701200
final Map<String, ServerTransportFilter> profileFilters = securityServerTransportInterceptor.getProfileFilters();
@@ -1213,16 +1243,21 @@ public void testNoProfileFilterForRemoteClusterWhenTheFeatureIsDisabled() {
12131243
final var securityServerTransportInterceptor = new SecurityServerTransportInterceptor(
12141244
builder.build(),
12151245
threadPool,
1216-
mock(AuthenticationService.class),
1217-
mock(AuthorizationService.class),
12181246
sslService,
12191247
securityContext,
12201248
new DestructiveOperations(
12211249
Settings.EMPTY,
12221250
new ClusterSettings(Settings.EMPTY, Collections.singleton(DestructiveOperations.REQUIRES_NAME_SETTING))
12231251
),
1224-
mock(CrossClusterAccessAuthenticationService.class),
1225-
mockLicenseState
1252+
new CrossClusterAccessTransportInterceptor(
1253+
mock(CrossClusterAccessAuthenticationService.class),
1254+
mock(AuthenticationService.class),
1255+
mock(AuthorizationService.class),
1256+
mockLicenseState,
1257+
securityContext,
1258+
threadPool,
1259+
builder.build()
1260+
)
12261261
);
12271262

12281263
final Map<String, ServerTransportFilter> profileFilters = securityServerTransportInterceptor.getProfileFilters();

0 commit comments

Comments
 (0)