blob: 92124d14c245def125bc0d684871f53c098e0818 [file] [log] [blame]
Sushil Singh45d841e2020-07-30 11:52:11 -05001*** Settings ***
2
3Documentation Test client identifier feature on BMC.
4
5Resource ../../lib/rest_client.robot
6Resource ../../lib/openbmc_ffdc.robot
7Resource ../../lib/resource.robot
8Resource ../../lib/bmc_redfish_utils.robot
9Library ../../lib/bmc_network_utils.py
10Library ../../lib/gen_robot_valid.py
11
12Suite Setup Redfish.Login
Sushil Singh889a75e2020-08-19 08:50:15 -050013Suite Teardown Run Keyword And Ignore Error Delete All Redfish Sessions
Sushil Singh45d841e2020-07-30 11:52:11 -050014Test Setup Printn
15Test Teardown FFDC On Test Case Fail
16
17
18*** Test Cases ***
19
20Create A Session With ClientID And Verify
Sushil Singh889a75e2020-08-19 08:50:15 -050021 [Documentation] Create a session with client id and verify client id is same.
22 [Tags] Create_A_Session_With_ClientID_And_Verify
23 [Template] Create And Verify Session ClientID
Sushil Singh45d841e2020-07-30 11:52:11 -050024
Sushil Singh889a75e2020-08-19 08:50:15 -050025 # client_id reboot_flag
26 12345 False
27 123456 False
28 EXTERNAL-CLIENT-01 False
29 EXTERNAL-CLIENT-02 False
Sushil Singh13843212020-08-18 04:00:51 -050030
31
32Check ClientID Persistency On BMC Reboot
Sushil Singh889a75e2020-08-19 08:50:15 -050033 [Documentation] Create a session with client id and verify client id is same after the reboot.
34 [Tags] Check_ClientID_Persistency_On_BMC_Reboot
35 [Template] Create And Verify Session ClientID
Sushil Singh13843212020-08-18 04:00:51 -050036
Sushil Singh889a75e2020-08-19 08:50:15 -050037 # client_id reboot_flag
38 12345 True
39 EXTERNAL-CLIENT-01 True
40
41
42Create A Multiple Session With ClientID And Verify
43 [Documentation] Create a multiple session with client id and verify client id is same.
44 [Tags] Create_A_Multiple_Session_With_ClientID_And_Verify
45 [Template] Create And Verify Session ClientID
46
47 # client_id reboot_flag
48 12345,123456 False
49 EXTERNAL-CLIENT-01,EXTERNAL-CLIENT-02 False
50
51
52Check Multiple ClientID Persistency On BMC Reboot
53 [Documentation] Create a multiple session with client id and verify client id is same after the reboot.
54 [Tags] Check_Multiple_ClientID_Persistency_On_BMC_Reboot
55 [Template] Create And Verify Session ClientID
56
57 # client_id reboot_flag
58 12345,123456 True
59 EXTERNAL-CLIENT-01,EXTERNAL-CLIENT-02 True
60
Sushil Singh45d841e2020-07-30 11:52:11 -050061
Sushil Singhc957f572020-08-20 05:47:02 -050062Fail To Set Client Origin IP
63 [Documentation] Fail to set the client origin IP.
64 [Tags] Fail_To_Set_Client_Origin_IP
65 [Template] Create Session And Fail To Set Client Origin IP
66
67 # client_id
68 12345
69 EXTERNAL-CLIENT-01
70
Sushil Singh45d841e2020-07-30 11:52:11 -050071*** Keywords ***
72
73Create A Session With ClientID
74 [Documentation] Create redifish session with client id.
75 [Arguments] ${client_id}
76
77 # Description of argument(s):
78 # client_id This client id can contain string value
79 # (e.g. 12345, "EXTERNAL-CLIENT").
80
Sushil Singh889a75e2020-08-19 08:50:15 -050081 @{session_list}= Create List
82 &{tmp_dict}= Create Dictionary
Sushil Singh45d841e2020-07-30 11:52:11 -050083
Sushil Singh889a75e2020-08-19 08:50:15 -050084 FOR ${client} IN @{client_id}
85 ${resp}= Redfish Login kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client}"}}
86 Append To List ${session_list} ${resp}
87 END
88
89 [Return] ${session_list}
90
91
92Get Session Information By ClientID
93 [Documentation] Get session information by client id.
94 [Arguments] ${client_id} ${session_ids}
95
96 FOR ${session} IN @{session_ids}
97 Return From Keyword If '${client_id}' == '${session["Oem"]["OpenBMC"]["ClientID"]}' ${session["Id"]}
98 END
99
100 [Return] ${EMPTY}
101
Sushil Singh45d841e2020-07-30 11:52:11 -0500102
103Verify A Session Created With ClientID
104 [Documentation] Verify session created with client id.
Sushil Singh889a75e2020-08-19 08:50:15 -0500105 [Arguments] ${client_ids} ${session_ids}
Sushil Singh45d841e2020-07-30 11:52:11 -0500106
107 # Description of argument(s):
108 # client_id External client name.
109 # session_id This value is a session id.
110
Sushil Singh45d841e2020-07-30 11:52:11 -0500111 # {
112 # "@odata.id": "/redfish/v1/SessionService/Sessions/H8q2ZKucSJ",
113 # "@odata.type": "#Session.v1_0_2.Session",
114 # "Description": "Manager User Session",
115 # "Id": "H8q2ZKucSJ",
116 # "Name": "User Session",
117 # "Oem": {
118 # "OpenBMC": {
119 # "@odata.type": "#OemSession.v1_0_0.Session",
120 # "ClientID": "",
121 # "ClientOriginIP": "::ffff:x.x.x.x"
122 # }
123 # },
124 # "UserName": "root"
125 # }
126
Sushil Singh889a75e2020-08-19 08:50:15 -0500127 FOR ${client} IN @{client_ids}
128 ${session_id}= Get Session Information By ClientID ${client} ${session_ids}
129 ${sessions}= Redfish.Get Properties /redfish/v1/SessionService/Sessions/${session_id}
130 Rprint Vars sessions
131 @{words} = Split String ${sessions["Oem"]["OpenBMC"]["ClientOriginIP"]} :
Sushil Singhbfaeb032020-09-01 02:02:36 -0500132 ${host_name}= Get Hostname
133 ${host_name} ${ip_address}= Get Host Name IP host=${host_name}
134 Set Suite Variable ${ip_address}
Sushil Singh889a75e2020-08-19 08:50:15 -0500135 Set Test Variable ${temp_ipaddr} ${words}[-1]
136 Valid Value client ['${sessions["Oem"]["OpenBMC"]["ClientID"]}']
137 Valid Value sessions["Id"] ['${session_id}']
Sushil Singhbfaeb032020-09-01 02:02:36 -0500138 Valid Value temp_ipaddr ['${ip_address}']
Sushil Singh889a75e2020-08-19 08:50:15 -0500139 END
Sushil Singh13843212020-08-18 04:00:51 -0500140
141
142Create And Verify Session ClientID
143 [Documentation] Create redifish session with client id and verify it remain same.
144 [Arguments] ${client_id} ${reboot_flag}=False
145
146 # Description of argument(s):
147 # client_id This client id contain string value
148 # (e.g. 12345, "EXTERNAL-CLIENT").
149 # reboot_flag Flag is used to run reboot the BMC code.
150 # (e.g. True or False).
151
Sushil Singh889a75e2020-08-19 08:50:15 -0500152 ${client_ids}= Split String ${client_id} ,
153 ${session_info}= Create A Session With ClientID ${client_ids}
154 Verify A Session Created With ClientID ${client_ids} ${session_info}
Sushil Singh13843212020-08-18 04:00:51 -0500155 Run Keyword If '${reboot_flag}' == 'True'
Sushil Singh889a75e2020-08-19 08:50:15 -0500156 ... Run Keywords Redfish OBMC Reboot (off) AND
157 ... Verify A Session Created With ClientID ${client_ids} ${session_info}
Sushil Singhc957f572020-08-20 05:47:02 -0500158
159
160Set Client Origin IP
161 [Documentation] Set client origin IP.
162 [Arguments] ${client_id} ${client_ip} ${status}
163
164 # Description of argument(s):
165 # client_id This client id contain string value
166 # (e.g. 12345, "EXTERNAL-CLIENT").
167 # client_ip Valid IP address
168 # status HTTP status code
169
170 ${session}= Run Keyword And Return Status
171 ... Redfish Login
172 ... kwargs= "Oem":{"OpenBMC": {"ClientID":"${client_id}", "ClientOriginIP":"${client_ip}"}}
173 Valid Value session [${status}]
174
175
176Create Session And Fail To Set Client Origin IP
177 [Documentation] Create redifish session with client id and fail to set client origin IP.
178 [Arguments] ${client_id}
179
180 # Description of argument(s):
181 # client_id This client id contain string value
182 # (e.g. 12345, "EXTERNAL-CLIENT").
183
184 Set Test Variable ${client_ip} 10.6.7.8
185 ${resp}= Set Client Origin IP ${client_id} ${client_ip} status=False