|
@@ -21,6 +21,7 @@ extern "C" {
|
|
static uint32_t write_callCnt = 0u;
|
|
static uint32_t write_callCnt = 0u;
|
|
static char write_data[1024];
|
|
static char write_data[1024];
|
|
static uint32_t write_length;
|
|
static uint32_t write_length;
|
|
|
|
+static uint32_t privateTemp;
|
|
static uint32_t userIdTemp;
|
|
static uint32_t userIdTemp;
|
|
static bool successTemp;
|
|
static bool successTemp;
|
|
|
|
|
|
@@ -43,6 +44,7 @@ static bool successTemp;
|
|
write_callCnt = 0u; \
|
|
write_callCnt = 0u; \
|
|
memset(write_data, 0, sizeof(write_data)); \
|
|
memset(write_data, 0, sizeof(write_data)); \
|
|
write_length = 0u; \
|
|
write_length = 0u; \
|
|
|
|
+ privateTemp = 0u; \
|
|
userIdTemp = 255u; \
|
|
userIdTemp = 255u; \
|
|
successTemp = false; \
|
|
successTemp = false; \
|
|
\
|
|
\
|
|
@@ -95,6 +97,8 @@ static shellmatta_retCode_t privateCmdFct(shellmatta_handle_t handle, const char
|
|
(void) arguments;
|
|
(void) arguments;
|
|
(void) length;
|
|
(void) length;
|
|
|
|
|
|
|
|
+ privateTemp ++;
|
|
|
|
+
|
|
return SHELLMATTA_OK;
|
|
return SHELLMATTA_OK;
|
|
}
|
|
}
|
|
shellmatta_cmd_t privateCmd = {(char*)"private", (char*)"r", NULL, NULL, privateCmdFct, NULL, NULL};
|
|
shellmatta_cmd_t privateCmd = {(char*)"private", (char*)"r", NULL, NULL, privateCmdFct, NULL, NULL};
|
|
@@ -140,7 +144,7 @@ SCENARIO("Check help auth uninitialized") {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-SCENARIO("Check help auth unauthorized") {
|
|
|
|
|
|
+SCENARIO("Check auth unauthorized") {
|
|
GIVEN("An initialized shellmatta instance with initialized auth") {
|
|
GIVEN("An initialized shellmatta instance with initialized auth") {
|
|
|
|
|
|
TEST_SHELLMATTA_SETUP;
|
|
TEST_SHELLMATTA_SETUP;
|
|
@@ -162,7 +166,24 @@ SCENARIO("Check help auth unauthorized") {
|
|
"\r\n"
|
|
"\r\n"
|
|
"shellmatta->";
|
|
"shellmatta->";
|
|
|
|
|
|
- CHECK(ret == SHELLMATTA_OK);
|
|
|
|
|
|
+ CHECK(write_length == strlen(dummyData));
|
|
|
|
+ REQUIRE_THAT(write_data, Catch::Matchers::Equals(dummyData));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ WHEN("The a private function is called") {
|
|
|
|
+
|
|
|
|
+ ret = shellmatta_processData(handle, (char*)"private\r", 8);
|
|
|
|
+ CHECK(ret == SHELLMATTA_OK);
|
|
|
|
+
|
|
|
|
+ THEN("The command is not executed.") {
|
|
|
|
+
|
|
|
|
+ char *dummyData = (char*) "private\r\n"
|
|
|
|
+ "\r\n"
|
|
|
|
+ "Command: private not found\r\n"
|
|
|
|
+ "shellmatta->";
|
|
|
|
+
|
|
|
|
+ CHECK(privateTemp == 0u);
|
|
CHECK(write_length == strlen(dummyData));
|
|
CHECK(write_length == strlen(dummyData));
|
|
REQUIRE_THAT(write_data, Catch::Matchers::Equals(dummyData));
|
|
REQUIRE_THAT(write_data, Catch::Matchers::Equals(dummyData));
|
|
}
|
|
}
|
|
@@ -170,7 +191,7 @@ SCENARIO("Check help auth unauthorized") {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-SCENARIO("Check help authorized") {
|
|
|
|
|
|
+SCENARIO("Check authorized") {
|
|
GIVEN("An initialized shellmatta instance with initialized auth") {
|
|
GIVEN("An initialized shellmatta instance with initialized auth") {
|
|
|
|
|
|
TEST_SHELLMATTA_SETUP;
|
|
TEST_SHELLMATTA_SETUP;
|
|
@@ -252,6 +273,22 @@ SCENARIO("Check help authorized") {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ AND_WHEN("The a private function is called") {
|
|
|
|
+
|
|
|
|
+ ret = shellmatta_processData(handle, (char*)"private\r", 8);
|
|
|
|
+ CHECK(ret == SHELLMATTA_OK);
|
|
|
|
+
|
|
|
|
+ THEN("The command executed.") {
|
|
|
|
+
|
|
|
|
+ char *dummyData = (char*) "private\r\n"
|
|
|
|
+ "\r\n"
|
|
|
|
+ "shimatta@shellmatta->";
|
|
|
|
+
|
|
|
|
+ CHECK(privateTemp == 1u);
|
|
|
|
+ CHECK(write_length == strlen(dummyData));
|
|
|
|
+ REQUIRE_THAT(write_data, Catch::Matchers::Equals(dummyData));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
WHEN("The user not_shellmatta is logged in") {
|
|
WHEN("The user not_shellmatta is logged in") {
|
|
|
|
|
|
@@ -289,6 +326,23 @@ SCENARIO("Check help authorized") {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ AND_WHEN("The a private function is called") {
|
|
|
|
+
|
|
|
|
+ ret = shellmatta_processData(handle, (char*)"private\r", 8);
|
|
|
|
+ CHECK(ret == SHELLMATTA_OK);
|
|
|
|
+
|
|
|
|
+ THEN("The command is not executed.") {
|
|
|
|
+
|
|
|
|
+ char *dummyData = (char*) "private\r\n"
|
|
|
|
+ "\r\n"
|
|
|
|
+ "Command: private not found\r\n"
|
|
|
|
+ "not_shimatta@shellmatta->";
|
|
|
|
+
|
|
|
|
+ CHECK(privateTemp == 0u);
|
|
|
|
+ CHECK(write_length == strlen(dummyData));
|
|
|
|
+ REQUIRE_THAT(write_data, Catch::Matchers::Equals(dummyData));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
WHEN("The user root is logged in") {
|
|
WHEN("The user root is logged in") {
|
|
ret = shellmatta_auth_login(handle, 3);
|
|
ret = shellmatta_auth_login(handle, 3);
|