manashsarma | 148e36c | 2021-08-16 07:15:18 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation This suite is to test service user login functionality. |
| 3 | ... This test expects SERVICE_FILE_PATH, PRODUCTION_KEY_FILE_PATH and |
| 4 | ... SERVICE_USER_PASSWORD to be provided. |
| 5 | ... |
| 6 | ... Execution Method : |
| 7 | ... python -m robot -v OPENBMC_HOST:<hostname> -v SERVICE_FILE_PATH:<service file path> |
| 8 | ... -v PRODUCTION_KEY_FILE_PATH:<production key file path> |
| 9 | ... -v SERVICE_USER_PASSWORD:<service user password> |
| 10 | ... openpower/service_account/test_service_login.robot |
| 11 | |
| 12 | Resource ../../lib/connection_client.robot |
| 13 | Resource ../../lib/openbmc_ffdc.robot |
| 14 | Resource ../../lib/bmc_redfish_utils.robot |
| 15 | |
| 16 | Library SSHLibrary |
| 17 | |
| 18 | Suite Setup Suite Setup Execution |
| 19 | Test Teardown FFDC On Test Case Fail |
| 20 | |
| 21 | |
| 22 | *** Variables *** |
| 23 | |
| 24 | ${acf_dir} /etc/acf |
| 25 | |
| 26 | *** Test Cases *** |
| 27 | |
| 28 | Verify Service User Login With Valid ACF file |
| 29 | [Documentation] Verify service user login with valid ACF file. |
| 30 | [Tags] Verify_Service_User_Login_With_Valid_ACF_file |
| 31 | |
| 32 | Upload Valid ACF |
| 33 | Redfish.Login service ${SERVICE_USER_PASSWORD} |
| 34 | |
| 35 | |
| 36 | Verify Service User Login Without ACF file |
| 37 | [Documentation] Verify service user login without ACF file. |
| 38 | [Tags] Verify_Service_User_Login_Without_ACF_file |
| 39 | |
| 40 | Remove Existing ACF |
| 41 | Run Keyword And Expect Error InvalidCredentialsError* |
| 42 | ... Redfish.Login service ${SERVICE_USER_PASSWORD} |
| 43 | |
| 44 | |
manashsarma | 3746be3 | 2021-11-10 06:32:31 -0600 | [diff] [blame] | 45 | Verify Service User SSH Login Without ACF file |
| 46 | [Documentation] Verify service user ssh login failure without ACF file. |
| 47 | [Tags] Verify_Service_User_SSH_Login_Without_ACF_file |
| 48 | |
| 49 | Remove Existing ACF |
| 50 | SSHLibrary.Open Connection ${OPENBMC_HOST} |
| 51 | ${status}= Run Keyword And Return Status SSHLibrary.Login service ${SERVICE_USER_PASSWORD} |
| 52 | Should Be Equal ${status} ${False} |
| 53 | |
| 54 | |
manashsarma | e7b973f | 2021-08-20 06:49:32 -0500 | [diff] [blame] | 55 | Verify Service Login Failure With Expired ACF |
| 56 | [Documentation] Verify service user login failure with expired ACF. |
| 57 | [Tags] Verify_Service_Login_Failure_With_Expired_ACF |
| 58 | [Setup] Valid Value EXPIRED_SERVICE_FILE_PATH |
| 59 | |
| 60 | Remove Existing ACF |
| 61 | Open Connection for SCP |
| 62 | scp.Put File ${EXPIRED_SERVICE_FILE_PATH} ${acf_dir} |
| 63 | Run Keyword And Expect Error InvalidCredentialsError* |
manashsarma | 75b58fe | 2021-08-20 09:01:32 -0500 | [diff] [blame] | 64 | ... Redfish.Login service ${SERVICE_USER_PASSWORD} |
| 65 | |
| 66 | |
| 67 | Verify Service Login Failure With Incorrect Password |
| 68 | [Documentation] Verify service login failure with incorrect password. |
| 69 | [Tags] Verify_Service_Login_Failure_With_Incorrect_Password |
| 70 | |
| 71 | Remove Existing ACF |
| 72 | Upload Valid ACF |
| 73 | ${incorrect_service_password} = Catenate SEPARATOR= ${SERVICE_USER_PASSWORD} 123 |
| 74 | Run Keyword And Expect Error InvalidCredentialsError* |
| 75 | ... Redfish.Login service ${incorrect_service_password} |
manashsarma | e7b973f | 2021-08-20 06:49:32 -0500 | [diff] [blame] | 76 | |
| 77 | |
manashsarma | 99eb108 | 2021-09-21 09:30:06 -0500 | [diff] [blame] | 78 | Verify SSH Login Access With Service User |
| 79 | [Documentation] Verify SSH login access with service user. |
| 80 | [Tags] Verify_SSH_Login_Access_With_Service_User |
| 81 | [Setup] Remove Existing ACF AND Upload Valid ACF |
| 82 | |
| 83 | # Attempt SSH login with service user. |
| 84 | SSHLibrary.Open Connection ${OPENBMC_HOST} |
| 85 | ${status}= Run Keyword And Return Status SSHLibrary.Login service ${SERVICE_USER_PASSWORD} |
| 86 | Should Be Equal ${status} ${True} |
| 87 | |
| 88 | |
manashsarma | 9f0eff4 | 2021-09-22 09:12:41 -0500 | [diff] [blame] | 89 | Verify SSH Login Failure With Incorrect Service User Password |
| 90 | [Documentation] Verify SSH login failure with incorrect service user password. |
| 91 | [Tags] Verify_SSH_Login_Failure_With_Incorrect_Service_User_Password |
| 92 | [Setup] Remove Existing ACF AND Upload Valid ACF |
| 93 | |
| 94 | # Attempt SSH login with service user. |
| 95 | SSHLibrary.Open Connection ${OPENBMC_HOST} |
| 96 | # Attempt login with invalid password |
| 97 | ${status}= Run Keyword And Return Status SSHLibrary.Login service ${SERVICE_USER_PASSWORD}123 |
| 98 | Should Be Equal ${status} ${False} |
| 99 | |
| 100 | |
manashsarma | 0f74c80 | 2021-11-10 04:37:02 -0600 | [diff] [blame] | 101 | Verify Service User Sets Admin Password |
| 102 | [Documentation] Verify that service user can update admin password. |
| 103 | [Tags] Verify_Service_User_Sets_Admin_Password |
| 104 | [Teardown] Restore Admin Password |
| 105 | |
| 106 | Redfish.Login service ${SERVICE_USER_PASSWORD} |
| 107 | |
| 108 | # Update admin user password using Redfish. |
| 109 | ${payload}= Create Dictionary Password=NewTestPwd123 |
| 110 | Redfish.Patch /redfish/v1/AccountService/Accounts/admin body=&{payload} |
| 111 | ... valid_status_codes=[${HTTP_OK}] |
| 112 | |
manashsarma | 148e36c | 2021-08-16 07:15:18 -0500 | [diff] [blame] | 113 | *** Keywords *** |
| 114 | |
| 115 | Suite Setup Execution |
| 116 | [Documentation] Do suite setup tasks. |
| 117 | |
| 118 | # Upload production key in BMC because it is not part of OpenBMC build yet. |
manashsarma | e7b973f | 2021-08-20 06:49:32 -0500 | [diff] [blame] | 119 | Open Connection for SCP |
manashsarma | 148e36c | 2021-08-16 07:15:18 -0500 | [diff] [blame] | 120 | scp.Put File ${PRODUCTION_KEY_FILE_PATH} ${acf_dir} |
| 121 | |
| 122 | |
| 123 | Remove Existing ACF |
| 124 | [Documentation] Remove existing ACF. |
| 125 | |
| 126 | BMC Execute Command rm -f ${acf_dir}/*.acf |
| 127 | |
manashsarma | 148e36c | 2021-08-16 07:15:18 -0500 | [diff] [blame] | 128 | Upload Valid ACF |
| 129 | [Documentation] Upload valid ACF. |
| 130 | |
| 131 | Run Keywords Open Connection for SCP |
| 132 | scp.Put File ${SERVICE_FILE_PATH} ${acf_dir} |
manashsarma | 0f74c80 | 2021-11-10 04:37:02 -0600 | [diff] [blame] | 133 | |
| 134 | |
| 135 | Restore Admin Password |
| 136 | [Documentation] Restore original password of admin user. |
| 137 | |
| 138 | ${payload}= Create Dictionary Password=${OPENBMC_ADMIN_PASSWORD} |
| 139 | Redfish.Patch /redfish/v1/AccountService/Accounts/admin body=&{payload} |
| 140 | ... valid_status_codes=[${HTTP_OK}] |