Skip to content

Commit 2e263b8

Browse files
Update the formatting of all *.java file under **/test/ (#2840)
* Update all tests Signed-off-by: Stephen Crawford <steecraw@amazon.com> * spotless Signed-off-by: Stephen Crawford <steecraw@amazon.com> --------- Signed-off-by: Stephen Crawford <steecraw@amazon.com>
1 parent 7e8acd4 commit 2e263b8

File tree

133 files changed

+7207
-6884
lines changed

Some content is hidden

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

133 files changed

+7207
-6884
lines changed

build.gradle

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +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/**/*.java'
81+
target '**/test/**/*.java'
8282

8383
removeUnusedImports()
8484
eclipse().configFile rootProject.file('formatter/formatterConfig.xml')
@@ -112,17 +112,11 @@ spotless {
112112
target '**/*.java'
113113
targetExclude '**/com/amazon/dlic/**/*.java'
114114
targetExclude '**/com/amazon/security/**/*.java'
115-
targetExclude '**/test/java/org/opensearch/security/**/*.java'
116-
targetExclude 'src/integrationTest/**'
115+
targetExclude '**/test/**/*.java'
117116

118117
trimTrailingWhitespace()
119118
endWithNewline();
120119
}
121-
format("integrationTest", JavaExtension) {
122-
target('src/integrationTest/java/**/*.java')
123-
importOrder('java', 'javax', '', 'com.amazon', 'org.opensearch', '\\#')
124-
indentWithTabs(4)
125-
}
126120
}
127121

128122
licenseFile = rootProject.file('LICENSE.txt')

bwc-test/src/test/java/SecurityBackwardsCompatibilityIT.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,11 @@
1212
import java.util.Set;
1313
import java.util.stream.Collectors;
1414

15-
import com.google.common.collect.ImmutableMap;
16-
import org.junit.Assert;
1715
import org.junit.Assume;
1816
import org.junit.Before;
1917

2018
import org.opensearch.Version;
21-
import org.opensearch.client.Response;
2219
import org.opensearch.common.settings.Settings;
23-
import org.opensearch.rest.RestStatus;
2420
import org.opensearch.test.rest.OpenSearchRestTestCase;
2521

