Sivas SRR | 7d7bae3 | 2019-05-29 00:31:14 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Test Redfish LDAP user configuration. |
| 3 | |
Sivas SRR | d21c984 | 2019-06-21 05:41:18 -0500 | [diff] [blame^] | 4 | Library ../../lib/gen_robot_valid.py |
Sivas SRR | 7d7bae3 | 2019-05-29 00:31:14 -0500 | [diff] [blame] | 5 | Resource ../../lib/resource.robot |
| 6 | Resource ../../lib/bmc_redfish_resource.robot |
| 7 | Resource ../../lib/openbmc_ffdc.robot |
Sivas SRR | f4ec649 | 2019-06-16 01:59:30 -0500 | [diff] [blame] | 8 | Library ../../lib/gen_robot_valid.py |
Sivas SRR | 7d7bae3 | 2019-05-29 00:31:14 -0500 | [diff] [blame] | 9 | |
| 10 | Suite Setup Suite Setup Execution |
Sivas SRR | f4ec649 | 2019-06-16 01:59:30 -0500 | [diff] [blame] | 11 | Suite Teardown Redfish.Logout |
| 12 | Test Teardown FFDC On Test Case Fail |
Sivas SRR | 7d7bae3 | 2019-05-29 00:31:14 -0500 | [diff] [blame] | 13 | |
Sivas SRR | 9358b5c | 2019-06-06 04:57:03 -0500 | [diff] [blame] | 14 | Force Tags LDAP_Test |
| 15 | |
Sivas SRR | f4ec649 | 2019-06-16 01:59:30 -0500 | [diff] [blame] | 16 | *** Variables *** |
| 17 | ${old_ldap_privilege} ${EMPTY} |
Sivas SRR | d21c984 | 2019-06-21 05:41:18 -0500 | [diff] [blame^] | 18 | &{old_account_service} &{EMPTY} |
Sivas SRR | f4ec649 | 2019-06-16 01:59:30 -0500 | [diff] [blame] | 19 | |
Sivas SRR | 7d7bae3 | 2019-05-29 00:31:14 -0500 | [diff] [blame] | 20 | ** Test Cases ** |
| 21 | |
| 22 | Verify LDAP Configuration Exist |
| 23 | [Documentation] Verify LDAP configuration is available. |
| 24 | [Tags] Verify_LDAP_Configuration_Exist |
| 25 | |
| 26 | ${resp}= Redfish.Get Attribute ${REDFISH_BASE_URI}AccountService |
| 27 | ... ${LDAP_TYPE} default=${EMPTY} |
| 28 | Should Not Be Empty ${resp} msg=LDAP configuration is not defined. |
| 29 | |
| 30 | |
| 31 | Verify LDAP User Login |
| 32 | [Documentation] Verify LDAP user able to login into BMC. |
| 33 | [Tags] Verify_LDAP_User_Login |
| 34 | |
| 35 | ${resp}= Run Keyword And Return Status Redfish.Login ${LDAP_USER} |
| 36 | ... ${LDAP_USER_PASSWORD} |
| 37 | Should Be Equal ${resp} ${True} msg=LDAP user is not able to login. |
| 38 | redfish.Logout |
| 39 | |
| 40 | |
| 41 | Verify LDAP Service Available |
| 42 | [Documentation] Verify LDAP service is available. |
| 43 | [Tags] Verify_LDAP_Service_Available |
| 44 | |
| 45 | @{ldap_configuration}= Get LDAP Configuration ${LDAP_TYPE} |
| 46 | Should Contain ${ldap_configuration} LDAPService |
| 47 | ... msg=LDAPService is not available. |
| 48 | |
| 49 | |
Sivas SRR | 108f9d3 | 2019-06-03 10:05:34 -0500 | [diff] [blame] | 50 | Verify LDAP Login Works After BMC Reboot |
| 51 | [Documentation] Verify LDAP login works after BMC reboot. |
| 52 | [Tags] Verify_LDAP_Login_Works_After_BMC_Reboot |
| 53 | |
| 54 | Redfish OBMC Reboot (off) |
| 55 | Redfish.Login ${LDAP_USER} ${LDAP_USER_PASSWORD} |
| 56 | Redfish.Logout |
| 57 | |
| 58 | |
| 59 | Verify LDAP User With Admin Privilege Able To Do BMC Reboot |
| 60 | [Documentation] Verify LDAP user with administrator privilege able to do BMC reboot. |
| 61 | [Tags] Verify_LDAP_User_With_Admin_Privilege_Able_To_Do_BMC_Reboot |
| 62 | |
| 63 | |
| 64 | Update LDAP Configuration with LDAP User Role And Group ${LDAP_TYPE} |
| 65 | ... ${GROUP_PRIVILEGE} ${GROUP_NAME} |
| 66 | Redfish.Login ${LDAP_USER} ${LDAP_USER_PASSWORD} |
| 67 | # With LDAP user and with right privilege trying to do BMC reboot. |
| 68 | Redfish OBMC Reboot (off) |
| 69 | Redfish.Login ${LDAP_USER} ${LDAP_USER_PASSWORD} |
| 70 | Redfish.Logout |
| 71 | |
| 72 | |
Sivas SRR | f4ec649 | 2019-06-16 01:59:30 -0500 | [diff] [blame] | 73 | Verify LDAP User With Operator Privilege Able To Do Host Poweron |
| 74 | [Documentation] Verify LDAP user with operator privilege able to do host up. |
| 75 | [Tags] Verify_LDAP_User_With_Operator_Privilege_Able_To_Do_Host_Poweron |
| 76 | [Teardown] Restore LDAP Privilege |
| 77 | |
| 78 | ${old_ldap_privilege}= Get LDAP Privilege |
| 79 | Update LDAP Configuration with LDAP User Role And Group ${LDAP_TYPE} |
| 80 | ... Operator ${GROUP_NAME} |
| 81 | # Provide adequate time for LDAP daemon to restart after the update. |
| 82 | Sleep 10s |
| 83 | |
| 84 | ${ldap_config}= Redfish.Get Properties ${REDFISH_BASE_URI}AccountService |
| 85 | ${new_ldap_privilege}= Set Variable |
| 86 | ... ${ldap_config["LDAP"]["RemoteRoleMapping"][0]["LocalRole"]} |
| 87 | Should Be Equal ${new_ldap_privilege} Operator |
| 88 | Redfish.Login ${LDAP_USER} ${LDAP_USER_PASSWORD} |
| 89 | # Verify that the LDAP user with operator privilege is able to power the system on. |
| 90 | Redfish Power On |
| 91 | Redfish.Logout |
| 92 | |
| 93 | |
Sivas SRR | d21c984 | 2019-06-21 05:41:18 -0500 | [diff] [blame^] | 94 | Verify AccountLockout Attributes Set To Zero |
| 95 | [Documentation] Verify attribute AccountLockoutDuration and |
| 96 | ... AccountLockoutThreshold are set to 0. |
| 97 | [Teardown] Run Keywords Restore AccountLockout Attributes AND |
| 98 | ... FFDC On Test Case Fail |
| 99 | [Tags] Verify_AccountLockout_Attributes_Set_To_Zero |
| 100 | |
| 101 | ${old_account_service}= Redfish.Get Properties |
| 102 | ... ${REDFISH_BASE_URI}AccountService |
| 103 | Rprint Vars old_account_service fmt=terse |
| 104 | Redfish.Patch ${REDFISH_BASE_URI}AccountService |
| 105 | ... body=[('AccountLockoutDuration', 0)] |
| 106 | Redfish.Patch ${REDFISH_BASE_URI}AccountService |
| 107 | ... body=[('AccountLockoutThreshold', 0)] |
| 108 | |
| 109 | |
Sivas SRR | 7d7bae3 | 2019-05-29 00:31:14 -0500 | [diff] [blame] | 110 | *** Keywords *** |
Sivas SRR | d21c984 | 2019-06-21 05:41:18 -0500 | [diff] [blame^] | 111 | |
| 112 | Restore AccountLockout Attributes |
| 113 | [Documentation] Restore AccountLockout Attributes. |
| 114 | |
| 115 | Return From Keyword If &{old_account_service} == &{EMPTY} |
| 116 | Redfish.Patch ${REDFISH_BASE_URI}AccountService |
| 117 | ... body=[('AccountLockoutDuration', ${old_account_service['AccountLockoutDuration']})] |
| 118 | Redfish.Patch ${REDFISH_BASE_URI}AccountService |
| 119 | ... body=[('AccountLockoutDuration', ${old_account_service['AccountLockoutThreshold']})] |
| 120 | |
| 121 | |
Sivas SRR | 7d7bae3 | 2019-05-29 00:31:14 -0500 | [diff] [blame] | 122 | Suite Setup Execution |
| 123 | [Documentation] Do suite setup tasks. |
| 124 | |
Sivas SRR | d21c984 | 2019-06-21 05:41:18 -0500 | [diff] [blame^] | 125 | Rvalid Value LDAP_TYPE valid_values=["ActiveDirectory", "LDAP"] |
Sivas SRR | f4ec649 | 2019-06-16 01:59:30 -0500 | [diff] [blame] | 126 | Rvalid Value LDAP_USER |
| 127 | Rvalid Value LDAP_USER_PASSWORD |
| 128 | Rvalid Value GROUP_PRIVILEGE |
| 129 | Rvalid Value GROUP_NAME |
| 130 | Redfish.Login |
| 131 | # Call 'Get LDAP Configuration' to verify that LDAP configuration exists. |
Sivas SRR | 7d7bae3 | 2019-05-29 00:31:14 -0500 | [diff] [blame] | 132 | Get LDAP Configuration ${LDAP_TYPE} |
Sivas SRR | 7d7bae3 | 2019-05-29 00:31:14 -0500 | [diff] [blame] | 133 | |
| 134 | |
Sivas SRR | d21c984 | 2019-06-21 05:41:18 -0500 | [diff] [blame^] | 135 | Test Teardown Execution |
| 136 | [Documentation] Do the post test teardown. |
| 137 | FFDC On Test Case Fail |
| 138 | Redfish.Logout |
| 139 | |
| 140 | |
Sivas SRR | 7d7bae3 | 2019-05-29 00:31:14 -0500 | [diff] [blame] | 141 | Get LDAP Configuration |
| 142 | [Documentation] Retrieve LDAP Configuration. |
| 143 | [Arguments] ${ldap_type} |
| 144 | |
| 145 | # Description of argument(s): |
| 146 | # ldap_type The LDAP type ("ActiveDirectory" or "LDAP"). |
| 147 | |
| 148 | ${ldap_config}= Redfish.Get Properties ${REDFISH_BASE_URI}AccountService |
| 149 | [Return] ${ldap_config["${ldap_type}"]} |
Sivas SRR | 108f9d3 | 2019-06-03 10:05:34 -0500 | [diff] [blame] | 150 | |
| 151 | |
| 152 | Update LDAP Configuration with LDAP User Role And Group |
| 153 | [Documentation] Update LDAP configuration update with LDAP user Role and group. |
| 154 | [Arguments] ${ldap_type} ${group_privilege} ${group_name} |
| 155 | |
| 156 | # Description of argument(s): |
| 157 | # ldap_type The LDAP type ("ActiveDirectory" or "LDAP"). |
| 158 | # group_privilege The group privilege ("Administrator", "Operator", "User" or "Callback"). |
| 159 | # group_name The group name of user. |
| 160 | |
| 161 | ${local_role_remote_group}= Create Dictionary LocalRole=${group_privilege} RemoteGroup=${group_name} |
| 162 | ${remote_role_mapping}= Create List ${local_role_remote_group} |
| 163 | ${ldap_data}= Create Dictionary RemoteRoleMapping=${remote_role_mapping} |
| 164 | ${payload}= Create Dictionary ${ldap_type}=${ldap_data} |
| 165 | Redfish.Patch ${REDFISH_BASE_URI}AccountService body=&{payload} |
| 166 | |
Sivas SRR | f4ec649 | 2019-06-16 01:59:30 -0500 | [diff] [blame] | 167 | |
| 168 | Get LDAP Privilege |
| 169 | [Documentation] Get LDAP privilege and return it. |
| 170 | |
| 171 | ${ldap_config}= Get LDAP Configuration ${LDAP_TYPE} |
| 172 | [Return] ${ldap_config["RemoteRoleMapping"][0]["LocalRole"]} |
| 173 | |
| 174 | |
| 175 | Restore LDAP Privilege |
| 176 | [Documentation] Restore the LDAP privilege to its original value. |
| 177 | |
| 178 | # Login back to update the original privilege. |
| 179 | Redfish.Login |
| 180 | Update LDAP Configuration with LDAP User Role And Group ${LDAP_TYPE} |
| 181 | ... ${old_ldap_privilege} ${GROUP_NAME} |
| 182 | FFDC On Test Case Fail |
| 183 | Redfish.Logout |