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 With Invalid Credentials
11    [Documentation]  Login to BMC web using invalid credential.
12    [Tags]  Redfish_Login_With_Invalid_Credentials
13    [Template]  Login And Verify Redfish Response
14
15    # Expect status            Username               Password
16    InvalidCredentialsError*   ${OPENBMC_USERNAME}    deadpassword
17    InvalidCredentialsError*   groot                  ${OPENBMC_PASSWORD}
18    InvalidCredentialsError*   ${EMPTY}               ${OPENBMC_PASSWORD}
19    InvalidCredentialsError*   ${OPENBMC_USERNAME}    ${EMPTY}
20    InvalidCredentialsError*   ${EMPTY}               ${EMPTY}
21
22
23Redfish Login Using Unsecured HTTP
24    [Documentation]  Login to BMC web through http unsecured.
25    [Tags]  Redfish_Login_Using_Unsecured_HTTP
26
27    Create Session  openbmc  http://${OPENBMC_HOST}
28    ${data}=  Create Dictionary
29    ...  UserName=${OPENBMC_USERNAME}  Password=${OPENBMC_PASSWORD}
30
31    ${headers}=  Create Dictionary  Content-Type=application/json
32
33    Run Keyword And Expect Error  *Connection refused*
34    ...  Post Request  openbmc  /redfish/v1/SessionService/Sessions
35    ...  data=${data}  headers=${headers}
36
37
38Redfish Login Using HTTPS Wrong Port 80 Protocol
39    [Documentation]  Login to BMC web through wrong protocol port 80.
40    [Tags]  Redfish_Login_Using_HTTPS_Wrong_Port_80_Protocol
41
42    Create Session  openbmc  https://${OPENBMC_HOST}:80
43    ${data}=  Create Dictionary
44    ...  UserName=${OPENBMC_USERNAME}  Password=${OPENBMC_PASSWORD}
45
46    ${headers}=  Create Dictionary  Content-Type=application/json
47
48    Run Keyword And Expect Error  *Connection refused*
49    ...  Post Request  openbmc  /redfish/v1/SessionService/Sessions
50    ...  data=${data}  headers=${headers}
51
52
53*** Keywords ***
54
55Login And Verify Redfish Response
56    [Documentation]  Login and verify redfish response.
57    [Arguments]  ${expected_response}  ${username}  ${password}
58
59    # Description of arguments:
60    # expected_response   Expected REST status.
61    # username            The username to be used to connect to the server.
62    # password            The password to be used to connect to the server.
63
64    ${data}=  Create Dictionary  username=${username}  password=${password}
65    Run Keyword And Expect Error  ${expected_response}  redfish.Login  ${data}
66