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
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 Without Login
345a73ee0bSGeorge Keishing    [Documentation]  Get /redfish/v1/SessionService without login
355ee33d93SGeorge Keishing    [Tags]  GET_Redfish_SessionService_Without_Login
365a73ee0bSGeorge Keishing
3797c93945SGeorge Keishing    ${resp}=  Redfish.Get  /redfish/v1/SessionService
3897c93945SGeorge Keishing    ...  valid_status_codes=[${HTTP_UNAUTHORIZED}]
395a73ee0bSGeorge Keishing
405a73ee0bSGeorge Keishing
41c681a63fSGeorge KeishingGET Redfish Resources With Login
42c681a63fSGeorge Keishing    [Documentation]  Login to BMCweb and GET valid resource.
43c681a63fSGeorge Keishing    [Tags]  GET_Redfish_Resources_With_Login
44c681a63fSGeorge Keishing    [Setup]  Redfish.Login
45c681a63fSGeorge Keishing    [Template]  GET And Verify Redfish Response
46c681a63fSGeorge Keishing
47c681a63fSGeorge Keishing    # Expect status      Resource URL Path
48c681a63fSGeorge Keishing    ${HTTP_OK}           /redfish/v1/SessionService
49c681a63fSGeorge Keishing    ${HTTP_OK}           /redfish/v1/AccountService
50c681a63fSGeorge Keishing    ${HTTP_OK}           /redfish/v1/Systems/system
51c681a63fSGeorge Keishing    ${HTTP_OK}           /redfish/v1/Chassis/chassis
52c681a63fSGeorge Keishing    ${HTTP_OK}           /redfish/v1/Managers/bmc
53c681a63fSGeorge Keishing    ${HTTP_OK}           /redfish/v1/UpdateService
54c681a63fSGeorge Keishing
55c681a63fSGeorge Keishing
565ee33d93SGeorge KeishingRedfish Login Using Invalid Token
575a73ee0bSGeorge Keishing    [Documentation]  Login to BMCweb with invalid token.
585ee33d93SGeorge Keishing    [Tags]  Redfish_Login_Using_Invalid_Token
595a73ee0bSGeorge Keishing
605a73ee0bSGeorge Keishing    Create Session  openbmc  ${AUTH_URI}
615a73ee0bSGeorge Keishing
625a73ee0bSGeorge Keishing    # Example: "X-Auth-Token: 3la1JUf1vY4yN2dNOwun"
635a73ee0bSGeorge Keishing    ${headers}=  Create Dictionary  Content-Type=application/json
645a73ee0bSGeorge Keishing    ...  X-Auth-Token=deadbeef
655a73ee0bSGeorge Keishing
665a73ee0bSGeorge Keishing    ${resp}=  Get Request
675a73ee0bSGeorge Keishing    ...  openbmc  /redfish/v1/SessionService/Sessions  headers=${headers}
685a73ee0bSGeorge Keishing
695a73ee0bSGeorge Keishing    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_UNAUTHORIZED}
705a73ee0bSGeorge Keishing
715a73ee0bSGeorge Keishing
7207e4109bSGeorge KeishingVerify Redfish Invalid URL Response Code
7307e4109bSGeorge Keishing    [Documentation]  Login to BMCweb and verify error response code.
7407e4109bSGeorge Keishing    [Tags]  Verify_Redfish_Invalid_URL_Response_Code
7507e4109bSGeorge Keishing
7607e4109bSGeorge Keishing    Redfish.Login
7707e4109bSGeorge Keishing    Redfish.Get  /redfish/v1/idontexist  valid_status_codes=[${HTTP_NOT_FOUND}]
7807e4109bSGeorge Keishing    Redfish.Logout
7907e4109bSGeorge Keishing
8007e4109bSGeorge Keishing
815ee33d93SGeorge KeishingDelete Redfish Session Using Valid login
825a73ee0bSGeorge Keishing    [Documentation]  Delete a session using valid login.
835ee33d93SGeorge Keishing    [Tags]  Delete_Redfish_Session_Using_Valid_Login
845a73ee0bSGeorge Keishing
8597c93945SGeorge Keishing    Redfish.Login
866fed4436SGeorge Keishing    ${session_info}=  Get Redfish Session Info
876fed4436SGeorge Keishing
8897c93945SGeorge Keishing    Redfish.Login
895a73ee0bSGeorge Keishing
905a73ee0bSGeorge Keishing    # Example o/p:
915a73ee0bSGeorge Keishing    # [{'@odata.id': '/redfish/v1/SessionService/Sessions/bOol3WlCI8'},
925a73ee0bSGeorge Keishing    #  {'@odata.id': '/redfish/v1/SessionService/Sessions/Yu3xFqjZr1'}]
9397c93945SGeorge Keishing    ${resp_list}=  Redfish_Utils.List Request
9497c93945SGeorge Keishing    ...  /redfish/v1/SessionService/Sessions
956fed4436SGeorge Keishing
966fed4436SGeorge Keishing    Redfish.Delete  ${session_info["location"]}
975a73ee0bSGeorge Keishing
9897c93945SGeorge Keishing    ${resp}=  Redfish_Utils.List Request  /redfish/v1/SessionService/Sessions
996fed4436SGeorge Keishing    List Should Not Contain Value  ${resp}  ${session_info["location"]}
1004db114ccSGeorge Keishing
1016510cfbeSGeorge Keishing
102da5a81d0SGeorge KeishingRedfish Login Via SessionService
103da5a81d0SGeorge Keishing    [Documentation]  Login to BMC via redfish session service.
104da5a81d0SGeorge Keishing    [Tags]   Redfish_Login_Via_SessionService
105da5a81d0SGeorge Keishing
106da5a81d0SGeorge Keishing    Create Session  openbmc  https://${OPENBMC_HOST}
107da5a81d0SGeorge Keishing    ${headers}=  Create Dictionary  Content-Type=application/json
108da5a81d0SGeorge Keishing    ${data}=  Create Dictionary  UserName=${OPENBMC_USERNAME}  Password=${OPENBMC_PASSWORD}
109da5a81d0SGeorge Keishing
110da5a81d0SGeorge Keishing    ${resp}=  Post Request  openbmc  /redfish/v1/SessionService/Sessions  data=${data}  headers=${headers}
111da5a81d0SGeorge Keishing    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_CREATED}
112da5a81d0SGeorge Keishing
113da5a81d0SGeorge Keishing    ${content}=  To JSON  ${resp.content}
114da5a81d0SGeorge Keishing    ${headers}=  Create Dictionary   Content-Type=application/json
115da5a81d0SGeorge Keishing    ...  X-Auth-Token=${resp.headers["X-Auth-Token"]}
116da5a81d0SGeorge Keishing    ${resp}=  Delete Request  openbmc  /redfish/v1/SessionService/Sessions/${content["Id"]}  headers=${headers}
117da5a81d0SGeorge Keishing    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
118da5a81d0SGeorge Keishing
119da5a81d0SGeorge Keishing
120*6d2d42fcSAnusha DathatriVerify Redfish Unresponsive URL paths
121*6d2d42fcSAnusha Dathatri    [Documentation]  Verify that all URLs in /redfish/v1 respond.
122*6d2d42fcSAnusha Dathatri    [Tags]   Verify_Redfish_Unresponsive_URL_paths
123*6d2d42fcSAnusha Dathatri
124*6d2d42fcSAnusha Dathatri    Redfish.Login
125*6d2d42fcSAnusha Dathatri    ${resource_list}  ${dead_resources}=  Enumerate Request  /redfish/v1  include_dead_resources=True
126*6d2d42fcSAnusha Dathatri    Redfish.Logout
127*6d2d42fcSAnusha Dathatri    Valid Length  dead_resources  max_length=0
128*6d2d42fcSAnusha Dathatri
129*6d2d42fcSAnusha Dathatri
1306510cfbeSGeorge Keishing*** Keywords ***
1316510cfbeSGeorge Keishing
1326510cfbeSGeorge KeishingGET And Verify Redfish Response
1336510cfbeSGeorge Keishing    [Documentation]  GET given resource and verfiy response.
13497c93945SGeorge Keishing    [Arguments]  ${valid_status_codes}  ${resource_path}
1356510cfbeSGeorge Keishing
13697c93945SGeorge Keishing    # Description of argument(s):
13797c93945SGeorge Keishing    # valid_status_codes            A comma-separated list of acceptable
13897c93945SGeorge Keishing    #                               status codes (e.g. 200).
1396510cfbeSGeorge Keishing    # resource_path                 Redfish resource URL path.
1406510cfbeSGeorge Keishing
14197c93945SGeorge Keishing    ${resp}=  Redfish.Get  ${resource_path}
14297c93945SGeorge Keishing    ...  valid_status_codes=[${valid_status_codes}]
143