blob: 8cfa771aca6d8c75b0733b44f1ef774c9298482b [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
Sushil Singhca49ced2020-11-05 03:15:19 -06009Resource ../../lib/external_intf/management_console_utils.robot
Sushil Singhf90fd652021-02-05 05:07:40 -060010Resource ../../lib/utils.robot
Sushil Singh45d841e2020-07-30 11:52:11 -050011Library ../../lib/bmc_network_utils.py
12Library ../../lib/gen_robot_valid.py
13
Sushil Singhf90fd652021-02-05 05:07:40 -060014
Sushil Singh45d841e2020-07-30 11:52:11 -050015Suite Setup Redfish.Login
Sushil Singh889a75e2020-08-19 08:50:15 -050016Suite Teardown Run Keyword And Ignore Error Delete All Redfish Sessions
Sushil Singh45d841e2020-07-30 11:52:11 -050017Test Setup Printn
18Test Teardown FFDC On Test Case Fail
19
20
21*** Test Cases ***
22
23Create A Session With ClientID And Verify
Sushil Singh889a75e2020-08-19 08:50:15 -050024 [Documentation] Create a session with client id and verify client id is same.
25 [Tags] Create_A_Session_With_ClientID_And_Verify
26 [Template] Create And Verify Session ClientID
Sushil Singh45d841e2020-07-30 11:52:11 -050027
Sushil Singh889a75e2020-08-19 08:50:15 -050028 # client_id reboot_flag
29 12345 False
30 123456 False
31 EXTERNAL-CLIENT-01 False
32 EXTERNAL-CLIENT-02 False
Sushil Singh13843212020-08-18 04:00:51 -050033
34
35Check ClientID Persistency On BMC Reboot
Sushil Singh889a75e2020-08-19 08:50:15 -050036 [Documentation] Create a session with client id and verify client id is same after the reboot.
37 [Tags] Check_ClientID_Persistency_On_BMC_Reboot
38 [Template] Create And Verify Session ClientID
Sushil Singh13843212020-08-18 04:00:51 -050039
Sushil Singh889a75e2020-08-19 08:50:15 -050040 # client_id reboot_flag
41 12345 True
42 EXTERNAL-CLIENT-01 True
43
44
45Create A Multiple Session With ClientID And Verify
46 [Documentation] Create a multiple session with client id and verify client id is same.
47 [Tags] Create_A_Multiple_Session_With_ClientID_And_Verify
48 [Template] Create And Verify Session ClientID
49
50 # client_id reboot_flag
51 12345,123456 False
52 EXTERNAL-CLIENT-01,EXTERNAL-CLIENT-02 False
53
54
55Check Multiple ClientID Persistency On BMC Reboot
56 [Documentation] Create a multiple session with client id and verify client id is same after the reboot.
57 [Tags] Check_Multiple_ClientID_Persistency_On_BMC_Reboot
58 [Template] Create And Verify Session ClientID
59
60 # client_id reboot_flag
61 12345,123456 True
62 EXTERNAL-CLIENT-01,EXTERNAL-CLIENT-02 True
63
Sushil Singh45d841e2020-07-30 11:52:11 -050064
Sushil Singhc957f572020-08-20 05:47:02 -050065Fail To Set Client Origin IP
66 [Documentation] Fail to set the client origin IP.
67 [Tags] Fail_To_Set_Client_Origin_IP
68 [Template] Create Session And Fail To Set Client Origin IP
69
70 # client_id
71 12345
72 EXTERNAL-CLIENT-01
73
Sushil Singh4ec68ba2020-09-11 09:16:43 -050074
75Create Session For Non Admin User
76 [Documentation] Create Session for non-admin user.
77 [Tags] Create_Session_For_Non_Admin_User
78 [Template] Non Admin User To Create Session
79
80 # client_id username password role_id
81 12345 operator_user TestPwd123 Operator
82
83
Sushil Singh45d841e2020-07-30 11:52:11 -050084*** Keywords ***
85
Sushil Singh13843212020-08-18 04:00:51 -050086Create And Verify Session ClientID
87 [Documentation] Create redifish session with client id and verify it remain same.
88 [Arguments] ${client_id} ${reboot_flag}=False
89
90 # Description of argument(s):
91 # client_id This client id contain string value
92 # (e.g. 12345, "EXTERNAL-CLIENT").
93 # reboot_flag Flag is used to run reboot the BMC code.
94 # (e.g. True or False).
95
Sushil Singh889a75e2020-08-19 08:50:15 -050096 ${client_ids}= Split String ${client_id} ,
Sushil Singh87e984c2020-10-20 01:43:47 -050097 ${session_info}= Create Session With List Of ClientID ${client_ids}
Sushil Singh889a75e2020-08-19 08:50:15 -050098 Verify A Session Created With ClientID ${client_ids} ${session_info}
Sushil Singhf90fd652021-02-05 05:07:40 -060099
100 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN}
101
Sushil Singh13843212020-08-18 04:00:51 -0500102 Run Keyword If '${reboot_flag}' == 'True'
Sushil Singhf90fd652021-02-05 05:07:40 -0600103 ... Run Keywords Redfish BMC Reset Operation AND
104 ... Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token} AND
105 ... Is BMC Standby AND
Sushil Singh889a75e2020-08-19 08:50:15 -0500106 ... Verify A Session Created With ClientID ${client_ids} ${session_info}
Sushil Singhf90fd652021-02-05 05:07:40 -0600107
Sushil Singh87e984c2020-10-20 01:43:47 -0500108 Redfish Delete List Of Session ${session_info}
Sushil Singhc957f572020-08-20 05:47:02 -0500109
110
111Set Client Origin IP
112 [Documentation] Set client origin IP.
113 [Arguments] ${client_id} ${client_ip} ${status}
114
115 # Description of argument(s):
116 # client_id This client id contain string value
117 # (e.g. 12345, "EXTERNAL-CLIENT").
118 # client_ip Valid IP address
119 # status HTTP status code
120
121 ${session}= Run Keyword And Return Status
122 ... Redfish Login
123 ... kwargs= "Oem":{"OpenBMC": {"ClientID":"${client_id}", "ClientOriginIP":"${client_ip}"}}
124 Valid Value session [${status}]
125
126
127Create Session And Fail To Set Client Origin IP
128 [Documentation] Create redifish session with client id and fail to set client origin IP.
129 [Arguments] ${client_id}
130
131 # Description of argument(s):
132 # client_id This client id contain string value
133 # (e.g. 12345, "EXTERNAL-CLIENT").
134
135 Set Test Variable ${client_ip} 10.6.7.8
136 ${resp}= Set Client Origin IP ${client_id} ${client_ip} status=False
Sushil Singh4ec68ba2020-09-11 09:16:43 -0500137
138
139Create A Non Admin Session With ClientID
140 [Documentation] Create redifish session with client id.
141 [Arguments] ${client_id} ${username} ${password}
142
143 # Description of argument(s):
144 # client_id This client id can contain string value
145 # (e.g. 12345, "EXTERNAL-CLIENT").
146
147 @{session_list}= Create List
148 &{tmp_dict}= Create Dictionary
149
150 FOR ${client} IN @{client_id}
George Keishingb78bca22021-06-29 11:11:19 -0500151 ${resp}= Redfish Login rest_username=${username} rest_password=${password}
152 ... kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client}"}}
Sushil Singh4ec68ba2020-09-11 09:16:43 -0500153 Append To List ${session_list} ${resp}
154 END
155
156 [Return] ${session_list}
157
158
159Verify A Non Admin Session Created With ClientID
160 [Documentation] Verify session created with client id.
161 [Arguments] ${client_ids} ${session_ids}
162
163 # Description of argument(s):
Sushil Singh87e984c2020-10-20 01:43:47 -0500164 # client_ids External client name.
165 # session_ids This value is a session id.
Sushil Singh4ec68ba2020-09-11 09:16:43 -0500166
167 # {
168 # "@odata.id": "/redfish/v1/SessionService/Sessions/H8q2ZKucSJ",
169 # "@odata.type": "#Session.v1_0_2.Session",
170 # "Description": "Manager User Session",
171 # "Id": "H8q2ZKucSJ",
172 # "Name": "User Session",
173 # "Oem": {
174 # "OpenBMC": {
175 # "@odata.type": "#OemSession.v1_0_0.Session",
176 # "ClientID": "",
177 # "ClientOriginIP": "::ffff:x.x.x.x"
178 # }
179 # },
180 # "UserName": "root"
181 # }
182
Sushil Singh87e984c2020-10-20 01:43:47 -0500183 FOR ${client} ${session} IN ZIP ${client_ids} ${session_ids}
184 ${resp}= Redfish Get Request /redfish/v1/SessionService/Sessions/${session["Id"]}
George Keishingfbd67002022-08-01 11:24:03 -0500185 Rprint Vars resp.json()
186 @{words} = Split String ${resp.json()["ClientOriginIPAddress"]} :
Sushil Singh4ec68ba2020-09-11 09:16:43 -0500187 ${ip_address}= Get Running System IP
188 Set Test Variable ${temp_ipaddr} ${words}[-1]
George Keishingfbd67002022-08-01 11:24:03 -0500189 Valid Value client ['${resp.json()["Oem"]["OpenBMC"]["ClientID"]}']
190 Valid Value session["Id"] ['${resp.json()["Id"]}']
Sushil Singh4ec68ba2020-09-11 09:16:43 -0500191 Valid Value temp_ipaddr ${ip_address}
192 END
193
194
195Non Admin User To Create Session
196 [Documentation] Non Admin user create a session and verify the session is created.
197 [Arguments] ${client_id} ${username} ${password} ${role} ${enabled}=${True}
198
199 # Description of argument(s):
200 # client_id This client id contain string value
201 # (e.g. 12345, "EXTERNAL-CLIENT").
202 # username Username.
203 # password Password.
204 # role Role of user.
205 # enabled Value can be True or False.
206
207 Redfish.Login
208 Redfish Create User ${username} ${password} ${role} ${enabled}
209 Delete All Sessions
210 Redfish.Logout
211 Initialize OpenBMC rest_username=${username} rest_password=${password}
212 ${client_ids}= Split String ${client_id} ,
213 ${session_info}= Create A Non Admin Session With ClientID ${client_ids} ${username} ${password}
214 Verify A Non Admin Session Created With ClientID ${client_ids} ${session_info}