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