1*** Settings *** 2Documentation Test Redfish user account. 3 4Resource ../../lib/resource.robot 5Resource ../../lib/bmc_redfish_resource.robot 6Resource ../../lib/openbmc_ffdc.robot 7 8Test Setup Test Setup Execution 9Test Teardown Test Teardown Execution 10 11 12** Test Cases ** 13 14Verify AccountService Available 15 [Documentation] Verify Redfish account service is available. 16 [Tags] Verify_AccountService_Available 17 18 ${resp} = Redfish_utils.Get Attribute /redfish/v1/AccountService ServiceEnabled 19 Should Be Equal As Strings ${resp} ${True} 20 21Redfish Create and Verify Users 22 [Documentation] Create Redfish users with various roles 23 [Tags] Redfish_Create_and_Verify_Users 24 [Template] Redfish Create And Verify User 25 26 # username password role_id enabled 27 admin_user TestPwd123 Administrator ${True} 28 operator_user TestPwd123 Operator ${True} 29 user_user TestPwd123 User ${True} 30 callback_user TestPwd123 Callback ${True} 31 32Verify Redfish User with Wrong Password 33 [Documentation] Verify Redfish User with Wrong Password 34 [Tags] Verify_Redfish_User_with_Wrong_Password 35 [Template] Verify Redfish User with Wrong Password 36 37 # username password role_id enabled wrong_password 38 admin_user TestPwd123 Administrator ${True} alskjhfwurh 39 operator_user TestPwd123 Operator ${True} 12j8a8uakjhdaosiruf024 40 user_user TestPwd123 User ${True} 12 41 callback_user TestPwd123 Callback ${True} !#@D#RF#@!D 42 43 44*** Keywords *** 45 46Test Setup Execution 47 [Documentation] Do test case setup tasks. 48 49 Redfish.Login 50 51 52Test Teardown Execution 53 [Documentation] Do the post test teardown. 54 55 FFDC On Test Case Fail 56 Redfish.Logout 57 58Redfish Create And Verify User 59 [Documentation] Redfish create and verify user. 60 [Arguments] ${username} ${password} ${role_id} ${enabled} 61 62 # Description of argument(s): 63 # username The username to be created. 64 # password The password to be assigned. 65 # role_id The role id of the user to be created. 66 # enabled The decision if it should be enabled. 67 68 # Example: 69 #{ 70 #"@odata.context": "/redfish/v1/$metadata#ManagerAccount.ManagerAccount", 71 #"@odata.id": "/redfish/v1/AccountService/Accounts/test1", 72 #"@odata.type": "#ManagerAccount.v1_0_3.ManagerAccount", 73 #"Description": "User Account", 74 #"Enabled": true, 75 #"Id": "test1", 76 #"Links": { 77 # "Role": { 78 # "@odata.id": "/redfish/v1/AccountService/Roles/Administrator" 79 # } 80 #}, 81 82 # Delete if the user exist. 83 Run Keyword And Ignore Error 84 ... Redfish.Delete /redfish/v1/AccountService/Accounts/${userName} 85 86 # Create specified user. 87 ${payload}= Create Dictionary 88 ... UserName=${username} Password=${password} RoleId=${role_id} Enabled=${enabled} 89 Redfish.Post /redfish/v1/AccountService/Accounts body=&{payload} 90 ... valid_status_codes=[${HTTP_CREATED}] 91 92 Redfish.Logout 93 94 # Login with created user. 95 Redfish.Login ${username} ${password} 96 97 # Validate Role Id of created user. 98 ${role_config}= Redfish_Utils.Get Attribute 99 ... /redfish/v1/AccountService/Accounts/${userName} RoleId 100 Should Be Equal ${role_id} ${role_config} 101 102 Redfish.Get /redfish/v1/AccountService/Accounts/${userName} 103 104 # Delete Specified User 105 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName} 106 107Verify Redfish User with Wrong Password 108 [Documentation] Verify Redfish User with Wrong Password 109 [Arguments] ${username} ${password} ${role_id} ${enabled} ${wrong_password} 110 111 # Description of argument(s): 112 # username The username to be created. 113 # password The password to be assigned. 114 # role_id The role id of the user to be created. 115 # enabled The decision if it should be enabled. 116 # wrong_password Any invalid password. 117 118 # Delete if the user exist. 119 Run Keyword And Ignore Error 120 ... Redfish.Delete /redfish/v1/AccountService/Accounts/${userName} 121 122 # Create specified user. 123 ${payload}= Create Dictionary 124 ... UserName=${username} Password=${password} RoleId=${role_id} Enabled=${enabled} 125 Redfish.Post /redfish/v1/AccountService/Accounts body=&{payload} 126 ... valid_status_codes=[${HTTP_CREATED}] 127 128 Redfish.Logout 129 130 # Login with created user. 131 Redfish.Login ${username} ${password} 132 133 Redfish.Logout 134 135 # Attempt to login with created user with invalid password. 136 Run Keyword And Expect Error InvalidCredentialsError* 137 ... Redfish.Login ${username} ${wrong_password} 138 139 Redfish.Login 140 141 # Delete newly created user. 142 Redfish.Delete /redfish/v1/AccountService/Accounts/${userName} 143 144 145