| Sweta Potthuri | 3925503 | 2018-03-28 10:12:14 -0500 | [diff] [blame] | 1 | *** Settings *** | 
|  | 2 | Documentation  Secure boot related test cases. | 
|  | 3 |  | 
| Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 4 | # Test Parameters: | 
|  | 5 | # FFDC_TOOL_DIR_PATH  The path to the directory containing FFDC translation | 
|  | 6 | #                     tools such as eSEL.pl. | 
|  | 7 |  | 
| George Keishing | a8b2549 | 2018-06-07 01:15:37 -0500 | [diff] [blame] | 8 | Resource          ../../lib/utils.robot | 
|  | 9 | Resource          ../../lib/boot_utils.robot | 
|  | 10 | Resource          ../../lib/secure_utils.robot | 
|  | 11 | Resource          ../../lib/open_power_utils.robot | 
|  | 12 | Resource          ../../lib/logging_utils.robot | 
|  | 13 | Resource          ../../lib/openbmc_ffdc_methods.robot | 
| Sweta Potthuri | 3925503 | 2018-03-28 10:12:14 -0500 | [diff] [blame] | 14 |  | 
| George Keishing | a8b2549 | 2018-06-07 01:15:37 -0500 | [diff] [blame] | 15 | Library           ../../lib/gen_misc.py | 
| Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 16 |  | 
|  | 17 | Suite Setup       Suite Setup Execution | 
| Sweta Potthuri | 3925503 | 2018-03-28 10:12:14 -0500 | [diff] [blame] | 18 | Test Setup        Test Setup Execution | 
|  | 19 | Test Teardown     Test Teardown Execution | 
|  | 20 |  | 
|  | 21 | *** Variables *** | 
|  | 22 |  | 
|  | 23 | ${security_access_bit_mask}  ${0xC000000000000000} | 
| Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 24 | # Description of BC8A1E07    A problem occurred during the IPL of the system. | 
|  | 25 | ${pnor_corruption_src}       BC8A1E07 | 
|  | 26 | ${bmc_image_dir_path}        /usr/local/share/pnor | 
| Lakshminarayana R. Kammath | 077fbf9 | 2019-02-20 11:15:18 -0600 | [diff] [blame^] | 27 | ${bmc_guard_dir_path}        /var/lib/phosphor-software-manager/pnor/prsv | 
| Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 28 | ${FFDC_TOOL_DIR_PATH}        ${EMPTY} | 
| Sweta Potthuri | 3925503 | 2018-03-28 10:12:14 -0500 | [diff] [blame] | 29 |  | 
|  | 30 | *** Test Cases *** | 
|  | 31 |  | 
|  | 32 | Validate Secure Boot With TPM Policy Disabled | 
|  | 33 | [Documentation]  Validate secure boot with TPM policy disabled. | 
|  | 34 | [Tags]  Validate_Secure_Boot_With_TPM_Policy_Disabled | 
|  | 35 |  | 
|  | 36 | Validate Secure Boot With TPM Policy Enabled Or Disabled  ${0} | 
|  | 37 |  | 
|  | 38 |  | 
|  | 39 | Validate Secure Boot With TPM Policy Enabled | 
|  | 40 | [Documentation]  Validate secure boot with TPM policy enabled. | 
|  | 41 | [Tags]  Validate_Secure_Boot_With_TPM_Policy_Enabled | 
|  | 42 |  | 
|  | 43 | Validate Secure Boot With TPM Policy Enabled Or Disabled  ${1} | 
|  | 44 |  | 
|  | 45 |  | 
| Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 46 | Violate Secure Boot Via Corrupt Key In SBE During Host Boot | 
|  | 47 | [Documentation]  Violate secure boot via corrupt key SBE during host boot. | 
|  | 48 | [Tags]  Violate_Secure_Boot_Via_Corrupt_Key_In_SBE_During_Host_Boot | 
|  | 49 |  | 
|  | 50 | Violate Secure Boot Via Corrupt Key | 
|  | 51 | ...  SBE  ${pnor_corruption_src}  ${bmc_image_dir_path} | 
|  | 52 |  | 
|  | 53 |  | 
| Sweta Potthuri | 3925503 | 2018-03-28 10:12:14 -0500 | [diff] [blame] | 54 | *** Keywords *** | 
|  | 55 |  | 
| Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 56 | Violate Secure Boot Via Corrupt Key | 
|  | 57 | [Documentation]  Cause secure boot violation during host boot | 
|  | 58 | ...  with corrupted key. | 
|  | 59 | [Arguments]  ${partition}  ${error_src}  ${bmc_image_dir_path} | 
|  | 60 |  | 
| Gunnar Mills | 7732c7e | 2018-08-14 11:54:24 -0500 | [diff] [blame] | 61 | # Description of argument(s): | 
| Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 62 | # partition            The partition which is to be corrupted | 
|  | 63 | #                      (e.g. "SBE", "HBI", "HBB", "HBRT", "HBBL", "OCC"). | 
|  | 64 | # error_src            The system reference code that is expected as a | 
|  | 65 | #                      result of the secure boot violation | 
|  | 66 | #                      (e.g. "BC8A1E07"). | 
|  | 67 | # bmc_image_dir_path   BMC image path. | 
|  | 68 |  | 
|  | 69 | Set And Verify TPM Policy  ${1} | 
|  | 70 |  | 
|  | 71 | # Descipiton: | 
|  | 72 | # Cause a secure boot violation by copying an BMC image file to the | 
|  | 73 | # target BMC and then starting a power on. | 
|  | 74 | # This action should result in: | 
|  | 75 | # 1) an error log entry | 
|  | 76 | # 2) the system going to "Quiesced" state. | 
|  | 77 |  | 
|  | 78 | # Load corrupted image to /usr/local/share/pnor. | 
|  | 79 | Open Connection For SCP | 
|  | 80 | Log  ${bmc_image_dir_path} | 
|  | 81 | scp.Put File | 
|  | 82 | ...  ${EXEC_DIR}/data/pnor_test_data/${partition}  ${bmc_image_dir_path} | 
|  | 83 |  | 
|  | 84 | # Starting a power on. | 
|  | 85 | BMC Execute Command  /usr/sbin/obmcutil poweron | 
|  | 86 | Wait Until Keyword Succeeds  10 min  10 sec  Error Logs Should Exist | 
|  | 87 |  | 
|  | 88 | Wait Until Keyword Succeeds  10 min  10 sec  Collect Error Logs and Verify SRC  ${error_src} | 
|  | 89 |  | 
|  | 90 | # Remove the file from /usr/local/share/pnor/. | 
|  | 91 | BMC Execute Command  rm -rf ${bmc_image_dir_path}* | 
|  | 92 |  | 
|  | 93 | # Check if system reaches quiesce state. | 
|  | 94 | Run Keywords | 
|  | 95 | ...  Wait Until Keyword Succeeds  3 min  5 sec  Is Host Quiesced  AND | 
|  | 96 | ...  Recover Quiesced Host | 
|  | 97 |  | 
|  | 98 |  | 
|  | 99 | Collect Error Logs and Verify SRC | 
|  | 100 | [Documentation]  Collect error logs and verify src. | 
|  | 101 | [Arguments]  ${system_reference_code} | 
|  | 102 |  | 
|  | 103 | # Description of argument(s): | 
|  | 104 | # system_reference_code  The system reference code that the caller | 
|  | 105 | #                        expects to be found among the existing | 
|  | 106 | #                        error log entries (e.g. "BC8A1E07"). | 
|  | 107 | # system_reference_code  Src code. | 
|  | 108 |  | 
|  | 109 | Convert eSEL To Elog Format  ${FFDC_TOOL_DIR_PATH} | 
|  | 110 |  | 
|  | 111 | ${cmd}=  Catenate | 
|  | 112 | ...  grep -i ${system_reference_code} ${FFDC_TOOL_DIR_PATH}/esel.out.txt | 
|  | 113 | ${rc}  ${output}=  Run and Return RC and Output  ${cmd} | 
|  | 114 | Should Be Equal  ${rc}  ${0} | 
|  | 115 | ...  msg=${system_reference_code} not found in the existing error logs. | 
|  | 116 |  | 
|  | 117 |  | 
| Sweta Potthuri | 3925503 | 2018-03-28 10:12:14 -0500 | [diff] [blame] | 118 | Get And Verify Security Access Bit | 
|  | 119 | [Documentation]  Get and verify security access bit. | 
|  | 120 | [Arguments]  ${sol_log_file_path} | 
|  | 121 |  | 
|  | 122 | # Description of argument(s): | 
|  | 123 | # sol_log_file_path  The path to the file containing SOL data | 
|  | 124 | #                    which was collected during a REST Power On. | 
|  | 125 |  | 
|  | 126 | # Sample output: | 
|  | 127 | #  19.68481|SECURE|Security Access Bit> 0xC000000000000000 | 
|  | 128 |  | 
|  | 129 | ${cmd}=  Catenate | 
|  | 130 | ...  grep "Security Access Bit"  ${sol_log_file_path} | awk '{ print $4 }' | 
|  | 131 | ${rc}  ${security_access_bit_str}=  Run and Return RC and Output  ${cmd} | 
|  | 132 | Should Be Equal  ${rc}  ${0} | 
|  | 133 | ...  msg=Return code from ${cmd} not zero. | 
|  | 134 |  | 
|  | 135 | # Verify the value of "Security Access Bit". | 
|  | 136 |  | 
|  | 137 | ${security_access_bit}=  Convert to Integer  ${security_access_bit_str} | 
|  | 138 | ${result}=  Evaluate  ${security_access_bit_mask} & ${security_access_bit} | 
|  | 139 | Should Be Equal  ${result}  ${security_access_bit_mask} | 
|  | 140 | ...  msg=System is not booted in secure mode.  values=False | 
|  | 141 |  | 
|  | 142 |  | 
|  | 143 | Validate Secure Boot With TPM Policy Enabled Or Disabled | 
|  | 144 | [Documentation]  Validate secure boot with TPM policy enabled or disabled. | 
|  | 145 | [Arguments]  ${tpm_policy} | 
|  | 146 |  | 
|  | 147 | # Description of argument(s): | 
|  | 148 | # tpm_policy  Enable-0 or Disable-1. | 
|  | 149 |  | 
|  | 150 | Set And Verify TPM Policy  ${tpm_policy} | 
|  | 151 | REST Power On  quiet=1 | 
|  | 152 | Validate Secure Boot  ${sol_log_file_path} | 
|  | 153 |  | 
|  | 154 |  | 
|  | 155 | Validate Secure Boot | 
|  | 156 | [Documentation]  Validate secure boot. | 
|  | 157 | [Arguments]  ${sol_log_file_path} | 
|  | 158 |  | 
|  | 159 | # Description of argument(s): | 
|  | 160 | # sol_log_file_path  The path to the file containing SOL data | 
|  | 161 | #                    which was collected during a REST Power On. | 
|  | 162 |  | 
|  | 163 | Get And Verify Security Access Bit  ${sol_log_file_path} | 
|  | 164 | Error Logs Should Not Exist | 
|  | 165 | REST Verify No Gard Records | 
|  | 166 |  | 
|  | 167 |  | 
| Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 168 | Suite Setup Execution | 
|  | 169 | [Documentation]  Suite Setup Execution | 
|  | 170 |  | 
|  | 171 | Run  export PATH=$PATH:${FFDC_TOOL_DIR_PATH} | 
|  | 172 | Set Environment Variable  ${FFDC_TOOL_DIR_PATH}  ${FFDC_TOOL_DIR_PATH} | 
|  | 173 | ${bmc_image_dir_path}=  Add Trailing Slash  ${bmc_image_dir_path} | 
| Lakshminarayana R. Kammath | 077fbf9 | 2019-02-20 11:15:18 -0600 | [diff] [blame^] | 174 | ${bmc_guard_dir_path}=  Add Trailing Slash  ${bmc_guard_dir_path} | 
|  | 175 |  | 
| Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 176 | Set Global Variable  ${bmc_image_dir_path} | 
|  | 177 | Log  ${bmc_image_dir_path} | 
|  | 178 | BMC Execute Command  rm -rf ${bmc_image_dir_path}* | 
|  | 179 |  | 
| Lakshminarayana R. Kammath | 077fbf9 | 2019-02-20 11:15:18 -0600 | [diff] [blame^] | 180 | Set Global Variable  ${bmc_guard_dir_path} | 
|  | 181 | Log  ${bmc_guard_dir_path} | 
|  | 182 | BMC Execute Command  rm -rf ${bmc_guard_dir_path}* | 
|  | 183 |  | 
| Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 184 |  | 
| Sweta Potthuri | 3925503 | 2018-03-28 10:12:14 -0500 | [diff] [blame] | 185 | Test Setup Execution | 
|  | 186 | [Documentation]  Test setup execution. | 
|  | 187 |  | 
|  | 188 | ${timestamp}=  Get Current Date  result_format=%Y%m%d%H%M%S | 
|  | 189 | ${sol_log_file_path}=  Catenate  ${EXECDIR}/Secure_SOL${timestamp} | 
|  | 190 | Start SOL Console Logging  ${sol_log_file_path} | 
|  | 191 | Set Suite Variable  ${sol_log_file_path} | 
|  | 192 |  | 
|  | 193 | REST Power Off  stack_mode=skip  quiet=1 | 
|  | 194 | Delete Error Logs And Verify | 
| Lakshminarayana R. Kammath | 077fbf9 | 2019-02-20 11:15:18 -0600 | [diff] [blame^] | 195 |  | 
| Sweta Potthuri | 3925503 | 2018-03-28 10:12:14 -0500 | [diff] [blame] | 196 |  | 
|  | 197 |  | 
|  | 198 | Test Teardown Execution | 
|  | 199 | [Documentation]  Test teardown execution. | 
|  | 200 |  | 
|  | 201 | Stop SOL Console Logging | 
|  | 202 | Run  rm -rf ${sol_log_file_path} | 
| Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 203 |  | 
|  | 204 | # Removing the corrupted file from BMC. | 
|  | 205 | BMC Execute Command  rm -rf ${bmc_image_dir_path}* |