1*** Settings ***
2Resource         ../../lib/resource.txt
3Resource         ../../lib/bmc_redfish_resource.robot
4
5Suite Teardown   redfish.Logout
6
7
8*** Test Cases ***
9
10Login And Logout BMCweb
11    [Documentation]  Login to BMCweb and then logout.
12    [Tags]  Login_And_Logout_BMCweb
13
14    redfish.Login
15    redfish.Logout
16
17
18GET BMCweb Hypermedia Without Login
19    [Documentation]  GET /redfish/v1 without login.
20    [Tags]  GET_BMCweb_Hypermedia_Without_Login
21
22    redfish.Logout
23    ${resp}=  redfish.Get  ${EMPTY}
24    Should Be Equal As Strings  ${resp.status}  ${HTTP_OK}
25
26
27GET SessionService Resource With Login
28    [Documentation]  Login to BMCweb and get /redfish/v1/SessionService.
29    [Tags]  GET_SessionService_Resource_With_Login
30
31    redfish.Login
32    ${resp}=  redfish.Get  SessionService
33    Should Be Equal As Strings  ${resp.status}  ${HTTP_OK}
34
35
36GET SessionService Without Login
37    [Documentation]  Get /redfish/v1/SessionService without login
38    [Tags]  GET_SessionService_Without_Login
39
40    redfish.Logout
41    ${resp}=  redfish.Get  SessionService
42    Should Be Equal As Strings  ${resp.status}  ${HTTP_UNAUTHORIZED}
43
44
45Login Using Invalid Token
46    [Documentation]  Login to BMCweb with invalid token.
47    [Tags]  Login_Using_Invalid_Token
48
49    redfish.Logout
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 Session Using Valid login
64    [Documentation]  Delete a session using valid login.
65    [Tags]  Delete_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.Get  SessionService/Sessions
73
74    redfish.Delete  ${resp_list.dict["Members"][0]["@odata.id"]}
75
76    ${resp}=  redfish.Get  SessionService/Sessions
77    Should Not Contain  ${resp.dict["Members"]}  ${resp_list.dict["Members"][0]["@odata.id"]}
78
79