Skip to content

Commit b7b8aa7

Browse files
introduce destructiveOperations field in test class
1 parent de29062 commit b7b8aa7

File tree

1 file changed

+18
-52
lines changed

1 file changed

+18
-52
lines changed

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

Lines changed: 18 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ public class SecurityServerTransportInterceptorTests extends ESTestCase {
120120
private SecurityContext securityContext;
121121
private ClusterService clusterService;
122122
private MockLicenseState mockLicenseState;
123+
private DestructiveOperations destructiveOperations;
123124

124125
@Override
125126
public void setUp() throws Exception {
@@ -131,6 +132,10 @@ public void setUp() throws Exception {
131132
securityContext = spy(new SecurityContext(settings, threadPool.getThreadContext()));
132133
mockLicenseState = MockLicenseState.createMock();
133134
Mockito.when(mockLicenseState.isAllowed(Security.ADVANCED_REMOTE_CLUSTER_SECURITY_FEATURE)).thenReturn(true);
135+
destructiveOperations = new DestructiveOperations(
136+
Settings.EMPTY,
137+
new ClusterSettings(Settings.EMPTY, Collections.singleton(DestructiveOperations.REQUIRES_NAME_SETTING))
138+
);
134139
}
135140

136141
@After
@@ -151,10 +156,7 @@ public void testSendAsync() throws Exception {
151156
threadPool,
152157
mockSslService(),
153158
securityContext,
154-
new DestructiveOperations(
155-
Settings.EMPTY,
156-
new ClusterSettings(Settings.EMPTY, Collections.singleton(DestructiveOperations.REQUIRES_NAME_SETTING))
157-
),
159+
destructiveOperations,
158160
new CrossClusterAccessTransportInterceptor(
159161
mock(CrossClusterAccessAuthenticationService.class),
160162
mock(AuthenticationService.class),
@@ -207,10 +209,7 @@ public void testSendAsyncSwitchToSystem() throws Exception {
207209
threadPool,
208210
mockSslService(),
209211
securityContext,
210-
new DestructiveOperations(
211-
Settings.EMPTY,
212-
new ClusterSettings(Settings.EMPTY, Collections.singleton(DestructiveOperations.REQUIRES_NAME_SETTING))
213-
),
212+
destructiveOperations,
214213
new CrossClusterAccessTransportInterceptor(
215214
mock(CrossClusterAccessAuthenticationService.class),
216215
mock(AuthenticationService.class),
@@ -256,10 +255,7 @@ public void testSendWithoutUser() throws Exception {
256255
threadPool,
257256
mockSslService(),
258257
securityContext,
259-
new DestructiveOperations(
260-
Settings.EMPTY,
261-
new ClusterSettings(Settings.EMPTY, Collections.singleton(DestructiveOperations.REQUIRES_NAME_SETTING))
262-
),
258+
destructiveOperations,
263259
new CrossClusterAccessTransportInterceptor(
264260
mock(CrossClusterAccessAuthenticationService.class),
265261
mock(AuthenticationService.class),
@@ -323,10 +319,7 @@ public void testSendToNewerVersionSetsCorrectVersion() throws Exception {
323319
threadPool,
324320
mockSslService(),
325321
securityContext,
326-
new DestructiveOperations(
327-
Settings.EMPTY,
328-
new ClusterSettings(Settings.EMPTY, Collections.singleton(DestructiveOperations.REQUIRES_NAME_SETTING))
329-
),
322+
destructiveOperations,
330323
new CrossClusterAccessTransportInterceptor(
331324
mock(CrossClusterAccessAuthenticationService.class),
332325
mock(AuthenticationService.class),
@@ -396,10 +389,7 @@ public void testSendToOlderVersionSetsCorrectVersion() throws Exception {
396389
threadPool,
397390
mockSslService(),
398391
securityContext,
399-
new DestructiveOperations(
400-
Settings.EMPTY,
401-
new ClusterSettings(Settings.EMPTY, Collections.singleton(DestructiveOperations.REQUIRES_NAME_SETTING))
402-
),
392+
destructiveOperations,
403393
new CrossClusterAccessTransportInterceptor(
404394
mock(CrossClusterAccessAuthenticationService.class),
405395
mock(AuthenticationService.class),
@@ -467,10 +457,7 @@ public void testSetUserBasedOnActionOrigin() {
467457
threadPool,
468458
mockSslService(),
469459
securityContext,
470-
new DestructiveOperations(
471-
Settings.EMPTY,
472-
new ClusterSettings(Settings.EMPTY, Collections.singleton(DestructiveOperations.REQUIRES_NAME_SETTING))
473-
),
460+
destructiveOperations,
474461
new CrossClusterAccessTransportInterceptor(
475462
mock(CrossClusterAccessAuthenticationService.class),
476463
mock(AuthenticationService.class),
@@ -639,10 +626,7 @@ public void testSendWithCrossClusterAccessHeadersWithUnsupportedLicense() throws
639626
threadPool,
640627
mockSslService(),
641628
securityContext,
642-
new DestructiveOperations(
643-
Settings.EMPTY,
644-
new ClusterSettings(Settings.EMPTY, Collections.singleton(DestructiveOperations.REQUIRES_NAME_SETTING))
645-
),
629+
destructiveOperations,
646630
new CrossClusterAccessTransportInterceptor(
647631
mock(CrossClusterAccessAuthenticationService.class),
648632
mock(AuthenticationService.class),
@@ -781,10 +765,7 @@ private void doTestSendWithCrossClusterAccessHeaders(
781765
threadPool,
782766
mockSslService(),
783767
securityContext,
784-
new DestructiveOperations(
785-
Settings.EMPTY,
786-
new ClusterSettings(Settings.EMPTY, Collections.singleton(DestructiveOperations.REQUIRES_NAME_SETTING))
787-
),
768+
destructiveOperations,
788769
new CrossClusterAccessTransportInterceptor(
789770
mock(CrossClusterAccessAuthenticationService.class),
790771
mock(AuthenticationService.class),
@@ -926,10 +907,7 @@ public void testSendWithUserIfCrossClusterAccessHeadersConditionNotMet() throws
926907
threadPool,
927908
mockSslService(),
928909
securityContext,
929-
new DestructiveOperations(
930-
Settings.EMPTY,
931-
new ClusterSettings(Settings.EMPTY, Collections.singleton(DestructiveOperations.REQUIRES_NAME_SETTING))
932-
),
910+
destructiveOperations,
933911
new CrossClusterAccessTransportInterceptor(
934912
mock(CrossClusterAccessAuthenticationService.class),
935913
mock(AuthenticationService.class),
@@ -992,10 +970,7 @@ public void testSendWithCrossClusterAccessHeadersThrowsOnOldConnection() throws
992970
threadPool,
993971
mockSslService(),
994972
securityContext,
995-
new DestructiveOperations(
996-
Settings.EMPTY,
997-
new ClusterSettings(Settings.EMPTY, Collections.singleton(DestructiveOperations.REQUIRES_NAME_SETTING))
998-
),
973+
destructiveOperations,
999974
new CrossClusterAccessTransportInterceptor(
1000975
mock(CrossClusterAccessAuthenticationService.class),
1001976
mock(AuthenticationService.class),
@@ -1098,10 +1073,7 @@ public void testSendRemoteRequestFailsIfUserHasNoRemoteIndicesPrivileges() throw
10981073
threadPool,
10991074
mockSslService(),
11001075
securityContext,
1101-
new DestructiveOperations(
1102-
Settings.EMPTY,
1103-
new ClusterSettings(Settings.EMPTY, Collections.singleton(DestructiveOperations.REQUIRES_NAME_SETTING))
1104-
),
1076+
destructiveOperations,
11051077
new CrossClusterAccessTransportInterceptor(
11061078
mock(CrossClusterAccessAuthenticationService.class),
11071079
mock(AuthenticationService.class),
@@ -1215,10 +1187,7 @@ public void testProfileFiltersCreatedDifferentlyForDifferentTransportAndRemoteCl
12151187
threadPool,
12161188
sslService,
12171189
securityContext,
1218-
new DestructiveOperations(
1219-
Settings.EMPTY,
1220-
new ClusterSettings(Settings.EMPTY, Collections.singleton(DestructiveOperations.REQUIRES_NAME_SETTING))
1221-
),
1190+
destructiveOperations,
12221191
new CrossClusterAccessTransportInterceptor(
12231192
mock(CrossClusterAccessAuthenticationService.class),
12241193
mock(AuthenticationService.class),
@@ -1278,10 +1247,7 @@ public void testNoProfileFilterForRemoteClusterWhenTheFeatureIsDisabled() {
12781247
threadPool,
12791248
sslService,
12801249
securityContext,
1281-
new DestructiveOperations(
1282-
Settings.EMPTY,
1283-
new ClusterSettings(Settings.EMPTY, Collections.singleton(DestructiveOperations.REQUIRES_NAME_SETTING))
1284-
),
1250+
destructiveOperations,
12851251
new CrossClusterAccessTransportInterceptor(
12861252
mock(CrossClusterAccessAuthenticationService.class),
12871253
mock(AuthenticationService.class),

0 commit comments

Comments
 (0)