blob: 686dfed041c9b3be9b5cd9256fc47d7a567d09a1 [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 Singh45d841e2020-07-30 11:52:11 -050010Library ../../lib/bmc_network_utils.py
11Library ../../lib/gen_robot_valid.py
12
13Suite Setup Redfish.Login
Sushil Singh889a75e2020-08-19 08:50:15 -050014Suite Teardown Run Keyword And Ignore Error Delete All Redfish Sessions
Sushil Singh45d841e2020-07-30 11:52:11 -050015Test Setup Printn
16Test Teardown FFDC On Test Case Fail
17
18
19*** Test Cases ***
20
21Create A Session With ClientID And Verify
Sushil Singh889a75e2020-08-19 08:50:15 -050022 [Documentation] Create a session with client id and verify client id is same.
23 [Tags] Create_A_Session_With_ClientID_And_Verify
24 [Template] Create And Verify Session ClientID
Sushil Singh45d841e2020-07-30 11:52:11 -050025
Sushil Singh889a75e2020-08-19 08:50:15 -050026 # client_id reboot_flag
27 12345 False
28 123456 False
29 EXTERNAL-CLIENT-01 False
30 EXTERNAL-CLIENT-02 False
Sushil Singh13843212020-08-18 04:00:51 -050031
32
33Check ClientID Persistency On BMC Reboot
Sushil Singh889a75e2020-08-19 08:50:15 -050034 [Documentation] Create a session with client id and verify client id is same after the reboot.
35 [Tags] Check_ClientID_Persistency_On_BMC_Reboot
36 [Template] Create And Verify Session ClientID
Sushil Singh13843212020-08-18 04:00:51 -050037
Sushil Singh889a75e2020-08-19 08:50:15 -050038 # client_id reboot_flag
39 12345 True
40 EXTERNAL-CLIENT-01 True
41
42
43Create A Multiple Session With ClientID And Verify
44 [Documentation] Create a multiple session with client id and verify client id is same.
45 [Tags] Create_A_Multiple_Session_With_ClientID_And_Verify
46 [Template] Create And Verify Session ClientID
47
48 # client_id reboot_flag
49 12345,123456 False
50 EXTERNAL-CLIENT-01,EXTERNAL-CLIENT-02 False
51
52
53Check Multiple ClientID Persistency On BMC Reboot
54 [Documentation] Create a multiple session with client id and verify client id is same after the reboot.
55 [Tags] Check_Multiple_ClientID_Persistency_On_BMC_Reboot
56 [Template] Create And Verify Session ClientID
57
58 # client_id reboot_flag
59 12345,123456 True
60 EXTERNAL-CLIENT-01,EXTERNAL-CLIENT-02 True
61
Sushil Singh45d841e2020-07-30 11:52:11 -050062
Sushil Singhc957f572020-08-20 05:47:02 -050063Fail To Set Client Origin IP
64 [Documentation] Fail to set the client origin IP.
65 [Tags] Fail_To_Set_Client_Origin_IP
66 [Template] Create Session And Fail To Set Client Origin IP
67
68 # client_id
69 12345
70 EXTERNAL-CLIENT-01
71
Sushil Singh4ec68ba2020-09-11 09:16:43 -050072
73Create Session For Non Admin User
74 [Documentation] Create Session for non-admin user.
75 [Tags] Create_Session_For_Non_Admin_User
76 [Template] Non Admin User To Create Session
77
78 # client_id username password role_id
79 12345 operator_user TestPwd123 Operator
80
81
Sushil Singh45d841e2020-07-30 11:52:11 -050082*** Keywords ***
83
Sushil Singh13843212020-08-18 04:00:51 -050084Create And Verify Session ClientID
85 [Documentation] Create redifish session with client id and verify it remain same.
86 [Arguments] ${client_id} ${reboot_flag}=False
87
88 # Description of argument(s):
89 # client_id This client id contain string value
90 # (e.g. 12345, "EXTERNAL-CLIENT").
91 # reboot_flag Flag is used to run reboot the BMC code.
92 # (e.g. True or False).
93
Sushil Singh889a75e2020-08-19 08:50:15 -050094 ${client_ids}= Split String ${client_id} ,
Sushil Singh87e984c2020-10-20 01:43:47 -050095 ${session_info}= Create Session With List Of ClientID ${client_ids}
Sushil Singh889a75e2020-08-19 08:50:15 -050096 Verify A Session Created With ClientID ${client_ids} ${session_info}
Sushil Singh13843212020-08-18 04:00:51 -050097 Run Keyword If '${reboot_flag}' == 'True'
Sushil Singh889a75e2020-08-19 08:50:15 -050098 ... Run Keywords Redfish OBMC Reboot (off) AND
99 ... Verify A Session Created With ClientID ${client_ids} ${session_info}
Sushil Singh87e984c2020-10-20 01:43:47 -0500100 Redfish Delete List Of Session ${session_info}
Sushil Singhc957f572020-08-20 05:47:02 -0500101
102
103Set Client Origin IP
104 [Documentation] Set client origin IP.
105 [Arguments] ${client_id} ${client_ip} ${status}
106
107 # Description of argument(s):
108 # client_id This client id contain string value
109 # (e.g. 12345, "EXTERNAL-CLIENT").
110 # client_ip Valid IP address
111 # status HTTP status code
112
113 ${session}= Run Keyword And Return Status
114 ... Redfish Login
115 ... kwargs= "Oem":{"OpenBMC": {"ClientID":"${client_id}", "ClientOriginIP":"${client_ip}"}}
116 Valid Value session [${status}]
117
118
119Create Session And Fail To Set Client Origin IP
120 [Documentation] Create redifish session with client id and fail to set client origin IP.
121 [Arguments] ${client_id}
122
123 # Description of argument(s):
124 # client_id This client id contain string value
125 # (e.g. 12345, "EXTERNAL-CLIENT").
126
127 Set Test Variable ${client_ip} 10.6.7.8
128 ${resp}= Set Client Origin IP ${client_id} ${client_ip} status=False
Sushil Singh4ec68ba2020-09-11 09:16:43 -0500129
130
131Create A Non Admin Session With ClientID
132 [Documentation] Create redifish session with client id.
133 [Arguments] ${client_id} ${username} ${password}
134
135 # Description of argument(s):
136 # client_id This client id can contain string value
137 # (e.g. 12345, "EXTERNAL-CLIENT").
138
139 @{session_list}= Create List
140 &{tmp_dict}= Create Dictionary
141
142 FOR ${client} IN @{client_id}
143 ${resp}= Redfish Login rest_username=${username} rest_password=${password} kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client}"}}
144 Append To List ${session_list} ${resp}
145 END
146
147 [Return] ${session_list}
148
149
150Verify A Non Admin Session Created With ClientID
151 [Documentation] Verify session created with client id.
152 [Arguments] ${client_ids} ${session_ids}
153
154 # Description of argument(s):
Sushil Singh87e984c2020-10-20 01:43:47 -0500155 # client_ids External client name.
156 # session_ids This value is a session id.
Sushil Singh4ec68ba2020-09-11 09:16:43 -0500157
158 # {
159 # "@odata.id": "/redfish/v1/SessionService/Sessions/H8q2ZKucSJ",
160 # "@odata.type": "#Session.v1_0_2.Session",
161 # "Description": "Manager User Session",
162 # "Id": "H8q2ZKucSJ",
163 # "Name": "User Session",
164 # "Oem": {
165 # "OpenBMC": {
166 # "@odata.type": "#OemSession.v1_0_0.Session",
167 # "ClientID": "",
168 # "ClientOriginIP": "::ffff:x.x.x.x"
169 # }
170 # },
171 # "UserName": "root"
172 # }
173
Sushil Singh87e984c2020-10-20 01:43:47 -0500174 FOR ${client} ${session} IN ZIP ${client_ids} ${session_ids}
175 ${resp}= Redfish Get Request /redfish/v1/SessionService/Sessions/${session["Id"]}
Sushil Singh4ec68ba2020-09-11 09:16:43 -0500176 ${sessions}= To Json ${resp.content}
Sushil Singh4ec68ba2020-09-11 09:16:43 -0500177 Rprint Vars sessions
Sushil Singh24e32af2020-10-05 08:09:00 -0500178 @{words} = Split String ${sessions["ClientOriginIPAddress"]} :
Sushil Singh4ec68ba2020-09-11 09:16:43 -0500179 ${ip_address}= Get Running System IP
180 Set Test Variable ${temp_ipaddr} ${words}[-1]
181 Valid Value client ['${sessions["Oem"]["OpenBMC"]["ClientID"]}']
Sushil Singh87e984c2020-10-20 01:43:47 -0500182 Valid Value session["Id"] ['${sessions["Id"]}']
Sushil Singh4ec68ba2020-09-11 09:16:43 -0500183 Valid Value temp_ipaddr ${ip_address}
184 END
185
186
187Non Admin User To Create Session
188 [Documentation] Non Admin user create a session and verify the session is created.
189 [Arguments] ${client_id} ${username} ${password} ${role} ${enabled}=${True}
190
191 # Description of argument(s):
192 # client_id This client id contain string value
193 # (e.g. 12345, "EXTERNAL-CLIENT").
194 # username Username.
195 # password Password.
196 # role Role of user.
197 # enabled Value can be True or False.
198
199 Redfish.Login
200 Redfish Create User ${username} ${password} ${role} ${enabled}
201 Delete All Sessions
202 Redfish.Logout
203 Initialize OpenBMC rest_username=${username} rest_password=${password}
204 ${client_ids}= Split String ${client_id} ,
205 ${session_info}= Create A Non Admin Session With ClientID ${client_ids} ${username} ${password}
206 Verify A Non Admin Session Created With ClientID ${client_ids} ${session_info}