Skip to content

Commit ceb5ad2

Browse files
Format all *.java files tests under test/security (opensearch-project#2837)
* Update test/security/s* java files Signed-off-by: Stephen Crawford <steecraw@amazon.com> * Update test/security/s* java files Signed-off-by: Stephen Crawford <steecraw@amazon.com> * Update all tests under security Signed-off-by: Stephen Crawford <steecraw@amazon.com> --------- Signed-off-by: Stephen Crawford <steecraw@amazon.com>
1 parent bfc8a6b commit ceb5ad2

File tree

167 files changed

+14803
-9161
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+14803
-9161
lines changed

build.gradle

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,7 @@ spotless {
7878
// non-standard places
7979
target '**/com/amazon/dlic/**/*.java'
8080
target '**/com/amazon/security/**/*.java'
81-
target '**/test/java/org/opensearch/security/a*/**/*.java'
82-
target '**/test/java/org/opensearch/security/b*/**/*.java'
83-
target '**/test/java/org/opensearch/security/c*/**/*.java'
84-
target '**/test/java/org/opensearch/security/d*/**/*.java'
85-
target '**/test/java/org/opensearch/security/f*/**/*.java'
86-
target '**/test/java/org/opensearch/security/h*/**/*.java'
87-
target '**/test/java/org/opensearch/security/m*/**/*.java'
88-
target '**/test/java/org/opensearch/security/s*/**/*.java'
81+
target '**/test/java/org/opensearch/security/**/*.java'
8982

9083
removeUnusedImports()
9184
eclipse().configFile rootProject.file('formatter/formatterConfig.xml')
@@ -119,14 +112,7 @@ spotless {
119112
target '**/*.java'
120113
targetExclude '**/com/amazon/dlic/**/*.java'
121114
targetExclude '**/com/amazon/security/**/*.java'
122-
targetExclude '**/test/java/org/opensearch/security/a*/**/*.java'
123-
targetExclude '**/test/java/org/opensearch/security/b*/**/*.java'
124-
targetExclude '**/test/java/org/opensearch/security/c*/**/*.java'
125-
targetExclude '**/test/java/org/opensearch/security/d*/**/*.java'
126-
targetExclude '**/test/java/org/opensearch/security/f*/**/*.java'
127-
targetExclude '**/test/java/org/opensearch/security/h*/**/*.java'
128-
targetExclude '**/test/java/org/opensearch/security/m*/**/*.java'
129-
targetExclude '**/test/java/org/opensearch/security/s*/**/*.java'
115+
targetExclude '**/test/java/org/opensearch/security/**/*.java'
130116
targetExclude 'src/integrationTest/**'
131117

132118
trimTrailingWhitespace()

src/test/java/org/opensearch/security/AdvancedSecurityMigrationTests.java

Lines changed: 87 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ public void testPluginEnabledDataNodeWithSSlOnlyClusterManagerNode_ReqOnSSLNode(
5050
final Settings advSecSettings = getAdvSecSettings().build();
5151
final Settings sslOnlySettings = getSSLOnlyModeSettings().build();
5252

53-
setupGenericNodes(Arrays.asList(sslOnlySettings, advSecSettings, advSecSettings, sslOnlySettings),
54-
Arrays.asList(true, false, false, true), ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA);
53+
setupGenericNodes(
54+
Arrays.asList(sslOnlySettings, advSecSettings, advSecSettings, sslOnlySettings),
55+
Arrays.asList(true, false, false, true),
56+
ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA
57+
);
5558
Thread.sleep(10000);
5659

5760
commonTestsForAdvancedSecurityMigration(nonSslRestHelper(), null);
@@ -67,8 +70,11 @@ public void testPluginEnabledDataNodeWithSSlOnlyClusterManagerNode_ReqOnAdvSecNo
6770
final Settings advSecSettings = getAdvSecSettings().build();
6871
final Settings sslOnlySettings = getSSLOnlyModeSettings().build();
6972

70-
setupGenericNodes(Arrays.asList(advSecSettings, sslOnlySettings, advSecSettings, sslOnlySettings),
71-
Arrays.asList(false, true, false, true), ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA);
73+
setupGenericNodes(
74+
Arrays.asList(advSecSettings, sslOnlySettings, advSecSettings, sslOnlySettings),
75+
Arrays.asList(false, true, false, true),
76+
ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA
77+
);
7278
Thread.sleep(10000);
7379

7480
commonTestsForAdvancedSecurityMigration(nonSslRestHelper(), encodeBasicHeader("admin", "admin"));
@@ -84,11 +90,14 @@ public void testPluginEnabledClusterManagerNodeWithSSlOnlyDataNode_ReqOnSSLNode(
8490
final Settings advSecSettings = getAdvSecSettings().build();
8591
final Settings sslOnlySettings = getSSLOnlyModeSettings().build();
8692

87-
setupGenericNodes(Arrays.asList(sslOnlySettings, sslOnlySettings, advSecSettings, advSecSettings),
88-
Arrays.asList(true, true, false, false), ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA);
93+
setupGenericNodes(
94+
Arrays.asList(sslOnlySettings, sslOnlySettings, advSecSettings, advSecSettings),
95+
Arrays.asList(true, true, false, false),
96+
ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA
97+
);
8998
Thread.sleep(10000);
9099

91-
commonTestsForAdvancedSecurityMigration(nonSslRestHelper(),null);
100+
commonTestsForAdvancedSecurityMigration(nonSslRestHelper(), null);
92101
}
93102

94103
/**
@@ -101,8 +110,11 @@ public void testPluginEnabledClusterManagerNodeWithSSlOnlyDataNode_ReqOnAdvSecNo
101110
final Settings advSecSettings = getAdvSecSettings().build();
102111
final Settings sslOnlySettings = getSSLOnlyModeSettings().build();
103112

104-
setupGenericNodes(Arrays.asList(advSecSettings, sslOnlySettings, sslOnlySettings, advSecSettings),
105-
Arrays.asList(false, true, true, false), ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA);
113+
setupGenericNodes(
114+
Arrays.asList(advSecSettings, sslOnlySettings, sslOnlySettings, advSecSettings),
115+
Arrays.asList(false, true, true, false),
116+
ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA
117+
);
106118
Thread.sleep(10000);
107119

108120
commonTestsForAdvancedSecurityMigration(nonSslRestHelper(), encodeBasicHeader("admin", "admin"));
@@ -118,11 +130,14 @@ public void testPluginEnabledDataNodeWithDisabledClusterManagerNode_ReqOnDisable
118130
final Settings advSecSettings = getAdvSecSettingsDualMode().build();
119131
final Settings disabledSettings = getDisabledSettings().build();
120132

121-
setupGenericNodes(Arrays.asList(disabledSettings, advSecSettings, advSecSettings, disabledSettings),
122-
Arrays.asList(false, false, false, false), ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA);
133+
setupGenericNodes(
134+
Arrays.asList(disabledSettings, advSecSettings, advSecSettings, disabledSettings),
135+
Arrays.asList(false, false, false, false),
136+
ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA
137+
);
123138
Thread.sleep(10000);
124139

125-
commonTestsForAdvancedSecurityMigration(nonSslRestHelper(),null);
140+
commonTestsForAdvancedSecurityMigration(nonSslRestHelper(), null);
126141
}
127142

128143
/**
@@ -135,8 +150,11 @@ public void testPluginEnabledDataNodeWithDisabledClusterManagerNode_ReqOnAdvSecN
135150
final Settings advSecSettings = getAdvSecSettingsDualMode().build();
136151
final Settings disabledSettings = getDisabledSettings().build();
137152

138-
setupGenericNodes(Arrays.asList(advSecSettings, disabledSettings, advSecSettings, disabledSettings),
139-
Arrays.asList(false, false, false, false), ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA);
153+
setupGenericNodes(
154+
Arrays.asList(advSecSettings, disabledSettings, advSecSettings, disabledSettings),
155+
Arrays.asList(false, false, false, false),
156+
ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA
157+
);
140158
Thread.sleep(10000);
141159

142160
commonTestsForAdvancedSecurityMigration(nonSslRestHelper(), encodeBasicHeader("admin", "admin"));
@@ -152,8 +170,11 @@ public void testPluginEnabledClusterManagerNodeWithDisabledDataNode_ReqOnDisable
152170
final Settings advSecSettings = getAdvSecSettingsDualMode().build();
153171
final Settings disabledSettings = getDisabledSettings().build();
154172

155-
setupGenericNodes(Arrays.asList(disabledSettings, disabledSettings, advSecSettings, advSecSettings),
156-
Arrays.asList(false, false, false, false), ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA);
173+
setupGenericNodes(
174+
Arrays.asList(disabledSettings, disabledSettings, advSecSettings, advSecSettings),
175+
Arrays.asList(false, false, false, false),
176+
ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA
177+
);
157178
Thread.sleep(10000);
158179

159180
commonTestsForAdvancedSecurityMigration(nonSslRestHelper(), null);
@@ -169,22 +190,29 @@ public void testPluginEnabledClusterManagerNodeWithDisabledDataNode_ReqOnAdvSecN
169190
final Settings advSecSettings = getAdvSecSettingsDualMode().build();
170191
final Settings disabledSettings = getDisabledSettings().build();
171192

172-
setupGenericNodes(Arrays.asList(advSecSettings, disabledSettings, advSecSettings, advSecSettings),
173-
Arrays.asList(false, false, false, false), ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA);
193+
setupGenericNodes(
194+
Arrays.asList(advSecSettings, disabledSettings, advSecSettings, advSecSettings),
195+
Arrays.asList(false, false, false, false),
196+
ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA
197+
);
174198
Thread.sleep(10000);
175199

176200
commonTestsForAdvancedSecurityMigration(nonSslRestHelper(), encodeBasicHeader("admin", "admin"));
177201
}
178202

179203
@Test
180204
public void testWithPassiveAuthDisabled() throws Exception {
181-
final Settings advSecSettings = getAdvSecSettings()
182-
.put(ConfigConstants.SECURITY_UNSUPPORTED_PASSIVE_INTERTRANSPORT_AUTH_INITIALLY, false)
183-
.build();
205+
final Settings advSecSettings = getAdvSecSettings().put(
206+
ConfigConstants.SECURITY_UNSUPPORTED_PASSIVE_INTERTRANSPORT_AUTH_INITIALLY,
207+
false
208+
).build();
184209
final Settings sslOnlySettings = getSSLOnlyModeSettings().build();
185210

186-
setupGenericNodes(Arrays.asList(sslOnlySettings, sslOnlySettings, advSecSettings, advSecSettings),
187-
Arrays.asList(true, true, false, false), ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA);
211+
setupGenericNodes(
212+
Arrays.asList(sslOnlySettings, sslOnlySettings, advSecSettings, advSecSettings),
213+
Arrays.asList(true, true, false, false),
214+
ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA
215+
);
188216
Thread.sleep(10000);
189217

190218
RestHelper.HttpResponse res;
@@ -196,15 +224,19 @@ public void testWithPassiveAuthDisabled() throws Exception {
196224
@Test
197225
public void testWithPassiveAuthDisabledDynamic() throws Exception {
198226

199-
final Settings advSecSettings = getAdvSecSettingsDualMode()
200-
.put(ConfigConstants.SECURITY_UNSUPPORTED_PASSIVE_INTERTRANSPORT_AUTH_INITIALLY, false)
201-
.build();
227+
final Settings advSecSettings = getAdvSecSettingsDualMode().put(
228+
ConfigConstants.SECURITY_UNSUPPORTED_PASSIVE_INTERTRANSPORT_AUTH_INITIALLY,
229+
false
230+
).build();
202231
final Settings disabledSettings = getDisabledSettings().build();
203232

204-
setupGenericNodes(Arrays.asList(disabledSettings, disabledSettings, advSecSettings, advSecSettings),
205-
Arrays.asList(false, false, false, false), ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA);
233+
setupGenericNodes(
234+
Arrays.asList(disabledSettings, disabledSettings, advSecSettings, advSecSettings),
235+
Arrays.asList(false, false, false, false),
236+
ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA
237+
);
206238

207-
Thread.sleep(5*1000);
239+
Thread.sleep(5 * 1000);
208240

209241
RestHelper.HttpResponse res;
210242
RestHelper rh = nonSslRestHelper();
@@ -214,7 +246,7 @@ public void testWithPassiveAuthDisabledDynamic() throws Exception {
214246
}
215247

216248
private void commonTestsForAdvancedSecurityMigration(final RestHelper rh, final Header basicHeaders) throws Exception {
217-
Thread.sleep(5*1000);
249+
Thread.sleep(5 * 1000);
218250

219251
RestHelper.HttpResponse res;
220252
res = rh.executePutRequest("testindex", getIndexSettingsForAdvSec(), basicHeaders);
@@ -250,50 +282,47 @@ private void commonTestsForAnIndex(final RestHelper rh, final String index, fina
250282

251283
private Settings.Builder getAdvSecSettings() {
252284
return Settings.builder()
253-
.put(ConfigConstants.SECURITY_ALLOW_DEFAULT_INIT_SECURITYINDEX, true)
254-
.put(ConfigConstants.SECURITY_UNSUPPORTED_PASSIVE_INTERTRANSPORT_AUTH_INITIALLY, true)
255-
.put(ConfigConstants.SECURITY_UNSUPPORTED_RESTAPI_ALLOW_SECURITYCONFIG_MODIFICATION, true)
256-
.put("node.attr.custom_node", true);
285+
.put(ConfigConstants.SECURITY_ALLOW_DEFAULT_INIT_SECURITYINDEX, true)
286+
.put(ConfigConstants.SECURITY_UNSUPPORTED_PASSIVE_INTERTRANSPORT_AUTH_INITIALLY, true)
287+
.put(ConfigConstants.SECURITY_UNSUPPORTED_RESTAPI_ALLOW_SECURITYCONFIG_MODIFICATION, true)
288+
.put("node.attr.custom_node", true);
257289
}
258290

259291
private Settings.Builder getAdvSecSettingsDualMode() {
260-
return getAdvSecSettings()
261-
.put(ConfigConstants.SECURITY_CONFIG_SSL_DUAL_MODE_ENABLED, true);
292+
return getAdvSecSettings().put(ConfigConstants.SECURITY_CONFIG_SSL_DUAL_MODE_ENABLED, true);
262293
}
263294

264295
private Settings.Builder getSSLOnlyModeSettings() {
265-
return Settings.builder()
266-
.put(ConfigConstants.SECURITY_SSL_ONLY, true);
296+
return Settings.builder().put(ConfigConstants.SECURITY_SSL_ONLY, true);
267297
}
268298

269299
private Settings.Builder getDisabledSettings() {
270-
return Settings.builder()
271-
.put(ConfigConstants.SECURITY_DISABLED, true);
300+
return Settings.builder().put(ConfigConstants.SECURITY_DISABLED, true);
272301
}
273302

274303
// Create index with shards only in adv sec nodes
275304
private String getIndexSettingsForAdvSec() {
276-
return "{\n" +
277-
" \"settings\" : {\n" +
278-
" \"index\" : {\n" +
279-
" \"number_of_shards\" : 2, \n" +
280-
" \"number_of_replicas\" : 1, \n" +
281-
" \"routing.allocation.include.custom_node\" : true \n" +
282-
" }\n" +
283-
" }\n" +
284-
"}";
305+
return "{\n"
306+
+ " \"settings\" : {\n"
307+
+ " \"index\" : {\n"
308+
+ " \"number_of_shards\" : 2, \n"
309+
+ " \"number_of_replicas\" : 1, \n"
310+
+ " \"routing.allocation.include.custom_node\" : true \n"
311+
+ " }\n"
312+
+ " }\n"
313+
+ "}";
285314
}
286315

287316
// Create index with shards only in non adv sec nodes
288317
private String getIndexSettingForSSLOnlyNode() {
289-
return "{\n" +
290-
" \"settings\" : {\n" +
291-
" \"index\" : {\n" +
292-
" \"number_of_shards\" : 2, \n" +
293-
" \"number_of_replicas\" : 1, \n" +
294-
" \"routing.allocation.exclude.custom_node\" : true \n" +
295-
" }\n" +
296-
" }\n" +
297-
"}";
318+
return "{\n"
319+
+ " \"settings\" : {\n"
320+
+ " \"index\" : {\n"
321+
+ " \"number_of_shards\" : 2, \n"
322+
+ " \"number_of_replicas\" : 1, \n"
323+
+ " \"routing.allocation.exclude.custom_node\" : true \n"
324+
+ " }\n"
325+
+ " }\n"
326+
+ "}";
298327
}
299328
}

0 commit comments

Comments
 (0)