PakhomovAlexander commented on code in PR #2339:
URL: https://github.com/apache/ignite-3/pull/2339#discussion_r1272390853
##########
modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/connect/ItConnectWithBasicAuthenticationCommandTest.java:
##########
@@ -99,4 +103,155 @@ void failToConnectWithWrongCredentials() {
// And prompt is still disconnected
assertThat(getPrompt()).isEqualTo("[disconnected]> ");
}
+
+ @Test
+ @DisplayName("Should connect to cluster with username/password")
+ void connectWithAuthenticationParameters() {
+ // Given basic authentication is NOT configured in config file
+ configManagerProvider.setConfigFile(createIntegrationTestsConfig());
+
+ // Given prompt before connect
+ assertThat(getPrompt()).isEqualTo("[disconnected]> ");
+
+ // When connect with auth parameters
+ //execute("connect", nodeName(), "--username", "admin1", "--password",
"password1");
+
+ execute("connect", "--username", "admin", "--password", "password");
+
+ // Then
+ assertAll(
+ this::assertErrOutputIsEmpty,
+ () -> assertOutputContains("Connected to
http://localhost:10300")
+ );
+
+ // And prompt shows user name and node name
+ assertThat(getPrompt()).isEqualTo("[admin:" + nodeName() + "]> ");
+ }
+
+ @Test
+ @DisplayName("Should NOT connect to cluster with incorrect password")
+ void connectWithWrongAuthenticationParameters() {
+ // Given basic authentication is NOT configured in config file
+ configManagerProvider.setConfigFile(createIntegrationTestsConfig());
+
+ // Given prompt before connect
+ assertThat(getPrompt()).isEqualTo("[disconnected]> ");
+
+ // When connect with auth parameters
+ execute("connect", "--username", "admin", "--password",
"wrong-password");
+
+ // Then
+ assertAll(
+ this::assertOutputIsEmpty,
+ () -> assertErrOutputIs("Authentication error" +
System.lineSeparator()
+ + "Could not connect to node with URL
http://localhost:10300. Check authentication configuration"
+ + System.lineSeparator())
+ );
+ // And prompt is still disconnected
+ assertThat(getPrompt()).isEqualTo("[disconnected]> ");
+ }
+
+ @Test
+ void connectFailIfPasswordNotDefined() {
+ // Given basic authentication is NOT configured in config file
+ configManagerProvider.setConfigFile(createIntegrationTestsConfig());
+
+ // Given prompt before connect
+ assertThat(getPrompt()).isEqualTo("[disconnected]> ");
+
+ // When connect with auth parameters
+ //execute("connect", nodeName(), "--username", "admin1", "--password",
"password1");
Review Comment:
Instead of a direct message to the obvious review requests we just hit
"Resolve conversation" button if we are agreed with the comments.
--
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]