1*** Settings ***
2Resource         ../../lib/resource.robot
3Resource         ../../lib/bmc_redfish_resource.robot
4Resource         ../../lib/openbmc_ffdc.robot
5
6Test Teardown    FFDC On Test Case Fail
7
8*** Test Cases ***
9
10Redfish Login And Logout
11    [Documentation]  Login to BMCweb and then logout.
12    [Tags]  Redfish_Login_And_Logout
13
14    redfish.Login
15    redfish.Logout
16
17
18GET Redfish Hypermedia Without Login
19    [Documentation]  GET hypermedia URL without login.
20    [Tags]  GET_Redfish_Hypermedia_Without_Login
21    [Template]  GET And Verify Redfish Response
22
23    # Expect status      Resource URL Path
24    ${HTTP_OK}           /
25    ${HTTP_OK}           /redfish
26    ${HTTP_OK}           /redfish/v1
27
28
29GET Redfish SessionService Resource With Login
30    [Documentation]  Login to BMCweb and get /redfish/v1/SessionService.
31    [Tags]  GET_Redfish_SessionService_Resource_With_Login
32
33    redfish.Login
34    ${resp}=  redfish.Get  /redfish/v1/SessionService
35    Should Be Equal As Strings  ${resp.status}  ${HTTP_OK}
36    redfish.Logout
37
38
39GET Redfish SessionService Without Login
40    [Documentation]  Get /redfish/v1/SessionService without login
41    [Tags]  GET_Redfish_SessionService_Without_Login
42
43    ${resp}=  redfish.Get  /redfish/v1/SessionService
44    Should Be Equal As Strings  ${resp.status}  ${HTTP_UNAUTHORIZED}
45
46
47Redfish Login Using Invalid Token
48    [Documentation]  Login to BMCweb with invalid token.
49    [Tags]  Redfish_Login_Using_Invalid_Token
50
51    Create Session  openbmc  ${AUTH_URI}
52
53    # Example: "X-Auth-Token: 3la1JUf1vY4yN2dNOwun"
54    ${headers}=  Create Dictionary  Content-Type=application/json
55    ...  X-Auth-Token=deadbeef
56
57    ${resp}=  Get Request
58    ...  openbmc  /redfish/v1/SessionService/Sessions  headers=${headers}
59
60    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_UNAUTHORIZED}
61
62
63Delete Redfish Session Using Valid login
64    [Documentation]  Delete a session using valid login.
65    [Tags]  Delete_Redfish_Session_Using_Valid_Login
66
67    redfish.Login
68
69    # Example o/p:
70    # [{'@odata.id': '/redfish/v1/SessionService/Sessions/bOol3WlCI8'},
71    #  {'@odata.id': '/redfish/v1/SessionService/Sessions/Yu3xFqjZr1'}]
72    ${resp_list}=  redfish.List Request  /redfish/v1/SessionService/Sessions
73    redfish.Delete  ${resp_list[1]}
74
75    ${resp}=  redfish.List Request  /redfish/v1/SessionService/Sessions
76    List Should Not Contain Value  ${resp}  ${resp_list[1]}
77
78
79*** Keywords ***
80
81GET And Verify Redfish Response
82    [Documentation]  GET given resource and verfiy response.
83    [Arguments]  ${expected_response_code}  ${resource_path}
84
85    # Description of arguments:
86    # expected_response_code   Expected REST status codes.
87    # resource_path            Redfish resource URL path.
88
89    ${resp}=  redfish.Get  ${resource_path}
90    Should Be Equal As Strings  ${resp.status}  ${expected_response_code}
91