1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
#include <ipmid/sessionhelper.hpp>
#include <gtest/gtest.h>
TEST(parseSessionInputPayloadTest, ValidObjectPath)
{
uint32_t sessionId = 0;
uint8_t sessionHandle = 0;
std::string objectPath =
"/xyz/openbmc_project/ipmi/session/eth0/12a4567d_8a";
EXPECT_TRUE(
parseCloseSessionInputPayload(objectPath, sessionId, sessionHandle));
EXPECT_EQ(0x12a4567d, sessionId);
EXPECT_EQ(0x8a, sessionHandle);
}
TEST(parseSessionInputPayloadTest, InvalidObjectPath)
{
uint32_t sessionId = 0;
uint8_t sessionHandle = 0;
// A valid object path will be like
// "/xyz/openbmc_project/ipmi/session/channel/sessionId_sessionHandle"
// Ex: "/xyz/openbmc_project/ipmi/session/eth0/12a4567d_8a"
// SessionId : 0X12a4567d
// SessionHandle: 0X8a
std::string objectPath = "/xyz/openbmc_project/ipmi/session/eth0/12a4567d";
EXPECT_FALSE(
parseCloseSessionInputPayload(objectPath, sessionId, sessionHandle));
}
TEST(parseSessionInputPayloadTest, NoObjectPath)
{
uint32_t sessionId = 0;
uint8_t sessionHandle = 0;
std::string objectPath;
EXPECT_FALSE(
parseCloseSessionInputPayload(objectPath, sessionId, sessionHandle));
}
TEST(isSessionObjectMatchedTest, ValidSessionId)
{
std::string objectPath =
"/xyz/openbmc_project/ipmi/session/eth0/12a4567d_8a";
uint32_t sessionId = 0x12a4567d;
uint8_t sessionHandle = 0;
EXPECT_TRUE(isSessionObjectMatched(objectPath, sessionId, sessionHandle));
}
TEST(isSessionObjectMatchedTest, ValidSessionHandle)
{
std::string objectPath =
"/xyz/openbmc_project/ipmi/session/eth0/12a4567d_8a";
uint32_t sessionId = 0;
uint8_t sessionHandle = 0x8a;
EXPECT_TRUE(isSessionObjectMatched(objectPath, sessionId, sessionHandle));
}
TEST(isSessionObjectMatchedTest, InvalidSessionId)
{
std::string objectPath =
"/xyz/openbmc_project/ipmi/session/eth0/12a4567d_8a";
uint32_t sessionId = 0x1234b67d;
uint8_t sessionHandle = 0;
EXPECT_FALSE(isSessionObjectMatched(objectPath, sessionId, sessionHandle));
}
TEST(isSessionObjectMatchedTest, InvalidSessionHandle)
{
std::string objectPath =
"/xyz/openbmc_project/ipmi/session/eth0/12a4567d_8a";
uint32_t sessionId = 0;
uint8_t sessionHandle = 0x9b;
EXPECT_FALSE(isSessionObjectMatched(objectPath, sessionId, sessionHandle));
}
TEST(isSessionObjectMatchedTest, ZeroSessionId_ZeroSessionHandle)
{
std::string objectPath =
"/xyz/openbmc_project/ipmi/session/eth0/12a4567d_8a";
uint32_t sessionId = 0;
uint8_t sessionHandle = 0;
EXPECT_FALSE(isSessionObjectMatched(objectPath, sessionId, sessionHandle));
}
TEST(isSessionObjectMatchedTest, InvalidObjectPath)
{
// A valid object path will be like
// "/xyz/openbmc_project/ipmi/session/channel/sessionId_sessionHandle"
// Ex: "/xyz/openbmc_project/ipmi/session/eth0/12a4567d_8a"
// SessionId : 0X12a4567d
// SessionHandle: 0X8a
std::string objectPath = "/xyz/openbmc_project/ipmi/session/eth0/12a4567d";
uint32_t sessionId = 0x12a4567d;
uint8_t sessionHandle = 0;
EXPECT_FALSE(isSessionObjectMatched(objectPath, sessionId, sessionHandle));
}
TEST(isSessionObjectMatchedTest, NoObjectPath)
{
std::string objectPath;
uint32_t sessionId = 0x12a4567d;
uint8_t sessionHandle = 0x8a;
EXPECT_FALSE(isSessionObjectMatched(objectPath, sessionId, sessionHandle));
}
|