1 #include "http_response.hpp" 2 #include "ibm/management_console_rest.hpp" 3 4 #include <string> 5 6 #include <gtest/gtest.h> 7 8 namespace crow 9 { 10 namespace ibm_mc 11 { 12 13 TEST(IsValidConfigFileName, FileNameValidCharReturnsTrue) 14 { 15 crow::Response res; 16 17 EXPECT_TRUE(isValidConfigFileName("GoodConfigFile", res)); 18 } 19 TEST(IsValidConfigFileName, FileNameInvalidCharReturnsFalse) 20 { 21 crow::Response res; 22 23 EXPECT_FALSE(isValidConfigFileName("Bad@file", res)); 24 } 25 TEST(IsValidConfigFileName, FileNameInvalidPathReturnsFalse) 26 { 27 crow::Response res; 28 29 EXPECT_FALSE(isValidConfigFileName("/../../../../../etc/badpath", res)); 30 EXPECT_FALSE(isValidConfigFileName("/../../etc/badpath", res)); 31 EXPECT_FALSE(isValidConfigFileName("/mydir/configFile", res)); 32 } 33 34 TEST(IsValidConfigFileName, EmptyFileNameReturnsFalse) 35 { 36 crow::Response res; 37 EXPECT_FALSE(isValidConfigFileName("", res)); 38 } 39 40 TEST(IsValidConfigFileName, SlashFileNameReturnsFalse) 41 { 42 crow::Response res; 43 EXPECT_FALSE(isValidConfigFileName("/", res)); 44 } 45 TEST(IsValidConfigFileName, FileNameMoreThan20CharReturnsFalse) 46 { 47 crow::Response res; 48 EXPECT_FALSE(isValidConfigFileName("BadfileBadfileBadfile", res)); 49 } 50 51 } // namespace ibm_mc 52 } // namespace crow 53