2622
import static org.hamcrest.MatcherAssert.assertThat;
@@ -56,14 +52,13 @@ protected boolean preserveTemplatesUponCompletion() {
5652

5753
@Override
5854
protected final Settings restClientSettings() {
59-
return Settings
60-
.builder()
61-
.put(super.restClientSettings())
62-
// increase the timeout here to 90 seconds to handle long waits for a green
63-
// cluster health. the waits for green need to be longer than a minute to
64-
// account for delayed shards
65-
.put(OpenSearchRestTestCase.CLIENT_SOCKET_TIMEOUT, "90s")
66-
.build();
55+
return Settings.builder()
56+
.put(super.restClientSettings())
57+
// increase the timeout here to 90 seconds to handle long waits for a green
58+
// cluster health. the waits for green need to be longer than a minute to
59+
// account for delayed shards
60+
.put(OpenSearchRestTestCase.CLIENT_SOCKET_TIMEOUT, "90s")
61+
.build();
6762
}
6863

6964
public void testBasicBackwardsCompatibility() throws Exception {

src/integrationTest/java/org/opensearch/node/PluginAwareNode.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@
3333
import org.opensearch.plugins.Plugin;
3434

3535
public class PluginAwareNode extends Node {
36-
36+
3737
private final boolean clusterManagerEligible;
3838

3939
@SafeVarargs
4040
public PluginAwareNode(boolean clusterManagerEligible, final Settings preparedSettings, final Class<? extends Plugin>... plugins) {
4141
super(InternalSettingsPreparer.prepareEnvironment(preparedSettings, Collections.emptyMap(), null, () -> System.getenv("HOSTNAME")), Arrays.asList(plugins), true);
4242
this.clusterManagerEligible = clusterManagerEligible;
4343
}
44-
44+
4545

4646
public boolean isClusterManagerEligible() {
4747
return clusterManagerEligible;

src/integrationTest/java/org/opensearch/security/SecurityRolesTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ public void testSecurityRoles() throws Exception {
4747
HttpResponse response = client.getAuthInfo();
4848
response.assertStatusCode(HttpStatus.SC_OK);
4949

50-
// Check username
50+
// Check username
5151
assertThat(response.getTextFromJsonBody("/user_name"), equalTo("sr_user"));
52-
52+
5353
// Check security roles
5454
assertThat(response.getTextFromJsonBody("/roles/0"), equalTo("user_sr_user__abc_ber"));
5555
assertThat(response.getTextFromJsonBody("/roles/1"), equalTo("user_sr_user__def_efg"));

src/integrationTest/java/org/opensearch/security/http/CommonProxyAuthenticationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ abstract class CommonProxyAuthenticationTests {
3636

3737
protected static final String ATTRIBUTE_DEPARTMENT = "department";
3838
protected static final String ATTRIBUTE_SKILLS = "skills";
39-
39+
4040
protected static final String USER_ATTRIBUTE_DEPARTMENT_NAME = "attr.proxy." + ATTRIBUTE_DEPARTMENT;
4141
protected static final String USER_ATTRIBUTE_SKILLS_NAME = "attr.proxy." + ATTRIBUTE_SKILLS;
4242
protected static final String USER_ATTRIBUTE_USERNAME_NAME = "attr.proxy.username";
@@ -82,7 +82,7 @@ abstract class CommonProxyAuthenticationTests {
8282

8383
protected static final RolesMapping ROLES_MAPPING_FIRST_MATE = new RolesMapping(ROLE_ALL_INDEX_SEARCH)
8484
.backendRoles(BACKEND_ROLE_FIRST_MATE);
85-
85+
8686
protected abstract LocalCluster getCluster();
8787

8888
protected void shouldAuthenticateWithBasicAuthWhenProxyAuthenticationIsConfigured() {

src/integrationTest/java/org/opensearch/test/framework/AuditCompliance.java

Lines changed: 86 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -18,89 +18,90 @@
1818

1919
public class AuditCompliance implements ToXContentObject {
2020

21-
private boolean enabled = false;
22-
23-
private Boolean writeLogDiffs;
24-
25-
private List<String> readIgnoreUsers;
26-
27-
private List<String> writeWatchedIndices;
28-
29-
private List<String> writeIgnoreUsers;
30-
31-
private Boolean readMetadataOnly;
32-
33-
private Boolean writeMetadataOnly;
34-
35-
private Boolean externalConfig;
36-
37-
private Boolean internalConfig;
38-
39-
public AuditCompliance enabled(boolean enabled) {
40-
this.enabled = enabled;
41-
this.writeLogDiffs = false;
42-
this.readIgnoreUsers = Collections.emptyList();
43-
this.writeWatchedIndices = Collections.emptyList();
44-
this.writeIgnoreUsers = Collections.emptyList();
45-
this.readMetadataOnly = false;
46-
this.writeMetadataOnly = false;
47-
this.externalConfig = false;
48-
this.internalConfig = false;
49-
return this;
50-
}
51-
52-
public AuditCompliance writeLogDiffs(boolean writeLogDiffs) {
53-
this.writeLogDiffs = writeLogDiffs;
54-
return this;
55-
}
56-
57-
public AuditCompliance readIgnoreUsers(List<String> list) {
58-
this.readIgnoreUsers = list;
59-
return this;
60-
}
61-
62-
public AuditCompliance writeWatchedIndices(List<String> list) {
63-
this.writeWatchedIndices = list;
64-
return this;
65-
}
66-
67-
public AuditCompliance writeIgnoreUsers(List<String> list) {
68-
this.writeIgnoreUsers = list;
69-
return this;
70-
}
71-
72-
public AuditCompliance readMetadataOnly(boolean readMetadataOnly) {
73-
this.readMetadataOnly = readMetadataOnly;
74-
return this;
75-
}
76-
77-
public AuditCompliance writeMetadataOnly(boolean writeMetadataOnly) {
78-
this.writeMetadataOnly = writeMetadataOnly;
79-
return this;
80-
}
81-
82-
public AuditCompliance externalConfig(boolean externalConfig) {
83-
this.externalConfig = externalConfig;
84-
return this;
85-
}
86-
87-
public AuditCompliance internalConfig(boolean internalConfig) {
88-
this.internalConfig = internalConfig;
89-
return this;
90-
}
91-
92-
@Override public XContentBuilder toXContent(XContentBuilder xContentBuilder, Params params) throws IOException {
93-
xContentBuilder.startObject();
94-
xContentBuilder.field("enabled", enabled);
95-
xContentBuilder.field("write_log_diffs", writeLogDiffs);
96-
xContentBuilder.field("read_ignore_users", readIgnoreUsers);
97-
xContentBuilder.field("write_watched_indices", writeWatchedIndices);
98-
xContentBuilder.field("write_ignore_users", writeIgnoreUsers);
99-
xContentBuilder.field("read_metadata_only", readMetadataOnly);
100-
xContentBuilder.field("write_metadata_only", writeMetadataOnly);
101-
xContentBuilder.field("external_config", externalConfig);
102-
xContentBuilder.field("internal_config", internalConfig);
103-
xContentBuilder.endObject();
104-
return xContentBuilder;
105-
}
21+
private boolean enabled = false;
22+
23+
private Boolean writeLogDiffs;
24+
25+
private List<String> readIgnoreUsers;
26+
27+
private List<String> writeWatchedIndices;
28+
29+
private List<String> writeIgnoreUsers;
30+
31+
private Boolean readMetadataOnly;
32+
33+
private Boolean writeMetadataOnly;
34+
35+
private Boolean externalConfig;
36+
37+
private Boolean internalConfig;
38+
39+
public AuditCompliance enabled(boolean enabled) {
40+
this.enabled = enabled;
41+
this.writeLogDiffs = false;
42+
this.readIgnoreUsers = Collections.emptyList();
43+
this.writeWatchedIndices = Collections.emptyList();
44+
this.writeIgnoreUsers = Collections.emptyList();
45+
this.readMetadataOnly = false;
46+
this.writeMetadataOnly = false;
47+
this.externalConfig = false;
48+
this.internalConfig = false;
49+
return this;
50+
}
51+
52+
public AuditCompliance writeLogDiffs(boolean writeLogDiffs) {
53+
this.writeLogDiffs = writeLogDiffs;
54+
return this;
55+
}
56+
57+
public AuditCompliance readIgnoreUsers(List<String> list) {
58+
this.readIgnoreUsers = list;
59+
return this;
60+
}
61+
62+
public AuditCompliance writeWatchedIndices(List<String> list) {
63+
this.writeWatchedIndices = list;
64+
return this;
65+
}
66+
67+
public AuditCompliance writeIgnoreUsers(List<String> list) {
68+
this.writeIgnoreUsers = list;
69+
return this;
70+
}
71+
72+
public AuditCompliance readMetadataOnly(boolean readMetadataOnly) {
73+
this.readMetadataOnly = readMetadataOnly;
74+
return this;
75+
}
76+
77+
public AuditCompliance writeMetadataOnly(boolean writeMetadataOnly) {
78+
this.writeMetadataOnly = writeMetadataOnly;
79+
return this;
80+
}
81+
82+
public AuditCompliance externalConfig(boolean externalConfig) {
83+
this.externalConfig = externalConfig;
84+
return this;
85+
}
86+
87+
public AuditCompliance internalConfig(boolean internalConfig) {
88+
this.internalConfig = internalConfig;
89+
return this;
90+
}
91+
92+
@Override
93+
public XContentBuilder toXContent(XContentBuilder xContentBuilder, Params params) throws IOException {
94+
xContentBuilder.startObject();
95+
xContentBuilder.field("enabled", enabled);
96+
xContentBuilder.field("write_log_diffs", writeLogDiffs);
97+
xContentBuilder.field("read_ignore_users", readIgnoreUsers);
98+
xContentBuilder.field("write_watched_indices", writeWatchedIndices);
99+
xContentBuilder.field("write_ignore_users", writeIgnoreUsers);
100+
xContentBuilder.field("read_metadata_only", readMetadataOnly);
101+
xContentBuilder.field("write_metadata_only", writeMetadataOnly);
102+
xContentBuilder.field("external_config", externalConfig);
103+
xContentBuilder.field("internal_config", internalConfig);
104+
xContentBuilder.endObject();
105+
return xContentBuilder;
106+
}
106107
}

src/integrationTest/java/org/opensearch/test/framework/AuditConfiguration.java

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,41 +15,42 @@
1515
import org.opensearch.core.xcontent.XContentBuilder;
1616

1717
public class AuditConfiguration implements ToXContentObject {
18-
private final boolean enabled;
18+
private final boolean enabled;
1919

20-
private AuditFilters filters;
20+
private AuditFilters filters;
2121

22-
private AuditCompliance compliance;
22+
private AuditCompliance compliance;
2323

24-
public AuditConfiguration(boolean enabled) {
25-
this.filters = new AuditFilters();
26-
this.compliance = new AuditCompliance();
27-
this.enabled = enabled;
28-
}
24+
public AuditConfiguration(boolean enabled) {
25+
this.filters = new AuditFilters();
26+
this.compliance = new AuditCompliance();
27+
this.enabled = enabled;
28+
}
2929

30-
public boolean isEnabled() {
31-
return enabled;
32-
}
30+
public boolean isEnabled() {
31+
return enabled;
32+
}
3333

34-
public AuditConfiguration filters(AuditFilters filters) {
35-
this.filters = filters;
36-
return this;
37-
}
34+
public AuditConfiguration filters(AuditFilters filters) {
35+
this.filters = filters;
36+
return this;
37+
}
3838

39-
public AuditConfiguration compliance(AuditCompliance auditCompliance) {
40-
this.compliance = auditCompliance;
41-
return this;
42-
}
39+
public AuditConfiguration compliance(AuditCompliance auditCompliance) {
40+
this.compliance = auditCompliance;
41+
return this;
42+
}
4343

44-
@Override public XContentBuilder toXContent(XContentBuilder xContentBuilder, Params params) throws IOException {
45-
// json built here must be deserialized to org.opensearch.security.auditlog.config.AuditConfig
46-
xContentBuilder.startObject();
47-
xContentBuilder.field("enabled", enabled);
44+
@Override
45+
public XContentBuilder toXContent(XContentBuilder xContentBuilder, Params params) throws IOException {
46+
// json built here must be deserialized to org.opensearch.security.auditlog.config.AuditConfig
47+
xContentBuilder.startObject();
48+
xContentBuilder.field("enabled", enabled);
4849

49-
xContentBuilder.field("audit", filters);
50-
xContentBuilder.field("compliance", compliance);
50+
xContentBuilder.field("audit", filters);
51+
xContentBuilder.field("compliance", compliance);
5152

52-
xContentBuilder.endObject();
53-
return xContentBuilder;
54-
}
53+
xContentBuilder.endObject();
54+
return xContentBuilder;
55+
}
5556
}

0 commit comments

Comments
 (0)