|
@@ -969,4 +969,97 @@ TEST(Head, FileTooSmall) {
|
|
|
EXPECT_NE(response.json["error"].asString(), "");
|
|
|
}
|
|
|
|
|
|
+TEST(Deleteme, Positive) {
|
|
|
+ FileManagerMock fileManager;
|
|
|
+
|
|
|
+ JsonCommander jsonCommander(fileManager);
|
|
|
+
|
|
|
+ // need to set currentUser in jsonCommander via calling checkLogin
|
|
|
+ Json::Value login;
|
|
|
+ login["login"] = true;
|
|
|
+ login["user"] = "positive";
|
|
|
+ login["pass"] = "positive";
|
|
|
+ login["cancel"] = false;
|
|
|
+
|
|
|
+ JsonCommander::Response loginRes = jsonCommander.checkLogin(login);
|
|
|
+ EXPECT_TRUE(loginRes.json["accept"].asBool());
|
|
|
+ EXPECT_EQ(loginRes.json["error"].asString(), "");
|
|
|
+
|
|
|
+ // now the actual test
|
|
|
+ const std::string command = "deleteme";
|
|
|
+
|
|
|
+ Json::Value message;
|
|
|
+ message["command"] = command;
|
|
|
+ message["pass"] = "positive";
|
|
|
+
|
|
|
+ JsonCommander::Response response = jsonCommander.execute(message);
|
|
|
+ EXPECT_EQ(response.action, JsonCommander::Action::closeAndSend);
|
|
|
+ EXPECT_EQ(response.json["command"].asString(), command);
|
|
|
+ EXPECT_TRUE(response.json["accept"].asBool());
|
|
|
+ EXPECT_EQ(response.json["error"].asString(), "");
|
|
|
+}
|
|
|
+
|
|
|
+TEST(Deleteme, Negative) {
|
|
|
+ FileManagerMock fileManager;
|
|
|
+
|
|
|
+ JsonCommander jsonCommander(fileManager);
|
|
|
+
|
|
|
+ // need to set currentUser in jsonCommander via calling checkLogin
|
|
|
+ Json::Value login;
|
|
|
+ login["login"] = true;
|
|
|
+ login["user"] = "positive";
|
|
|
+ login["pass"] = "positive";
|
|
|
+ login["cancel"] = false;
|
|
|
+
|
|
|
+ JsonCommander::Response loginRes = jsonCommander.checkLogin(login);
|
|
|
+ EXPECT_TRUE(loginRes.json["accept"].asBool());
|
|
|
+ EXPECT_EQ(loginRes.json["error"].asString(), "");
|
|
|
+
|
|
|
+ // now the actual test
|
|
|
+ const std::string command = "deleteme";
|
|
|
+
|
|
|
+ Json::Value message;
|
|
|
+ message["command"] = command;
|
|
|
+ message["pass"] = "negative";
|
|
|
+
|
|
|
+ JsonCommander::Response response = jsonCommander.execute(message);
|
|
|
+
|
|
|
+ std::cout << response.json << std::endl;
|
|
|
+
|
|
|
+ EXPECT_EQ(response.action, JsonCommander::Action::send);
|
|
|
+ EXPECT_EQ(response.json["command"].asString(), command);
|
|
|
+ EXPECT_FALSE(response.json["accept"].asBool());
|
|
|
+ EXPECT_NE(response.json["error"].asString(), "");
|
|
|
+}
|
|
|
+
|
|
|
+TEST(Deleteme, InvalidRequest) {
|
|
|
+ FileManagerMock fileManager;
|
|
|
+
|
|
|
+ JsonCommander jsonCommander(fileManager);
|
|
|
+
|
|
|
+ // need to set currentUser in jsonCommander via calling checkLogin
|
|
|
+ Json::Value login;
|
|
|
+ login["login"] = true;
|
|
|
+ login["user"] = "positive";
|
|
|
+ login["pass"] = "positive";
|
|
|
+ login["cancel"] = false;
|
|
|
+
|
|
|
+ JsonCommander::Response loginRes = jsonCommander.checkLogin(login);
|
|
|
+ EXPECT_TRUE(loginRes.json["accept"].asBool());
|
|
|
+ EXPECT_EQ(loginRes.json["error"].asString(), "");
|
|
|
+
|
|
|
+ // now the actual test
|
|
|
+ const std::string command = "deleteme";
|
|
|
+
|
|
|
+ Json::Value message;
|
|
|
+ message["command"] = command;
|
|
|
+ message["pass"] = 123;
|
|
|
+
|
|
|
+ JsonCommander::Response response = jsonCommander.execute(message);
|
|
|
+ EXPECT_EQ(response.action, JsonCommander::Action::closeAndSend);
|
|
|
+ EXPECT_EQ(response.json["command"].asString(), command);
|
|
|
+ EXPECT_FALSE(response.json["accept"].asBool());
|
|
|
+ EXPECT_NE(response.json["error"].asString(), "");
|
|
|
+}
|
|
|
+
|
|
|
} // namespace
|