15a73ee0bSGeorge Keishing*** Settings ***
2dbfe97dbSJoy OnyerikwuDocumentation    Test Redfish to verify responses for SessionService and Hypermedia.
397c93945SGeorge Keishing
4839a0c27SSandhya SomashekarResource         ../../lib/resource.robot
55a73ee0bSGeorge KeishingResource         ../../lib/bmc_redfish_resource.robot
63298d5c3SGeorge KeishingResource         ../../lib/openbmc_ffdc.robot
73298d5c3SGeorge Keishing
897c93945SGeorge Keishing
93298d5c3SGeorge KeishingTest Teardown    FFDC On Test Case Fail
10*c108e429SMichael WalshTest Setup       Printn
115a73ee0bSGeorge Keishing
125a73ee0bSGeorge Keishing*** Test Cases ***
135a73ee0bSGeorge Keishing
145ee33d93SGeorge KeishingRedfish Login And Logout
155a73ee0bSGeorge Keishing    [Documentation]  Login to BMCweb and then logout.
165ee33d93SGeorge Keishing    [Tags]  Redfish_Login_And_Logout
175a73ee0bSGeorge Keishing
1897c93945SGeorge Keishing    Redfish.Login
1997c93945SGeorge Keishing    Redfish.Logout
205a73ee0bSGeorge Keishing
215a73ee0bSGeorge Keishing
225ee33d93SGeorge KeishingGET Redfish Hypermedia Without Login
236510cfbeSGeorge Keishing    [Documentation]  GET hypermedia URL without login.
245ee33d93SGeorge Keishing    [Tags]  GET_Redfish_Hypermedia_Without_Login
256510cfbeSGeorge Keishing    [Template]  GET And Verify Redfish Response
265a73ee0bSGeorge Keishing
276510cfbeSGeorge Keishing    # Expect status      Resource URL Path
286510cfbeSGeorge Keishing    ${HTTP_OK}           /
296510cfbeSGeorge Keishing    ${HTTP_OK}           /redfish
306510cfbeSGeorge Keishing    ${HTTP_OK}           /redfish/v1
315a73ee0bSGeorge Keishing
325a73ee0bSGeorge Keishing
335ee33d93SGeorge KeishingGET Redfish SessionService Resource With Login
345a73ee0bSGeorge Keishing    [Documentation]  Login to BMCweb and get /redfish/v1/SessionService.
355ee33d93SGeorge Keishing    [Tags]  GET_Redfish_SessionService_Resource_With_Login
365a73ee0bSGeorge Keishing
3797c93945SGeorge Keishing    Redfish.Login
3897c93945SGeorge Keishing    ${resp}=  Redfish.Get  /redfish/v1/SessionService
3997c93945SGeorge Keishing    Redfish.Logout
405a73ee0bSGeorge Keishing
415a73ee0bSGeorge Keishing
425ee33d93SGeorge KeishingGET Redfish SessionService Without Login
435a73ee0bSGeorge Keishing    [Documentation]  Get /redfish/v1/SessionService without login
445ee33d93SGeorge Keishing    [Tags]  GET_Redfish_SessionService_Without_Login
455a73ee0bSGeorge Keishing
4697c93945SGeorge Keishing    ${resp}=  Redfish.Get  /redfish/v1/SessionService
4797c93945SGeorge Keishing    ...  valid_status_codes=[${HTTP_UNAUTHORIZED}]
485a73ee0bSGeorge Keishing
495a73ee0bSGeorge Keishing
505ee33d93SGeorge KeishingRedfish Login Using Invalid Token
515a73ee0bSGeorge Keishing    [Documentation]  Login to BMCweb with invalid token.
525ee33d93SGeorge Keishing    [Tags]  Redfish_Login_Using_Invalid_Token
535a73ee0bSGeorge Keishing
545a73ee0bSGeorge Keishing    Create Session  openbmc  ${AUTH_URI}
555a73ee0bSGeorge Keishing
565a73ee0bSGeorge Keishing    # Example: "X-Auth-Token: 3la1JUf1vY4yN2dNOwun"
575a73ee0bSGeorge Keishing    ${headers}=  Create Dictionary  Content-Type=application/json
585a73ee0bSGeorge Keishing    ...  X-Auth-Token=deadbeef
595a73ee0bSGeorge Keishing
605a73ee0bSGeorge Keishing    ${resp}=  Get Request
615a73ee0bSGeorge Keishing    ...  openbmc  /redfish/v1/SessionService/Sessions  headers=${headers}
625a73ee0bSGeorge Keishing
635a73ee0bSGeorge Keishing    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_UNAUTHORIZED}
645a73ee0bSGeorge Keishing
655a73ee0bSGeorge Keishing
665ee33d93SGeorge KeishingDelete Redfish Session Using Valid login
675a73ee0bSGeorge Keishing    [Documentation]  Delete a session using valid login.
685ee33d93SGeorge Keishing    [Tags]  Delete_Redfish_Session_Using_Valid_Login
695a73ee0bSGeorge Keishing
7097c93945SGeorge Keishing    Redfish.Login
716fed4436SGeorge Keishing    ${session_info}=  Get Redfish Session Info
726fed4436SGeorge Keishing
7397c93945SGeorge Keishing    Redfish.Login
745a73ee0bSGeorge Keishing
755a73ee0bSGeorge Keishing    # Example o/p:
765a73ee0bSGeorge Keishing    # [{'@odata.id': '/redfish/v1/SessionService/Sessions/bOol3WlCI8'},
775a73ee0bSGeorge Keishing    #  {'@odata.id': '/redfish/v1/SessionService/Sessions/Yu3xFqjZr1'}]
7897c93945SGeorge Keishing    ${resp_list}=  Redfish_Utils.List Request
7997c93945SGeorge Keishing    ...  /redfish/v1/SessionService/Sessions
806fed4436SGeorge Keishing
816fed4436SGeorge Keishing    Redfish.Delete  ${session_info["location"]}
825a73ee0bSGeorge Keishing
8397c93945SGeorge Keishing    ${resp}=  Redfish_Utils.List Request  /redfish/v1/SessionService/Sessions
846fed4436SGeorge Keishing    List Should Not Contain Value  ${resp}  ${session_info["location"]}
854db114ccSGeorge Keishing
866510cfbeSGeorge Keishing
876510cfbeSGeorge Keishing*** Keywords ***
886510cfbeSGeorge Keishing
896510cfbeSGeorge KeishingGET And Verify Redfish Response
906510cfbeSGeorge Keishing    [Documentation]  GET given resource and verfiy response.
9197c93945SGeorge Keishing    [Arguments]  ${valid_status_codes}  ${resource_path}
926510cfbeSGeorge Keishing
9397c93945SGeorge Keishing    # Description of argument(s):
9497c93945SGeorge Keishing    # valid_status_codes            A comma-separated list of acceptable
9597c93945SGeorge Keishing    #                               status codes (e.g. 200).
966510cfbeSGeorge Keishing    # resource_path                 Redfish resource URL path.
976510cfbeSGeorge Keishing
9897c93945SGeorge Keishing    ${resp}=  Redfish.Get  ${resource_path}
9997c93945SGeorge Keishing    ...  valid_status_codes=[${valid_status_codes}]
100