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
10c108e429SMichael 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
25ebe7e958SLei YU    [Setup]  Redfish.Logout
266510cfbeSGeorge Keishing    [Template]  GET And Verify Redfish Response
275a73ee0bSGeorge Keishing
286510cfbeSGeorge Keishing    # Expect status      Resource URL Path
296510cfbeSGeorge Keishing    ${HTTP_OK}           /
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
52c681a63fSGeorge Keishing    ${HTTP_OK}           /redfish/v1/Systems/system
53*2b975827STony Lee    ${HTTP_OK}           /redfish/v1/Chassis/${CHASSIS_ID}
54c681a63fSGeorge Keishing    ${HTTP_OK}           /redfish/v1/Managers/bmc
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
685a73ee0bSGeorge Keishing    ${resp}=  Get Request
695a73ee0bSGeorge Keishing    ...  openbmc  /redfish/v1/SessionService/Sessions  headers=${headers}
705a73ee0bSGeorge Keishing
715a73ee0bSGeorge Keishing    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_UNAUTHORIZED}
725a73ee0bSGeorge Keishing
735a73ee0bSGeorge Keishing
7407e4109bSGeorge KeishingVerify Redfish Invalid URL Response Code
7507e4109bSGeorge Keishing    [Documentation]  Login to BMCweb and verify error response code.
7607e4109bSGeorge Keishing    [Tags]  Verify_Redfish_Invalid_URL_Response_Code
7707e4109bSGeorge Keishing
7807e4109bSGeorge Keishing    Redfish.Login
7907e4109bSGeorge Keishing    Redfish.Get  /redfish/v1/idontexist  valid_status_codes=[${HTTP_NOT_FOUND}]
8007e4109bSGeorge Keishing    Redfish.Logout
8107e4109bSGeorge Keishing
8207e4109bSGeorge Keishing
835ee33d93SGeorge KeishingDelete Redfish Session Using Valid login
845a73ee0bSGeorge Keishing    [Documentation]  Delete a session using valid login.
855ee33d93SGeorge Keishing    [Tags]  Delete_Redfish_Session_Using_Valid_Login
865a73ee0bSGeorge Keishing
8797c93945SGeorge Keishing    Redfish.Login
886fed4436SGeorge Keishing    ${session_info}=  Get Redfish Session Info
896fed4436SGeorge Keishing
9097c93945SGeorge Keishing    Redfish.Login
915a73ee0bSGeorge Keishing
925a73ee0bSGeorge Keishing    # Example o/p:
935a73ee0bSGeorge Keishing    # [{'@odata.id': '/redfish/v1/SessionService/Sessions/bOol3WlCI8'},
945a73ee0bSGeorge Keishing    #  {'@odata.id': '/redfish/v1/SessionService/Sessions/Yu3xFqjZr1'}]
9597c93945SGeorge Keishing    ${resp_list}=  Redfish_Utils.List Request
9697c93945SGeorge Keishing    ...  /redfish/v1/SessionService/Sessions
976fed4436SGeorge Keishing
986fed4436SGeorge Keishing    Redfish.Delete  ${session_info["location"]}
995a73ee0bSGeorge Keishing
10097c93945SGeorge Keishing    ${resp}=  Redfish_Utils.List Request  /redfish/v1/SessionService/Sessions
1016fed4436SGeorge Keishing    List Should Not Contain Value  ${resp}  ${session_info["location"]}
1024db114ccSGeorge Keishing
1036510cfbeSGeorge Keishing
104da5a81d0SGeorge KeishingRedfish Login Via SessionService
105da5a81d0SGeorge Keishing    [Documentation]  Login to BMC via redfish session service.
106da5a81d0SGeorge Keishing    [Tags]   Redfish_Login_Via_SessionService
107da5a81d0SGeorge Keishing
108da5a81d0SGeorge Keishing    Create Session  openbmc  https://${OPENBMC_HOST}
109da5a81d0SGeorge Keishing    ${headers}=  Create Dictionary  Content-Type=application/json
110da5a81d0SGeorge Keishing    ${data}=  Create Dictionary  UserName=${OPENBMC_USERNAME}  Password=${OPENBMC_PASSWORD}
111da5a81d0SGeorge Keishing
112da5a81d0SGeorge Keishing    ${resp}=  Post Request  openbmc  /redfish/v1/SessionService/Sessions  data=${data}  headers=${headers}
113da5a81d0SGeorge Keishing    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_CREATED}
114da5a81d0SGeorge Keishing
115da5a81d0SGeorge Keishing    ${content}=  To JSON  ${resp.content}
116da5a81d0SGeorge Keishing    ${headers}=  Create Dictionary   Content-Type=application/json
117da5a81d0SGeorge Keishing    ...  X-Auth-Token=${resp.headers["X-Auth-Token"]}
118e4d41420SGeorge Keishing    ${resp}=  Delete Request  openbmc  ${REDFISH_SESSION}${/}${content["Id"]}  headers=${headers}
119da5a81d0SGeorge Keishing    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
120da5a81d0SGeorge Keishing
121da5a81d0SGeorge Keishing
1226d2d42fcSAnusha DathatriVerify Redfish Unresponsive URL paths
1236d2d42fcSAnusha Dathatri    [Documentation]  Verify that all URLs in /redfish/v1 respond.
1246d2d42fcSAnusha Dathatri    [Tags]   Verify_Redfish_Unresponsive_URL_paths
1256d2d42fcSAnusha Dathatri
1266d2d42fcSAnusha Dathatri    Redfish.Login
1276d2d42fcSAnusha Dathatri    ${resource_list}  ${dead_resources}=  Enumerate Request  /redfish/v1  include_dead_resources=True
1286d2d42fcSAnusha Dathatri    Redfish.Logout
1296d2d42fcSAnusha Dathatri    Valid Length  dead_resources  max_length=0
1306d2d42fcSAnusha Dathatri
1316d2d42fcSAnusha Dathatri
1326510cfbeSGeorge Keishing*** Keywords ***
1336510cfbeSGeorge Keishing
1346510cfbeSGeorge KeishingGET And Verify Redfish Response
1356510cfbeSGeorge Keishing    [Documentation]  GET given resource and verfiy response.
13697c93945SGeorge Keishing    [Arguments]  ${valid_status_codes}  ${resource_path}
1376510cfbeSGeorge Keishing
13897c93945SGeorge Keishing    # Description of argument(s):
13997c93945SGeorge Keishing    # valid_status_codes            A comma-separated list of acceptable
14097c93945SGeorge Keishing    #                               status codes (e.g. 200).
1416510cfbeSGeorge Keishing    # resource_path                 Redfish resource URL path.
1426510cfbeSGeorge Keishing
14397c93945SGeorge Keishing    ${resp}=  Redfish.Get  ${resource_path}
14497c93945SGeorge Keishing    ...  valid_status_codes=[${valid_status_codes}]
145