From 15b4d6a5b1ab25018d7bdcf4dc1be6fa9eb5e7bf Mon Sep 17 00:00:00 2001 From: Darshit Chanpura Date: Thu, 28 Sep 2023 14:49:28 -0400 Subject: [PATCH] Fixes spotless errors Signed-off-by: Darshit Chanpura --- .../identity/shiro/ShiroTokenManager.java | 10 +- .../identity/shiro/AuthTokenHandlerTests.java | 1 - .../InitializeExtensionSecurityRequest.java | 76 +++++++-------- .../InitializeExtensionSecurityResponse.java | 64 ++++++------- .../extensions/ExtensionsManager.java | 74 +++++++------- .../extensions/NoopExtensionsManager.java | 2 +- .../action/IssueServiceAccountRequest.java | 78 +++++++-------- .../action/IssueServiceAccountResponse.java | 96 +++++++++---------- .../extensions/rest/ExtensionRestRequest.java | 1 + .../rest/RestActionsRequestHandler.java | 3 +- .../rest/RestInitializeExtensionAction.java | 15 +-- .../identity/noop/NoopTokenManager.java | 2 - .../identity/tokens/TokenManager.java | 1 - .../extensions/ExtensionsManagerTests.java | 26 ++--- .../rest/ExtensionRestRequestTests.java | 5 +- .../RestInitializeExtensionActionTests.java | 10 +- .../rest/RestSendToExtensionActionTests.java | 12 --- 17 files changed, 232 insertions(+), 244 deletions(-) diff --git a/plugins/identity-shiro/src/main/java/org/opensearch/identity/shiro/ShiroTokenManager.java b/plugins/identity-shiro/src/main/java/org/opensearch/identity/shiro/ShiroTokenManager.java index 0c8deddb5351d..73cf9506aef2c 100644 --- a/plugins/identity-shiro/src/main/java/org/opensearch/identity/shiro/ShiroTokenManager.java +++ b/plugins/identity-shiro/src/main/java/org/opensearch/identity/shiro/ShiroTokenManager.java @@ -98,7 +98,7 @@ public boolean validateToken(AuthToken token) { if (token instanceof BasicAuthToken) { final BasicAuthToken basicAuthToken = (BasicAuthToken) token; return basicAuthToken.getUser().equals(SecurityUtils.getSubject().toString()) - && basicAuthToken.getPassword().equals(shiroTokenPasswordMap.get(basicAuthToken)); + && basicAuthToken.getPassword().equals(shiroTokenPasswordMap.get(basicAuthToken)); } return false; } @@ -140,10 +140,10 @@ public String generatePassword() { CharacterRule specialCharacterRule = new CharacterRule(EnglishCharacterData.Special, 1); List rules = Arrays.asList( - lowercaseCharacterRule, - uppercaseCharacterRule, - numericCharacterRule, - specialCharacterRule + lowercaseCharacterRule, + uppercaseCharacterRule, + numericCharacterRule, + specialCharacterRule ); PasswordGenerator passwordGenerator = new PasswordGenerator(); diff --git a/plugins/identity-shiro/src/test/java/org/opensearch/identity/shiro/AuthTokenHandlerTests.java b/plugins/identity-shiro/src/test/java/org/opensearch/identity/shiro/AuthTokenHandlerTests.java index 5898ea3dad855..7c7414843d86f 100644 --- a/plugins/identity-shiro/src/test/java/org/opensearch/identity/shiro/AuthTokenHandlerTests.java +++ b/plugins/identity-shiro/src/test/java/org/opensearch/identity/shiro/AuthTokenHandlerTests.java @@ -10,7 +10,6 @@ import org.apache.shiro.authc.AuthenticationToken; import org.apache.shiro.authc.UsernamePasswordToken; -import org.junit.Before; import org.opensearch.identity.Subject; import org.opensearch.identity.noop.NoopSubject; import org.opensearch.identity.noop.NoopTokenManager; diff --git a/server/src/main/java/org/opensearch/discovery/InitializeExtensionSecurityRequest.java b/server/src/main/java/org/opensearch/discovery/InitializeExtensionSecurityRequest.java index c18d8144098f1..530d69e418b25 100644 --- a/server/src/main/java/org/opensearch/discovery/InitializeExtensionSecurityRequest.java +++ b/server/src/main/java/org/opensearch/discovery/InitializeExtensionSecurityRequest.java @@ -22,42 +22,42 @@ */ public class InitializeExtensionSecurityRequest extends TransportRequest { - private final String serviceAccountToken; - - public InitializeExtensionSecurityRequest(String serviceAccountToken) { - this.serviceAccountToken = serviceAccountToken; - } - - public InitializeExtensionSecurityRequest(StreamInput in) throws IOException { - super(in); - serviceAccountToken = in.readString(); - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - super.writeTo(out); - out.writeString(serviceAccountToken); - } - - public String getServiceAccountToken() { - return serviceAccountToken; - } - - @Override - public String toString() { - return "InitializeExtensionsRequest{" + "serviceAccountToken= " + serviceAccountToken + "}"; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - InitializeExtensionSecurityRequest that = (InitializeExtensionSecurityRequest) o; - return Objects.equals(serviceAccountToken, that.serviceAccountToken); - } - - @Override - public int hashCode() { - return Objects.hash(serviceAccountToken); - } + private final String serviceAccountToken; + + public InitializeExtensionSecurityRequest(String serviceAccountToken) { + this.serviceAccountToken = serviceAccountToken; + } + + public InitializeExtensionSecurityRequest(StreamInput in) throws IOException { + super(in); + serviceAccountToken = in.readString(); + } + + @Override + public void writeTo(StreamOutput out) throws IOException { + super.writeTo(out); + out.writeString(serviceAccountToken); + } + + public String getServiceAccountToken() { + return serviceAccountToken; + } + + @Override + public String toString() { + return "InitializeExtensionsRequest{" + "serviceAccountToken= " + serviceAccountToken + "}"; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + InitializeExtensionSecurityRequest that = (InitializeExtensionSecurityRequest) o; + return Objects.equals(serviceAccountToken, that.serviceAccountToken); + } + + @Override + public int hashCode() { + return Objects.hash(serviceAccountToken); + } } diff --git a/server/src/main/java/org/opensearch/discovery/InitializeExtensionSecurityResponse.java b/server/src/main/java/org/opensearch/discovery/InitializeExtensionSecurityResponse.java index bcad61f3d59ba..31d1675ead2ec 100644 --- a/server/src/main/java/org/opensearch/discovery/InitializeExtensionSecurityResponse.java +++ b/server/src/main/java/org/opensearch/discovery/InitializeExtensionSecurityResponse.java @@ -45,44 +45,44 @@ * @opensearch.internal */ public class InitializeExtensionSecurityResponse extends TransportResponse { - private String name; + private String name; - public InitializeExtensionSecurityResponse(String name) { - this.name = name; - } + public InitializeExtensionSecurityResponse(String name) { + this.name = name; + } - public InitializeExtensionSecurityResponse(StreamInput in) throws IOException { - name = in.readString(); - } + public InitializeExtensionSecurityResponse(StreamInput in) throws IOException { + name = in.readString(); + } - @Override - public void writeTo(StreamOutput out) throws IOException { - out.writeString(name); - } + @Override + public void writeTo(StreamOutput out) throws IOException { + out.writeString(name); + } - /** - * @return the node that is currently leading, according to the responding node. - */ + /** + * @return the node that is currently leading, according to the responding node. + */ - public String getName() { - return this.name; - } + public String getName() { + return this.name; + } - @Override - public String toString() { - return "InitializeExtensionResponse{" + "name = " + name + "}"; - } + @Override + public String toString() { + return "InitializeExtensionResponse{" + "name = " + name + "}"; + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - InitializeExtensionSecurityResponse that = (InitializeExtensionSecurityResponse) o; - return Objects.equals(name, that.name); - } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + InitializeExtensionSecurityResponse that = (InitializeExtensionSecurityResponse) o; + return Objects.equals(name, that.name); + } - @Override - public int hashCode() { - return Objects.hash(name); - } + @Override + public int hashCode() { + return Objects.hash(name); + } } diff --git a/server/src/main/java/org/opensearch/extensions/ExtensionsManager.java b/server/src/main/java/org/opensearch/extensions/ExtensionsManager.java index 64bdb9bd036b7..c841e36348711 100644 --- a/server/src/main/java/org/opensearch/extensions/ExtensionsManager.java +++ b/server/src/main/java/org/opensearch/extensions/ExtensionsManager.java @@ -8,9 +8,6 @@ package org.opensearch.extensions; -import java.util.concurrent.CompletionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; @@ -38,6 +35,8 @@ import org.opensearch.extensions.action.ExtensionActionRequest; import org.opensearch.extensions.action.ExtensionActionResponse; import org.opensearch.extensions.action.ExtensionTransportActionsHandler; +import org.opensearch.extensions.action.IssueServiceAccountRequest; +import org.opensearch.extensions.action.IssueServiceAccountResponse; import org.opensearch.extensions.action.RegisterTransportActionsRequest; import org.opensearch.extensions.action.RemoteExtensionActionResponse; import org.opensearch.extensions.action.TransportActionRequestFromExtension; @@ -52,8 +51,6 @@ import org.opensearch.transport.TransportException; import org.opensearch.transport.TransportResponseHandler; import org.opensearch.transport.TransportService; -import org.opensearch.extensions.action.IssueServiceAccountRequest; -import org.opensearch.extensions.action.IssueServiceAccountResponse; import java.io.IOException; import java.net.InetAddress; @@ -63,6 +60,9 @@ import java.util.Optional; import java.util.Set; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import java.util.stream.Collectors; /** @@ -99,7 +99,6 @@ public static enum OpenSearchRequestType { REQUEST_OPENSEARCH_NAMED_WRITEABLE_REGISTRY } - private ExtensionTransportActionsHandler extensionTransportActionsHandler; private Map extensionSettingsMap; private Map initializedExtensions; @@ -423,38 +422,38 @@ protected void doRun() throws Exception { private void initializeExtensionSecurity(DiscoveryExtensionNode extension) { final CompletableFuture inProgressFuture = new CompletableFuture<>(); final TransportResponseHandler initializeExtensionSecurityResponseHandler = - new TransportResponseHandler() { + new TransportResponseHandler() { - @Override - public InitializeExtensionSecurityResponse read(StreamInput in) throws IOException { - return new InitializeExtensionSecurityResponse(in); - } + @Override + public InitializeExtensionSecurityResponse read(StreamInput in) throws IOException { + return new InitializeExtensionSecurityResponse(in); + } - @Override - public void handleResponse(InitializeExtensionSecurityResponse response) { - System.out.println("Registered security settings for " + response.getName()); - inProgressFuture.complete(response); - } + @Override + public void handleResponse(InitializeExtensionSecurityResponse response) { + System.out.println("Registered security settings for " + response.getName()); + inProgressFuture.complete(response); + } - @Override - public void handleException(TransportException exp) { - logger.error(new ParameterizedMessage("Extension initialization failed"), exp); - inProgressFuture.completeExceptionally(exp); - } + @Override + public void handleException(TransportException exp) { + logger.error(new ParameterizedMessage("Extension initialization failed"), exp); + inProgressFuture.completeExceptionally(exp); + } - @Override - public String executor() { - return ThreadPool.Names.GENERIC; - } - }; + @Override + public String executor() { + return ThreadPool.Names.GENERIC; + } + }; try { logger.info("Sending extension request type: " + REQUEST_EXTENSION_REGISTER_SECURITY_SETTINGS); AuthToken serviceAccountToken = identityService.getTokenManager().issueServiceAccountToken(extension.getId()); transportService.sendRequest( - extension, - REQUEST_EXTENSION_REGISTER_SECURITY_SETTINGS, - new InitializeExtensionSecurityRequest(serviceAccountToken.asAuthHeaderValue()), - initializeExtensionSecurityResponseHandler + extension, + REQUEST_EXTENSION_REGISTER_SECURITY_SETTINGS, + new InitializeExtensionSecurityRequest(serviceAccountToken.asAuthHeaderValue()), + initializeExtensionSecurityResponseHandler ); inProgressFuture.orTimeout(EXTENSION_REQUEST_WAIT_TIMEOUT, TimeUnit.SECONDS).join(); @@ -517,7 +516,7 @@ public void issueServiceAccount(Extension extension) { String authTokenAsString = serviceAccountToken.asAuthHeaderValue(); final CompletableFuture inProgressFuture = new CompletableFuture<>(); final TransportResponseHandler issueServiceAccountResponseHandler = new TransportResponseHandler< - IssueServiceAccountResponse>() { + IssueServiceAccountResponse>() { @Override public IssueServiceAccountResponse read(StreamInput in) throws IOException { @@ -528,7 +527,7 @@ public IssueServiceAccountResponse read(StreamInput in) throws IOException { public void handleResponse(IssueServiceAccountResponse response) { for (DiscoveryExtensionNode extension : extensionIdMap.values()) { if (extension.getName().equals(response.getName()) - && (serviceAccountToken.equals(response.getServiceAccountString()))) { + && (serviceAccountToken.equals(response.getServiceAccountString()))) { logger.info("Successfully issued service account token to extension: " + extension.getName()); break; } @@ -549,15 +548,13 @@ public String executor() { }; transportService.sendRequest( - discoveryExtensionNode, - REQUEST_EXTENSION_ISSUE_SERVICE_ACCOUNT, - new IssueServiceAccountRequest(authTokenAsString), - issueServiceAccountResponseHandler + discoveryExtensionNode, + REQUEST_EXTENSION_ISSUE_SERVICE_ACCOUNT, + new IssueServiceAccountRequest(authTokenAsString), + issueServiceAccountResponseHandler ); } - - static String getRequestExtensionActionName() { return REQUEST_EXTENSION_ACTION_NAME; } @@ -614,7 +611,6 @@ void setCustomSettingsRequestHandler(CustomSettingsRequestHandler customSettings this.customSettingsRequestHandler = customSettingsRequestHandler; } - public void setIdentityService(IdentityService identityService) { this.identityService = identityService; } diff --git a/server/src/main/java/org/opensearch/extensions/NoopExtensionsManager.java b/server/src/main/java/org/opensearch/extensions/NoopExtensionsManager.java index 16114622d3b1a..81b1b91b11481 100644 --- a/server/src/main/java/org/opensearch/extensions/NoopExtensionsManager.java +++ b/server/src/main/java/org/opensearch/extensions/NoopExtensionsManager.java @@ -8,7 +8,6 @@ package org.opensearch.extensions; -import java.util.List; import org.opensearch.action.ActionModule; import org.opensearch.client.node.NodeClient; import org.opensearch.cluster.service.ClusterService; @@ -21,6 +20,7 @@ import org.opensearch.transport.TransportService; import java.io.IOException; +import java.util.List; import java.util.Optional; import java.util.Set; diff --git a/server/src/main/java/org/opensearch/extensions/action/IssueServiceAccountRequest.java b/server/src/main/java/org/opensearch/extensions/action/IssueServiceAccountRequest.java index fc6bbbc2151f7..7d152a33e800a 100644 --- a/server/src/main/java/org/opensearch/extensions/action/IssueServiceAccountRequest.java +++ b/server/src/main/java/org/opensearch/extensions/action/IssueServiceAccountRequest.java @@ -20,50 +20,50 @@ */ public class IssueServiceAccountRequest extends TransportRequest { - private final String serviceAccountToken; + private final String serviceAccountToken; - /** - * This takes a string representing a service account token - * @param serviceAccountToken The string making up the service account token - */ - public IssueServiceAccountRequest(String serviceAccountToken) { - this.serviceAccountToken = serviceAccountToken; - } + /** + * This takes a string representing a service account token + * @param serviceAccountToken The string making up the service account token + */ + public IssueServiceAccountRequest(String serviceAccountToken) { + this.serviceAccountToken = serviceAccountToken; + } - /** - * This takes a stream representing a service account token - * @param in The stream passing the token - */ - public IssueServiceAccountRequest(StreamInput in) throws IOException { - super(in); - this.serviceAccountToken = in.readString(); - } + /** + * This takes a stream representing a service account token + * @param in The stream passing the token + */ + public IssueServiceAccountRequest(StreamInput in) throws IOException { + super(in); + this.serviceAccountToken = in.readString(); + } - @Override - public void writeTo(StreamOutput out) throws IOException { - super.writeTo(out); - out.writeString(serviceAccountToken); - } + @Override + public void writeTo(StreamOutput out) throws IOException { + super.writeTo(out); + out.writeString(serviceAccountToken); + } - public String getServiceAccountToken() { - return this.serviceAccountToken; - } + public String getServiceAccountToken() { + return this.serviceAccountToken; + } - @Override - public String toString() { - return "IssueServiceAccountRequest {" + "serviceAccountToken=" + serviceAccountToken + "}"; - } + @Override + public String toString() { + return "IssueServiceAccountRequest {" + "serviceAccountToken=" + serviceAccountToken + "}"; + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - IssueServiceAccountRequest that = (IssueServiceAccountRequest) o; - return Objects.equals(serviceAccountToken, that.serviceAccountToken); - } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + IssueServiceAccountRequest that = (IssueServiceAccountRequest) o; + return Objects.equals(serviceAccountToken, that.serviceAccountToken); + } - @Override - public int hashCode() { - return Objects.hash(serviceAccountToken); - } + @Override + public int hashCode() { + return Objects.hash(serviceAccountToken); + } } diff --git a/server/src/main/java/org/opensearch/extensions/action/IssueServiceAccountResponse.java b/server/src/main/java/org/opensearch/extensions/action/IssueServiceAccountResponse.java index ed481092b717b..78e41f1806e9e 100644 --- a/server/src/main/java/org/opensearch/extensions/action/IssueServiceAccountResponse.java +++ b/server/src/main/java/org/opensearch/extensions/action/IssueServiceAccountResponse.java @@ -20,62 +20,62 @@ */ public class IssueServiceAccountResponse extends TransportResponse { - private String name; - private String serviceAccountToken; + private String name; + private String serviceAccountToken; - /** - * This takes in a name for the extension and the service account token string - * @param name The name of the extension - * @param serviceAccountToken A string encapsulating the service account token - */ - public IssueServiceAccountResponse(String name, String serviceAccountToken) { - this.name = name; - this.serviceAccountToken = serviceAccountToken; - } + /** + * This takes in a name for the extension and the service account token string + * @param name The name of the extension + * @param serviceAccountToken A string encapsulating the service account token + */ + public IssueServiceAccountResponse(String name, String serviceAccountToken) { + this.name = name; + this.serviceAccountToken = serviceAccountToken; + } - /** - * This takes in a stream containing for the extension and the service account token - * @param in the stream containing the extension name and the service account token - */ - public IssueServiceAccountResponse(StreamInput in) throws IOException { - this.name = in.readString(); - this.serviceAccountToken = in.readString(); - } + /** + * This takes in a stream containing for the extension and the service account token + * @param in the stream containing the extension name and the service account token + */ + public IssueServiceAccountResponse(StreamInput in) throws IOException { + this.name = in.readString(); + this.serviceAccountToken = in.readString(); + } - @Override - public void writeTo(StreamOutput out) throws IOException { - out.writeString(name); - out.writeString(serviceAccountToken); - } + @Override + public void writeTo(StreamOutput out) throws IOException { + out.writeString(name); + out.writeString(serviceAccountToken); + } - /** - * @return the node that is currently leading, according to the responding node. - */ + /** + * @return the node that is currently leading, according to the responding node. + */ - public String getName() { - return this.name; - } + public String getName() { + return this.name; + } - public String getServiceAccountString() { - return this.serviceAccountToken; - } + public String getServiceAccountString() { + return this.serviceAccountToken; + } - @Override - public String toString() { - return "IssueServiceAccountResponse{" + "name = " + name + " , " + "received service account = " + serviceAccountToken + "}"; - } + @Override + public String toString() { + return "IssueServiceAccountResponse{" + "name = " + name + " , " + "received service account = " + serviceAccountToken + "}"; + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - IssueServiceAccountResponse that = (IssueServiceAccountResponse) o; - return Objects.equals(name, that.name) && Objects.equals(serviceAccountToken, that.serviceAccountToken); - } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + IssueServiceAccountResponse that = (IssueServiceAccountResponse) o; + return Objects.equals(name, that.name) && Objects.equals(serviceAccountToken, that.serviceAccountToken); + } - @Override - public int hashCode() { - return Objects.hash(name, serviceAccountToken); - } + @Override + public int hashCode() { + return Objects.hash(name, serviceAccountToken); + } } diff --git a/server/src/main/java/org/opensearch/extensions/rest/ExtensionRestRequest.java b/server/src/main/java/org/opensearch/extensions/rest/ExtensionRestRequest.java index 968aadcfbb7b9..89df1e4fbde35 100644 --- a/server/src/main/java/org/opensearch/extensions/rest/ExtensionRestRequest.java +++ b/server/src/main/java/org/opensearch/extensions/rest/ExtensionRestRequest.java @@ -30,6 +30,7 @@ import java.util.Map; import java.util.Objects; import java.util.Set; + import static java.util.Objects.requireNonNull; /** diff --git a/server/src/main/java/org/opensearch/extensions/rest/RestActionsRequestHandler.java b/server/src/main/java/org/opensearch/extensions/rest/RestActionsRequestHandler.java index 8385cdf7b2a34..97851cbd394a0 100644 --- a/server/src/main/java/org/opensearch/extensions/rest/RestActionsRequestHandler.java +++ b/server/src/main/java/org/opensearch/extensions/rest/RestActionsRequestHandler.java @@ -8,7 +8,6 @@ package org.opensearch.extensions.rest; -import java.util.Map; import org.opensearch.action.ActionModule.DynamicActionRegistry; import org.opensearch.core.transport.TransportResponse; import org.opensearch.extensions.AcknowledgedResponse; @@ -18,6 +17,8 @@ import org.opensearch.rest.RestHandler; import org.opensearch.transport.TransportService; +import java.util.Map; + /** * Handles requests to register extension REST actions. * diff --git a/server/src/main/java/org/opensearch/extensions/rest/RestInitializeExtensionAction.java b/server/src/main/java/org/opensearch/extensions/rest/RestInitializeExtensionAction.java index d1893fc94e273..86c306e2637fa 100644 --- a/server/src/main/java/org/opensearch/extensions/rest/RestInitializeExtensionAction.java +++ b/server/src/main/java/org/opensearch/extensions/rest/RestInitializeExtensionAction.java @@ -173,13 +173,14 @@ public RestChannelConsumer prepareRequest(RestRequest request, NodeClient client Map additionalSettingsMap = extensionMap.entrySet() .stream() - .filter(kv -> additionalSettingsKeys.stream().anyMatch(k -> { - if (k.endsWith(".")) { - return kv.getKey().startsWith(k); - } else { - return kv.getKey().equals(k); - } - })).collect(Collectors.toMap(map -> map.getKey(), map -> map.getValue())); + .filter(kv -> additionalSettingsKeys.stream().anyMatch(k -> { + if (k.endsWith(".")) { + return kv.getKey().startsWith(k); + } else { + return kv.getKey().equals(k); + } + })) + .collect(Collectors.toMap(map -> map.getKey(), map -> map.getValue())); Settings.Builder output = Settings.builder(); Map unflattenedMap = unflattenMap(additionalSettingsMap); diff --git a/server/src/main/java/org/opensearch/identity/noop/NoopTokenManager.java b/server/src/main/java/org/opensearch/identity/noop/NoopTokenManager.java index 4a304e4e3d4b6..1dc3a58916b5c 100644 --- a/server/src/main/java/org/opensearch/identity/noop/NoopTokenManager.java +++ b/server/src/main/java/org/opensearch/identity/noop/NoopTokenManager.java @@ -51,8 +51,6 @@ public String asAuthHeaderValue() { }; } - - @Override public Subject authenticateToken(AuthToken authToken) { return null; diff --git a/server/src/main/java/org/opensearch/identity/tokens/TokenManager.java b/server/src/main/java/org/opensearch/identity/tokens/TokenManager.java index 2d9da5ebad865..cc4ce012fbba2 100644 --- a/server/src/main/java/org/opensearch/identity/tokens/TokenManager.java +++ b/server/src/main/java/org/opensearch/identity/tokens/TokenManager.java @@ -38,5 +38,4 @@ public interface TokenManager { */ public Subject authenticateToken(AuthToken authToken); - } diff --git a/server/src/test/java/org/opensearch/extensions/ExtensionsManagerTests.java b/server/src/test/java/org/opensearch/extensions/ExtensionsManagerTests.java index 7f7e0d007934a..7e181d7524b12 100644 --- a/server/src/test/java/org/opensearch/extensions/ExtensionsManagerTests.java +++ b/server/src/test/java/org/opensearch/extensions/ExtensionsManagerTests.java @@ -8,19 +8,8 @@ package org.opensearch.extensions; -import java.io.IOException; -import java.net.InetAddress; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Set; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; -import org.junit.After; -import org.junit.Before; import org.opensearch.OpenSearchException; import org.opensearch.Version; import org.opensearch.action.ActionModule; @@ -68,9 +57,23 @@ import org.opensearch.transport.TransportService; import org.opensearch.transport.nio.MockNioTransport; import org.opensearch.usage.UsageService; +import org.junit.After; +import org.junit.Before; + +import java.io.IOException; +import java.net.InetAddress; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Set; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + import static java.util.Collections.emptyList; import static java.util.Collections.emptyMap; import static java.util.Collections.emptySet; +import static org.opensearch.test.ClusterServiceUtils.createClusterService; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyString; @@ -79,7 +82,6 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import static org.opensearch.test.ClusterServiceUtils.createClusterService; public class ExtensionsManagerTests extends OpenSearchTestCase { private TransportService transportService; diff --git a/server/src/test/java/org/opensearch/extensions/rest/ExtensionRestRequestTests.java b/server/src/test/java/org/opensearch/extensions/rest/ExtensionRestRequestTests.java index b60795a73238b..8b73f2e81972f 100644 --- a/server/src/test/java/org/opensearch/extensions/rest/ExtensionRestRequestTests.java +++ b/server/src/test/java/org/opensearch/extensions/rest/ExtensionRestRequestTests.java @@ -8,11 +8,9 @@ package org.opensearch.extensions.rest; - -import org.opensearch.common.settings.Settings; -import org.opensearch.core.rest.RestStatus; import org.opensearch.OpenSearchParseException; import org.opensearch.common.io.stream.BytesStreamOutput; +import org.opensearch.common.settings.Settings; import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.io.stream.BytesStreamInput; @@ -24,7 +22,6 @@ import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.http.HttpRequest; -import org.opensearch.core.common.io.stream.NamedWriteableAwareStreamInput; import org.opensearch.identity.IdentityService; import org.opensearch.identity.Subject; import org.opensearch.identity.tokens.OnBehalfOfClaims; diff --git a/server/src/test/java/org/opensearch/extensions/rest/RestInitializeExtensionActionTests.java b/server/src/test/java/org/opensearch/extensions/rest/RestInitializeExtensionActionTests.java index 8f8bc3834183d..2271b6eeac6fa 100644 --- a/server/src/test/java/org/opensearch/extensions/rest/RestInitializeExtensionActionTests.java +++ b/server/src/test/java/org/opensearch/extensions/rest/RestInitializeExtensionActionTests.java @@ -153,7 +153,10 @@ public void testRestInitializeExtensionActionResponseWithAdditionalSettings() th Function.identity(), Setting.Property.ExtensionScope ); - ExtensionsManager extensionsManager = new ExtensionsManager(Set.of(boolSetting, stringSetting, intSetting, listSetting), new IdentityService(Settings.EMPTY, List.of())); + ExtensionsManager extensionsManager = new ExtensionsManager( + Set.of(boolSetting, stringSetting, intSetting, listSetting), + new IdentityService(Settings.EMPTY, List.of()) + ); ExtensionsManager spy = spy(extensionsManager); // optionally, you can stub out some methods: @@ -201,7 +204,10 @@ public void testRestInitializeExtensionActionResponseWithAdditionalSettingsUsing Function.identity(), Setting.Property.ExtensionScope ); - ExtensionsManager extensionsManager = new ExtensionsManager(Set.of(boolSetting, stringSetting, intSetting, listSetting), new IdentityService(Settings.EMPTY, List.of())); + ExtensionsManager extensionsManager = new ExtensionsManager( + Set.of(boolSetting, stringSetting, intSetting, listSetting), + new IdentityService(Settings.EMPTY, List.of()) + ); ExtensionsManager spy = spy(extensionsManager); // optionally, you can stub out some methods: diff --git a/server/src/test/java/org/opensearch/extensions/rest/RestSendToExtensionActionTests.java b/server/src/test/java/org/opensearch/extensions/rest/RestSendToExtensionActionTests.java index 8a831f8a0bcf8..d7a852be73650 100644 --- a/server/src/test/java/org/opensearch/extensions/rest/RestSendToExtensionActionTests.java +++ b/server/src/test/java/org/opensearch/extensions/rest/RestSendToExtensionActionTests.java @@ -8,18 +8,6 @@ package org.opensearch.extensions.rest; -import java.net.InetAddress; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; -import org.junit.After; -import org.junit.Before; import org.opensearch.Version; import org.opensearch.action.ActionModule; import org.opensearch.action.ActionModule.DynamicActionRegistry;