openbmc / openbmc-test-automation

Apache License 2.0
100 stars 92 forks source link

Redfish Login With Invalid Credentials #2195

Closed MickDaDa closed 1 year ago

MickDaDa commented 1 year ago

https://github.com/openbmc/openbmc-test-automation/blob/177b459a07390f1b6b7a55e1bf867b0b9a14f95f/redfish/service_root/test_service_root_security.robot#L33

If library redfish is 3.1.7** Only ${EMPTY} account or password Should change " InvalidCredentialsError* " to " *SessionCreationError "

InvalidCredentialsError ${EMPTY} ${OPENBMC_PASSWORD} InvalidCredentialsError ${OPENBMC_USERNAME} ${EMPTY} InvalidCredentialsError* ${EMPTY} ${EMPTY}


SessionCreationError ${EMPTY} ${OPENBMC_PASSWORD} SessionCreationError ${OPENBMC_USERNAME} ${EMPTY} SessionCreationError* ${EMPTY} ${EMPTY}

gkeishin commented 1 year ago

Thank you for the feedback. Let me try to amend the code to handle both.

gkeishin commented 1 year ago
*** Test Cases ***
Check for Error
    ${msg}=  Run Keyword And Expect Error  *  My Error Response
    Should Contain Any  ${msg}  sample1  sample2

*** Keywords ***

My Error Response

  Fail  sample1
  #Fail  sample2
  #Fail  dontexist

I can handle this with old and new message formatting , so that user doesn't need to worry about older or newer versions

gkeishin commented 1 year ago
pip3 list  | grep redfish
redfish                         3.1.6
==============================================================================
Test Service Root Security :: Test Redfish service root login security.
==============================================================================
Redfish Login With Invalid Credentials :: Login to BMC web using i...
.<class 'redfish.rest.v1.InvalidCredentialsError'>
0
Re-try login due to exception and it is likely error response from server side.
.<class 'redfish.rest.v1.InvalidCredentialsError'>
0
Re-try login due to exception and it is likely error response from server side.
.<class 'redfish.rest.v1.InvalidCredentialsError'>
0
Re-try login due to exception and it is likely error response from server side.
.<class 'redfish.rest.v1.InvalidCredentialsError'>
0
Re-try login due to exception and it is likely error response from server side.
.<class 'redfish.rest.v1.InvalidCredentialsError'>
0
Re-try login due to exception and it is likely error response from server side.
Redfish Login With Invalid Credentials :: Login to BMC web using i... | PASS |
------------------------------------------------------------------------------
Test Service Root Security :: Test Redfish service root login secu... | PASS |
1 test, 1 passed, 0 failed
==============================================================================
$ pip3 list  | grep redfish
redfish                            3.1.7
==============================================================================
Test Service Root Security :: Test Redfish service root login security.
==============================================================================
Redfish Login With Invalid Credentials :: Login to BMC web using i...
.<class 'redfish.rest.v1.InvalidCredentialsError'>
HTTP 401 Unauthorized returned: Invalid credentials supplied
Re-try login due to exception and it is likely error response from server side.
.<class 'redfish.rest.v1.InvalidCredentialsError'>
HTTP 401 Unauthorized returned: Invalid credentials supplied
Re-try login due to exception and it is likely error response from server side.
Redfish Login With Invalid Credentials :: Login to BMC web using i... | PASS |
------------------------------------------------------------------------------
Test Service Root Security :: Test Redfish service root login secu... | PASS |
1 test, 1 passed, 0 failed
==============================================================================
gkeishin commented 1 year ago

@MickDaDa Fix up for review https://gerrit.openbmc.org/c/openbmc/openbmc-test-automation/+/57363