|
@@ -105,14 +105,14 @@ SCENARIO("Check help auth uninitialized") {
|
|
|
|
|
|
THEN("The help command prints all commands.") {
|
|
THEN("The help command prints all commands.") {
|
|
|
|
|
|
- char *dummyData = (char*) "help\r\n"
|
|
|
|
- "help ? help [command] - print help or usage information\r\n"
|
|
|
|
- "login li Login command\r\n"
|
|
|
|
- "logout lo Logout command\r\n"
|
|
|
|
- "private r\r\n"
|
|
|
|
- "public p\r\n"
|
|
|
|
- "\r\n"
|
|
|
|
- "shellmatta->";
|
|
|
|
|
|
+ char *dummyData = (char*) "help\r\n"
|
|
|
|
+ "help ? help [command] - print help or usage information\r\n"
|
|
|
|
+ "login li Login command\r\n"
|
|
|
|
+ "logout lo Logout command\r\n"
|
|
|
|
+ "private r\r\n"
|
|
|
|
+ "public p\r\n"
|
|
|
|
+ "\r\n"
|
|
|
|
+ "shellmatta->";
|
|
|
|
|
|
CHECK(ret == SHELLMATTA_OK);
|
|
CHECK(ret == SHELLMATTA_OK);
|
|
CHECK(write_length == strlen(dummyData));
|
|
CHECK(write_length == strlen(dummyData));
|
|
@@ -166,7 +166,7 @@ SCENARIO("Check help authorized") {
|
|
|
|
|
|
AND_WHEN("The help command is called") {
|
|
AND_WHEN("The help command is called") {
|
|
|
|
|
|
- ret = shellmatta_processData(handle, (char*)"help\r", 5);
|
|
|
|
|
|
+ ret = shellmatta_processData(handle, (char*)"help\r", 5);
|
|
CHECK(ret == SHELLMATTA_OK);
|
|
CHECK(ret == SHELLMATTA_OK);
|
|
|
|
|
|
THEN("The help command prints all commands.") {
|
|
THEN("The help command prints all commands.") {
|
|
@@ -180,10 +180,10 @@ SCENARIO("Check help authorized") {
|
|
"\r\n"
|
|
"\r\n"
|
|
"shimatta@shellmatta->";
|
|
"shimatta@shellmatta->";
|
|
|
|
|
|
- CHECK(ret == SHELLMATTA_OK);
|
|
|
|
- CHECK(write_length == strlen(dummyData));
|
|
|
|
- REQUIRE_THAT(write_data, Catch::Matchers::Equals(dummyData));
|
|
|
|
-}
|
|
|
|
|
|
+ CHECK(ret == SHELLMATTA_OK);
|
|
|
|
+ CHECK(write_length == strlen(dummyData));
|
|
|
|
+ REQUIRE_THAT(write_data, Catch::Matchers::Equals(dummyData));
|
|
|
|
+ }
|
|
|
|
|
|
AND_WHEN("The user is logged out using the logout command") {
|
|
AND_WHEN("The user is logged out using the logout command") {
|
|
write_length = 0;
|
|
write_length = 0;
|
|
@@ -227,3 +227,81 @@ SCENARIO("Check help authorized") {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+SCENARIO("Check login command") {
|
|
|
|
+ GIVEN("An initialized shellmatta instance with initialized auth") {
|
|
|
|
+
|
|
|
|
+ TEST_SHELLMATTA_SETUP;
|
|
|
|
+
|
|
|
|
+ TEST_SHELLMATTA_AUTH_SETUP;
|
|
|
|
+
|
|
|
|
+ WHEN("The user shellmatta logges in interactively using the correct credentials") {
|
|
|
|
+
|
|
|
|
+ ret = shellmatta_processData(handle, (char*)"login\r" \
|
|
|
|
+ "shimatta\r"\
|
|
|
|
+ "12345678\r", 24);
|
|
|
|
+ CHECK(ret == SHELLMATTA_OK);
|
|
|
|
+
|
|
|
|
+ THEN("The login message is printed - password is hidden") {
|
|
|
|
+ char *dummyData = (char*) "login\r\n" \
|
|
|
|
+ "enter username:\r\n" \
|
|
|
|
+ "shimatta\r\n" \
|
|
|
|
+ "enter password:\r\n" \
|
|
|
|
+ "\r\n" \
|
|
|
|
+ "login successful\r\n" \
|
|
|
|
+ "\r\n" \
|
|
|
|
+ "shimatta@shellmatta->";
|
|
|
|
+ CHECK(write_length == strlen(dummyData));
|
|
|
|
+ REQUIRE_THAT(write_data, Catch::Matchers::Equals(dummyData));
|
|
|
|
+
|
|
|
|
+ AND_THEN("The shimatta user is logged in") {
|
|
|
|
+ REQUIRE(1 == shellmatta_auth_getLoggedInUserId(handle));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ WHEN("The user shellmatta logges in interactively manipulating the input") {
|
|
|
|
+
|
|
|
|
+ ret = shellmatta_processData(handle, (char*)"login\r" \
|
|
|
|
+ "shimg\batta\r" \
|
|
|
|
+ "12346\033[D5\033[C78\r", 32);
|
|
|
|
+ CHECK(ret == SHELLMATTA_OK);
|
|
|
|
+
|
|
|
|
+ THEN("The login message is printed - password is hidden") {
|
|
|
|
+ char *dummyData = (char*) "login\r\n" \
|
|
|
|
+ "enter username:\r\n" \
|
|
|
|
+ "shimg\033[1D\033[K\033[s\033[uatta\r\n" \
|
|
|
|
+ "enter password:\r\n" \
|
|
|
|
+ "\r\n" \
|
|
|
|
+ "login successful\r\n" \
|
|
|
|
+ "\r\n" \
|
|
|
|
+ "shimatta@shellmatta->";
|
|
|
|
+ CHECK(write_length == strlen(dummyData));
|
|
|
|
+ REQUIRE_THAT(write_data, Catch::Matchers::Equals(dummyData));
|
|
|
|
+
|
|
|
|
+ AND_THEN("The shimatta user is logged in") {
|
|
|
|
+ REQUIRE(1 == shellmatta_auth_getLoggedInUserId(handle));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ WHEN("The user shellmatta logges in passing the credentials none interactive") {
|
|
|
|
+
|
|
|
|
+ ret = shellmatta_processData(handle, (char*)"login -u shimatta -p 12345678\r", 30);
|
|
|
|
+ CHECK(ret == SHELLMATTA_OK);
|
|
|
|
+
|
|
|
|
+ THEN("The login message is printed - password is hidden") {
|
|
|
|
+ char *dummyData = (char*) "login -u shimatta -p 12345678\r\n" \
|
|
|
|
+ "login successful\r\n" \
|
|
|
|
+ "\r\n" \
|
|
|
|
+ "shimatta@shellmatta->";
|
|
|
|
+ CHECK(write_length == strlen(dummyData));
|
|
|
|
+ REQUIRE_THAT(write_data, Catch::Matchers::Equals(dummyData));
|
|
|
|
+
|
|
|
|
+ AND_THEN("The shimatta user is logged in") {
|
|
|
|
+ REQUIRE(1 == shellmatta_auth_getLoggedInUserId(handle));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|