keith-turner commented on code in PR #3440:
URL: https://github.com/apache/accumulo/pull/3440#discussion_r1211720032
##########
shell/src/main/java/org/apache/accumulo/shell/Shell.java:
##########
@@ -189,6 +189,16 @@
*/
@AutoService(KeywordExecutable.class)
public class Shell extends ShellOptions implements KeywordExecutable {
+
+ public static interface Authenticator {
+ default boolean authenticateUser(AccumuloClient client, String principal,
+ AuthenticationToken token) throws AccumuloException,
AccumuloSecurityException {
+ return client.securityOperations().authenticateUser(principal, token);
+ }
+ }
+
+ public static Authenticator AUTHENTICATOR = new Authenticator() {};
Review Comment:
Does this exist so that a test can override a static method?
##########
test/src/main/java/org/apache/accumulo/test/shell/ShellAuthenticatorTest.java:
##########
@@ -0,0 +1,121 @@
+package org.apache.accumulo.test.shell;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.Properties;
+import java.util.TimeZone;
+
+import org.apache.accumulo.harness.SharedMiniClusterBase;
+import org.apache.accumulo.shell.Shell;
+import org.apache.accumulo.test.shell.ShellIT.StringInputStream;
+import org.apache.accumulo.test.shell.ShellIT.TestOutputStream;
+import org.jline.reader.LineReader;
+import org.jline.reader.LineReaderBuilder;
+import org.jline.terminal.Size;
+import org.jline.terminal.Terminal;
+import org.jline.terminal.impl.DumbTerminal;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+public class ShellAuthenticatorTest extends SharedMiniClusterBase {
+
+ @BeforeAll
+ public static void setup() throws Exception {
+ SharedMiniClusterBase.startMiniCluster();
+ }
+
+ @AfterAll
+ public static void teardown() {
+ SharedMiniClusterBase.stopMiniCluster();
+ }
+
+ private StringInputStream input;
+ private TestOutputStream output;
+ private Shell shell;
+ private File config;
+ public LineReader reader;
+ public Terminal terminal;
+
+ @BeforeEach
+ public void setupShell() throws IOException {
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+ output = new TestOutputStream();
+ input = new StringInputStream();
+ terminal = new DumbTerminal(input, output);
+ terminal.setSize(new Size(80, 24));
+ reader = LineReaderBuilder.builder().terminal(terminal).build();
+ if (config != null) {
+ config.delete();
+ }
+ config = Files.createTempFile(null, null).toFile();
+ try (FileWriter writer = new FileWriter(config)) {
+ Properties p = super.getClientProps();
+ p.store(writer, null);
+ }
+ config.deleteOnExit();
+ }
+
+ @AfterEach
+ public void tearDownShell() {
+ if (shell != null) {
+ shell.shutdown();
+ }
+ }
+
+ @Test
+ public void testClientPropertiesFile() throws IOException {
+ shell = new Shell(reader);
+ shell.setLogErrorsToConsole();
+ assertTrue(shell.config("--config-file", config.toString()));
+ }
+
+ @Test
+ public void testClientProperties() throws IOException {
+ shell = new Shell(reader);
+ shell.setLogErrorsToConsole();
+ assertTrue(shell.config("-u", "root", "-p", getRootPassword(), "-zi",
+ getCluster().getInstanceName(), "-zh", getCluster().getZooKeepers()));
+ }
+
+ @Test
+ public void testClientPropertiesBadPassword() throws IOException {
Review Comment:
How does it fail when run with other test? What errors to do you see?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]