15a73ee0bSGeorge Keishing*** Settings ***
2dbfe97dbSJoy OnyerikwuDocumentation    Test Redfish to verify responses for SessionService and Hypermedia.
397c93945SGeorge Keishing
45a73ee0bSGeorge KeishingResource         ../../lib/bmc_redfish_resource.robot
53298d5c3SGeorge KeishingResource         ../../lib/openbmc_ffdc.robot
63298d5c3SGeorge Keishing
797c93945SGeorge Keishing
83298d5c3SGeorge KeishingTest Teardown    FFDC On Test Case Fail
9c108e429SMichael WalshTest Setup       Printn
105a73ee0bSGeorge Keishing
116fb70d98SMatt FischerTest Tags       Service_Root
125431685fSGeorge Keishing
135a73ee0bSGeorge Keishing*** Test Cases ***
145a73ee0bSGeorge Keishing
155ee33d93SGeorge KeishingRedfish Login And Logout
165a73ee0bSGeorge Keishing    [Documentation]  Login to BMCweb and then logout.
175ee33d93SGeorge Keishing    [Tags]  Redfish_Login_And_Logout
185a73ee0bSGeorge Keishing
1997c93945SGeorge Keishing    Redfish.Login
2097c93945SGeorge Keishing    Redfish.Logout
215a73ee0bSGeorge Keishing
225a73ee0bSGeorge Keishing
235ee33d93SGeorge KeishingGET Redfish Hypermedia Without Login
246510cfbeSGeorge Keishing    [Documentation]  GET hypermedia URL without login.
255ee33d93SGeorge Keishing    [Tags]  GET_Redfish_Hypermedia_Without_Login
26ebe7e958SLei YU    [Setup]  Redfish.Logout
276510cfbeSGeorge Keishing    [Template]  GET And Verify Redfish Response
285a73ee0bSGeorge Keishing
296510cfbeSGeorge Keishing    # Expect status      Resource URL Path
306510cfbeSGeorge Keishing    ${HTTP_OK}           /redfish
316510cfbeSGeorge Keishing    ${HTTP_OK}           /redfish/v1
325a73ee0bSGeorge Keishing
335a73ee0bSGeorge Keishing
345ee33d93SGeorge KeishingGET Redfish SessionService Without Login
355a73ee0bSGeorge Keishing    [Documentation]  Get /redfish/v1/SessionService without login
365ee33d93SGeorge Keishing    [Tags]  GET_Redfish_SessionService_Without_Login
37ebe7e958SLei YU    [Setup]  Redfish.Logout
385a73ee0bSGeorge Keishing
3997c93945SGeorge Keishing    ${resp}=  Redfish.Get  /redfish/v1/SessionService
4097c93945SGeorge Keishing    ...  valid_status_codes=[${HTTP_UNAUTHORIZED}]
415a73ee0bSGeorge Keishing
425a73ee0bSGeorge Keishing
43c681a63fSGeorge KeishingGET Redfish Resources With Login
44c681a63fSGeorge Keishing    [Documentation]  Login to BMCweb and GET valid resource.
45c681a63fSGeorge Keishing    [Tags]  GET_Redfish_Resources_With_Login
46c681a63fSGeorge Keishing    [Setup]  Redfish.Login
47c681a63fSGeorge Keishing    [Template]  GET And Verify Redfish Response
48c681a63fSGeorge Keishing
49c681a63fSGeorge Keishing    # Expect status      Resource URL Path
50c681a63fSGeorge Keishing    ${HTTP_OK}           /redfish/v1/SessionService
51c681a63fSGeorge Keishing    ${HTTP_OK}           /redfish/v1/AccountService
52c32434a3SYi Hu    ${HTTP_OK}           /redfish/v1/Systems/${SYSTEM_ID}
532b975827STony Lee    ${HTTP_OK}           /redfish/v1/Chassis/${CHASSIS_ID}
544d430283Sganesanb    ${HTTP_OK}           /redfish/v1/Managers/${MANAGER_ID}
55c681a63fSGeorge Keishing    ${HTTP_OK}           /redfish/v1/UpdateService
56c681a63fSGeorge Keishing
57c681a63fSGeorge Keishing
585ee33d93SGeorge KeishingRedfish Login Using Invalid Token
595a73ee0bSGeorge Keishing    [Documentation]  Login to BMCweb with invalid token.
605ee33d93SGeorge Keishing    [Tags]  Redfish_Login_Using_Invalid_Token
615a73ee0bSGeorge Keishing
625a73ee0bSGeorge Keishing    Create Session  openbmc  ${AUTH_URI}
635a73ee0bSGeorge Keishing
645a73ee0bSGeorge Keishing    # Example: "X-Auth-Token: 3la1JUf1vY4yN2dNOwun"
655a73ee0bSGeorge Keishing    ${headers}=  Create Dictionary  Content-Type=application/json
665a73ee0bSGeorge Keishing    ...  X-Auth-Token=deadbeef
675a73ee0bSGeorge Keishing
68fbd67007SGeorge Keishing    ${resp}=  GET On Session
695a73ee0bSGeorge Keishing    ...  openbmc  /redfish/v1/SessionService/Sessions  headers=${headers}
70fbd67007SGeorge Keishing    ...  expected_status=${HTTP_UNAUTHORIZED}
715a73ee0bSGeorge Keishing
725a73ee0bSGeorge Keishing    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_UNAUTHORIZED}
735a73ee0bSGeorge Keishing
745a73ee0bSGeorge Keishing
7507e4109bSGeorge KeishingVerify Redfish Invalid URL Response Code
7607e4109bSGeorge Keishing    [Documentation]  Login to BMCweb and verify error response code.
7707e4109bSGeorge Keishing    [Tags]  Verify_Redfish_Invalid_URL_Response_Code
7807e4109bSGeorge Keishing
7907e4109bSGeorge Keishing    Redfish.Login
80*43909f32SGeorge Keishing    Wait Until Keyword Succeeds  1 min  30 sec
81*43909f32SGeorge Keishing    ...  Redfish.Get  /redfish/v1/idontexist  valid_status_codes=[${HTTP_NOT_FOUND}]
8207e4109bSGeorge Keishing    Redfish.Logout
8307e4109bSGeorge Keishing
8407e4109bSGeorge Keishing
855236ec54SGeorge KeishingDelete Redfish Session Using Valid Login
865a73ee0bSGeorge Keishing    [Documentation]  Delete a session using valid login.
875ee33d93SGeorge Keishing    [Tags]  Delete_Redfish_Session_Using_Valid_Login
885a73ee0bSGeorge Keishing
8997c93945SGeorge Keishing    Redfish.Login
906fed4436SGeorge Keishing    ${session_info}=  Get Redfish Session Info
916fed4436SGeorge Keishing
9297c93945SGeorge Keishing    Redfish.Login
935a73ee0bSGeorge Keishing
945a73ee0bSGeorge Keishing    # Example o/p:
955a73ee0bSGeorge Keishing    # [{'@odata.id': '/redfish/v1/SessionService/Sessions/bOol3WlCI8'},
965a73ee0bSGeorge Keishing    #  {'@odata.id': '/redfish/v1/SessionService/Sessions/Yu3xFqjZr1'}]
9797c93945SGeorge Keishing    ${resp_list}=  Redfish_Utils.List Request
9897c93945SGeorge Keishing    ...  /redfish/v1/SessionService/Sessions
996fed4436SGeorge Keishing
1006fed4436SGeorge Keishing    Redfish.Delete  ${session_info["location"]}
1015a73ee0bSGeorge Keishing
10297c93945SGeorge Keishing    ${resp}=  Redfish_Utils.List Request  /redfish/v1/SessionService/Sessions
1036fed4436SGeorge Keishing    List Should Not Contain Value  ${resp}  ${session_info["location"]}
1044db114ccSGeorge Keishing
1056510cfbeSGeorge Keishing
106da5a81d0SGeorge KeishingRedfish Login Via SessionService
107da5a81d0SGeorge Keishing    [Documentation]  Login to BMC via redfish session service.
108da5a81d0SGeorge Keishing    [Tags]   Redfish_Login_Via_SessionService
109da5a81d0SGeorge Keishing
1106954602dSMatt Fischer    Create Session  openbmc  https://${OPENBMC_HOST}:${HTTPS_PORT}
111da5a81d0SGeorge Keishing    ${headers}=  Create Dictionary  Content-Type=application/json
112fbd67007SGeorge Keishing    ${data}=  Set Variable  {"UserName":"${OPENBMC_USERNAME}", "Password":"${OPENBMC_PASSWORD}"}
113da5a81d0SGeorge Keishing
114fbd67007SGeorge Keishing    ${resp}=  POST On Session  openbmc  /redfish/v1/SessionService/Sessions  data=${data}  headers=${headers}
115da5a81d0SGeorge Keishing    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_CREATED}
116da5a81d0SGeorge Keishing
117da5a81d0SGeorge Keishing    ${headers}=  Create Dictionary   Content-Type=application/json
118da5a81d0SGeorge Keishing    ...  X-Auth-Token=${resp.headers["X-Auth-Token"]}
119fbd67007SGeorge Keishing    ${resp}=  DELETE On Session  openbmc  ${REDFISH_SESSION}${/}${resp.json()["Id"]}  headers=${headers}
120da5a81d0SGeorge Keishing    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
121da5a81d0SGeorge Keishing
122da5a81d0SGeorge Keishing
1236d2d42fcSAnusha DathatriVerify Redfish Unresponsive URL paths
1246d2d42fcSAnusha Dathatri    [Documentation]  Verify that all URLs in /redfish/v1 respond.
1256d2d42fcSAnusha Dathatri    [Tags]   Verify_Redfish_Unresponsive_URL_paths
1266d2d42fcSAnusha Dathatri
1276d2d42fcSAnusha Dathatri    Redfish.Login
1286d2d42fcSAnusha Dathatri    ${resource_list}  ${dead_resources}=  Enumerate Request  /redfish/v1  include_dead_resources=True
1296d2d42fcSAnusha Dathatri    Redfish.Logout
1306d2d42fcSAnusha Dathatri    Valid Length  dead_resources  max_length=0
1316d2d42fcSAnusha Dathatri
1326d2d42fcSAnusha Dathatri
1336510cfbeSGeorge Keishing*** Keywords ***
1346510cfbeSGeorge Keishing
1356510cfbeSGeorge KeishingGET And Verify Redfish Response
136e16f158fSGeorge Keishing    [Documentation]  GET given resource and verify response.
13797c93945SGeorge Keishing    [Arguments]  ${valid_status_codes}  ${resource_path}
1386510cfbeSGeorge Keishing
13997c93945SGeorge Keishing    # Description of argument(s):
14097c93945SGeorge Keishing    # valid_status_codes            A comma-separated list of acceptable
14197c93945SGeorge Keishing    #                               status codes (e.g. 200).
1426510cfbeSGeorge Keishing    # resource_path                 Redfish resource URL path.
1436510cfbeSGeorge Keishing
14497c93945SGeorge Keishing    ${resp}=  Redfish.Get  ${resource_path}
14597c93945SGeorge Keishing    ...  valid_status_codes=[${valid_status_codes}]
146