Refactoring REST interface test
Resolves openbmc/openbmc-test-automation#392
Change-Id: I4ac180c78ca40729a519a9c6250535bb7a4efdcb
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/test_lists/HW_CI b/test_lists/HW_CI
index a039d7c..9a6907e 100644
--- a/test_lists/HW_CI
+++ b/test_lists/HW_CI
@@ -1,12 +1,4 @@
#REST SSL connection test
-i Test_SSL_Connection
-#Error log create and delete test
--i Create_error_log_on_single_FRU
--i Delete_error_log
#Basic poweron test
-i Power_On_Test
-#Clear event and create a logs
--i clear_any_logs
--i write_a_log
-#Test basic REST interface
--i Get_a_Property
diff --git a/test_lists/skip_test b/test_lists/skip_test
index 2fb1f78..04d76fb 100644
--- a/test_lists/skip_test
+++ b/test_lists/skip_test
@@ -37,12 +37,8 @@
-e IPMI_Chassis_Status_On
-e IPMI_Chassis_Status_Off
-e IPMI_Chassis_Restore_Power_Policy
-#https://github.com/openbmc/openbmc/issues/830
--e Good_connection_for_testing
--e get_directory_listing
--e get_directory_listing_xyz
--e get_names
--e get_names_org
+#https://github.com/openbmc/openbmc-test-automation/issues/226
+-e Test_BIOS_Version
#https://github.com/openbmc/openbmc/issues/928
-e Set_Host_Time_With_Both_And_NTP
#https://github.com/openbmc/openbmc/issues/901
diff --git a/tests/test_rest_interfaces.robot b/tests/test_rest_interfaces.robot
index 11242df..9c9d919 100644
--- a/tests/test_rest_interfaces.robot
+++ b/tests/test_rest_interfaces.robot
@@ -1,382 +1,196 @@
*** Settings ***
-Documentation This suite will verifiy all OpenBMC rest interfaces
-... Details of valid interfaces can be found here...
-... https://github.com/openbmc/docs/blob/master/rest-api.md
+Documentation Verify REST services Get/Put/Post/Delete.
Resource ../lib/rest_client.robot
Resource ../lib/openbmc_ffdc.robot
Resource ../lib/resource.txt
+Library Collections
Test Teardown FFDC On Test Case Fail
*** Variables ***
*** Test Cases ***
-Good connection for testing
- [Tags] Good_connection_for_testing
- ${content}= Read Properties /
- ${c}= get from List ${content} 0
- Should Be Equal ${c} /xyz
-Get an object with no properties
- ${content}= Read Properties ${INVENTORY_URI.rstrip("/")}
- Should Be Empty ${content}
+Get Response Codes
+ [Documentation] REST "Get" response status test.
+ #--------------------------------------------------------------------
+ # Expect status URL Path
+ #--------------------------------------------------------------------
+ ${HTTP_OK} /
+ ${HTTP_OK} /xyz/
+ ${HTTP_OK} /xyz/openbmc_project/
+ ${HTTP_OK} /xyz/openbmc_project/enumerate
+ ${HTTP_NOT_FOUND} /i/dont/exist/
-Get a Property
- [Tags] Get_a_Property
- ${url_list}=
- ... Get Endpoint Paths ${INVENTORY_URI.rstrip("/")} cpu
- ${url}= Get From List ${url_list} 0
- ${resp}= Read Attribute ${url} is_fru
- Should Be Equal ${resp} ${1}
-
-Get a null Property
- ${resp}= OpenBMC Get Request ${INVENTORY_URI}attr/is_fru
- Should Be Equal As Strings ${resp.status_code} ${HTTP_NOT_FOUND}
- ${jsondata}= To Json ${resp.content}
- Should Be Equal
- ... ${jsondata['data']['description']}
- ... The specified property cannot be found: ''is_fru''
-
-get directory listing /
- [Tags] get_directory_listing
- ${resp}= openbmc get request /
- should be equal as strings ${resp.status_code} ${HTTP_OK}
- ${json}= to json ${resp.content}
- list should contain value ${json['data']} /xyz
- should be equal as strings ${json['status']} ok
-
-get directory listing /xyz/
- [Tags] get_directory_listing_xyz
- ${resp}= openbmc get request /xyz/
- should be equal as strings ${resp.status_code} ${HTTP_OK}
- ${json}= to json ${resp.content}
- list should contain value
- ... ${json['data']} /xyz/openbmc_project
- should be equal as strings ${json['status']} ok
-
-get invalid directory listing /i/dont/exist/
- [Tags] CI
- ${resp}= openbmc get request /i/dont/exist/
- should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-put directory listing /
- [Tags] CI
- ${resp}= openbmc put request /
- should be equal as strings
- ... ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-put directory listing /xyz/
- [Tags] CI
- ${resp}= openbmc put request /xyz/
- should be equal as strings
- ... ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-put invalid directory listing /i/dont/exist/
- [Tags] CI
- ${resp}= openbmc put request /i/dont/exist/
- should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-post directory listing /
- [Tags] CI
- ${resp}= openbmc post request /
- should be equal as strings
- ... ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-post directory listing /xyz/
- [Tags] CI
- ${resp}= openbmc post request /xyz/
- should be equal as strings
- ... ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-post invalid directory listing /i/dont/exist/
- [Tags] CI
- ${resp}= openbmc post request /i/dont/exist/
- should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-delete directory listing /
- [Tags] CI
- ${resp}= openbmc delete request /
- should be equal as strings
- ... ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-delete directory listing /xyz/
- [Tags] CI
- ${resp}= openbmc delete request /
- should be equal as strings
- ... ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-delete invalid directory listing /xyz/nothere/
- [Tags] CI
- ${resp}= openbmc delete request /xyz/nothere/
- should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-get list names /
- ${resp}= openbmc get request /list
- should be equal as strings ${resp.status_code} ${HTTP_OK}
- ${json}= to json ${resp.content}
- list should contain value
- ... ${json['data']} /xyz/openbmc_project/inventory
- should be equal as strings ${json['status']} ok
-
-get list names /xyz/
- ${resp}= openbmc get request /xyz/list
- should be equal as strings ${resp.status_code} ${HTTP_OK}
- ${json}= to json ${resp.content}
- list should contain value
- ... ${json['data']} /xyz/openbmc_project/inventory
- should be equal as strings ${json['status']} ok
-
-get invalid list names /i/dont/exist/
- [Tags] CI
- ${resp}= openbmc get request /i/dont/exist/list
- should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-put list names /
- [Tags] CI
- ${resp}= openbmc put request /list
- should be equal as strings
- ... ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-put list names /xyz/
- [Tags] CI
- ${resp}= openbmc put request /xyz/list
- should be equal as strings
- ... ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-put invalid list names /i/dont/exist/
- [Tags] CI
- ${resp}= openbmc put request /i/dont/exist/list
- should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-post list names /
- [Tags] CI
- ${resp}= openbmc post request /list
- should be equal as strings
- ... ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-post list names /xyz/
- [Tags] CI
- ${resp}= openbmc post request /xyz/list
- should be equal as strings
- ... ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-post invalid list names /i/dont/exist/
- [Tags] CI
- ${resp}= openbmc post request /i/dont/exist/list
- should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-delete list names /
- [Tags] CI
- ${resp}= openbmc delete request /list
- should be equal as strings
- ... ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-delete list names /xyz/
- [Tags] CI
- ${resp}= openbmc delete request /list
- should be equal as strings
- ... ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-delete invalid list names /xyz/nothere/
- [Tags] CI
- ${resp}= openbmc delete request /xyz/nothere/list
- should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-get names /
- [Tags] get_names
- ${resp}= openbmc get request /enumerate
- should be equal as strings ${resp.status_code} ${HTTP_OK}
- ${json}= to json ${resp.content}
- list should contain value
- ... ${json['data']} /xyz/openbmc_project/inventory
- should be equal as strings ${json['status']} ok
-
-get names /xyz/
- [Tags] get_names_xyz
- ${resp}= openbmc get request /xyz/enumerate
- should be equal as strings ${resp.status_code} ${HTTP_OK}
- ${json}= to json ${resp.content}
- list should contain value
- ... ${json['data']} /xyz/openbmc_project/inventory
- should be equal as strings ${json['status']} ok
-
-get invalid names /i/dont/exist/
- [Tags] CI
- ${resp}= openbmc get request /i/dont/exist/enumerate
- should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-put names /
- [Tags] CI
- ${resp}= openbmc put request /enumerate
- should be equal as strings
- ... ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-put names /xyz/
- [Tags] CI
- ${resp}= openbmc put request /xyz/enumerate
- should be equal as strings
- ... ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-put invalid names /i/dont/exist/
- [Tags] CI
- ${resp}= openbmc put request /i/dont/exist/enumerate
- should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-post names /
- [Tags] CI
- ${resp}= openbmc post request /enumerate
- should be equal as strings
- ... ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-post names /xyz/
- [Tags] CI
- ${resp}= openbmc post request /xyz/enumerate
- should be equal as strings
- ... ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-post invalid names /i/dont/exist/
- [Tags] CI
- ${resp}= openbmc post request /i/dont/exist/enumerate
- should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-delete names /
- [Tags] CI
- ${resp}= openbmc delete request /enumerate
- should be equal as strings
- ... ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-delete names /xyz/
- [Tags] CI
- ${resp}= openbmc delete request /enumerate
- should be equal as strings
- ... ${resp.status_code} ${HTTP_METHOD_NOT_ALLOWED}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-delete invalid names /xyz/nothere/
- [Tags] CI
- ${resp}= openbmc delete request /xyz/nothere/enumerate
- should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-get method xyz/openbmc_project/logging/entry
- [Tags] CI
- ${resp}= openbmc get request
- ... xyz/openbmc_project/logging/entry
- should be equal as strings
- ... ${resp.status_code} ${HTTP_NOT_FOUND}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
-
-get invalid method /i/dont/exist/
- [Tags] CI
- ${resp}= openbmc get request /i/dont/exist/action/foo
- should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
+ [Tags] Get_Response_Codes
+ [Template] Execute Get And Check Response
-put invalid method /i/dont/exist/
- [Tags] CI
- ${resp}= openbmc put request /i/dont/exist/action/foo
- should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
+Get Data
+ [Documentation] REST "Get" request url and expect the
+ ... response OK and data non empty.
+ #--------------------------------------------------------------------
+ # URL Path
+ #--------------------------------------------------------------------
+ /xyz/openbmc_project/
+ /xyz/openbmc_project/list
+ /xyz/openbmc_project/enumerate
-post method power/getPowerState no args
- ${fan_uri}= Get Power Control Interface
- ${data}= create dictionary data=@{EMPTY}
- ${resp}= openbmc post request
- ... ${fan_uri}/action/getPowerState data=${data}
- should be equal as strings ${resp.status_code} ${HTTP_OK}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} ok
+ [Tags] Get_Data
+ [Template] Execute Get And Check Data
-post method xyz/openbmc_project/sensors/host/BootCount with args
- ${uri}= Set Variable ${SENSORS_URI}host/BootCount
- ${COUNT}= Set Variable ${3}
- @{count_list}= Create List ${COUNT}
- ${data}= create dictionary data=@{count_list}
- ${resp}= openbmc post request ${uri}/action/setValue data=${data}
- should be equal as strings ${resp.status_code} ${HTTP_OK}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} ok
- ${content}= Read Attribute ${uri} value
- Should Be Equal ${content} ${COUNT}
-delete invalid method /xyz/nothere/
- [Tags] CI
- ${resp}= openbmc delete request /xyz/nothere/action/foomethod
- should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
- ${json}= to json ${resp.content}
- should be equal as strings ${json['status']} error
+Get Data Validation
+ [Documentation] REST "Get" request url and expect the
+ ... pre-defined string in response data.
+ #--------------------------------------------------------------------
+ # URL Path Expect Data
+ #--------------------------------------------------------------------
+ /xyz/openbmc_project/ /xyz/openbmc_project/logging
+ /i/dont/exist/ path or object not found: /i/dont/exist
+
+ [Tags] Get_Data_Validation
+ [Template] Execute Get And Verify Data
+
+
+Put Response Codes
+ [Documentation] REST "Put" request url and expect the REST pre-defined
+ ... codes.
+ #--------------------------------------------------------------------
+ # Expect status URL Path
+ #--------------------------------------------------------------------
+ ${HTTP_METHOD_NOT_ALLOWED} /
+ ${HTTP_METHOD_NOT_ALLOWED} /xyz/
+ ${HTTP_METHOD_NOT_ALLOWED} /i/dont/exist/
+ ${HTTP_METHOD_NOT_ALLOWED} /xyz/list
+ ${HTTP_METHOD_NOT_ALLOWED} /xyz/enumerate
+
+ [Tags] Put_Response_Codes
+ [Template] Execute Put And Check Response
+
+
+Put Data Validation
+ [Documentation] REST "Put" request url and expect success.
+ #--------------------------------------------------------------------
+ # URL Path Parm Data
+ #--------------------------------------------------------------------
+ /xyz/openbmc_project/state/host0/attr/RequestedHostTransition xyz.openbmc_project.State.Host.Transition.Off
+
+ [Tags] Put_Data_Validation
+ [Template] Execute Put And Expect Success
+
+
+Post Response Code
+ [Documentation] REST Post request url and expect the
+ ... REST response code pre define.
+ #--------------------------------------------------------------------
+ # Expect status URL Path
+ #--------------------------------------------------------------------
+ ${HTTP_METHOD_NOT_ALLOWED} /
+ ${HTTP_METHOD_NOT_ALLOWED} /xyz/
+ ${HTTP_METHOD_NOT_ALLOWED} /i/dont/exist/
+ ${HTTP_METHOD_NOT_ALLOWED} /xyz/enumerate
+
+ [Tags] Post_Response_Codes
+ [Template] Execute Post And Check Response
+
+
+Delete Response Code
+ [Documentation] REST "Delete" request url and expect the
+ ... REST response code pre define.
+ #--------------------------------------------------------------------
+ # Expect status URL Path
+ #--------------------------------------------------------------------
+ ${HTTP_METHOD_NOT_ALLOWED} /
+ ${HTTP_METHOD_NOT_ALLOWED} /xyz/
+ ${HTTP_METHOD_NOT_ALLOWED} /xyz/nothere/
+ ${HTTP_METHOD_NOT_ALLOWED} /xyz/enumerate
+ ${HTTP_METHOD_NOT_ALLOWED} /xyz/openbmc_project/list
+ ${HTTP_METHOD_NOT_ALLOWED} /xyz/openbmc_project/enumerate
+
+ [Tags] Delete_Response_Codes
+ [Template] Execute Delete And Check Response
+
*** Keywords ***
-Get Power Control Interface
- ${resp}= OpenBMC Get Request ${CONTROL_URI}
- should be equal as strings
- ... ${resp.status_code} ${HTTP_OK}
- ... msg=Unable to get any controls - ${CONTROL_URI}
- ${jsondata}= To Json ${resp.content}
- log ${jsondata}
- : FOR ${ELEMENT} IN @{jsondata["data"]}
- \ log ${ELEMENT}
- \ ${found}= Get Lines Matching Pattern ${ELEMENT} *control/power*
- \ Return From Keyword If '${found}' != '' ${found}
+
+Execute Get And Check Response
+ [Documentation] Request "Get" url path and expect REST response code.
+ [Arguments] ${expected_response_code} ${url_path}
+ # Description of arguments:
+ # expected_response_code Expected REST status codes.
+ # url_path URL path.
+ ${resp}= Openbmc Get Request ${url_path}
+ Should Be Equal As Strings ${resp.status_code} ${expected_response_code}
+
+Execute Get And Check Data
+ [Documentation] Request "Get" url path and expect non empty data.
+ [Arguments] ${url_path}
+ # Description of arguments:
+ # url_path URL path.
+ ${resp}= Openbmc Get Request ${url_path}
+ Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
+ ${jsondata}= To JSON ${resp.content}
+ Should Not Be Empty ${jsondata["data"]}
+
+Execute Get And Verify Data
+ [Documentation] Request "Get" url path and verify data.
+ [Arguments] ${url_path} ${expected_response_code}
+ # Description of arguments:
+ # expected_response_code Expected REST status codes.
+ # url_path URL path.
+ ${resp}= Openbmc Get Request ${url_path}
+ ${jsondata}= To JSON ${resp.content}
+ Run Keyword If '${resp.status_code}' == '${HTTP_OK}'
+ ... Should Contain ${jsondata["data"]} ${expected_response_code}
+ ... ELSE
+ ... Should Contain ${jsondata["data"]["description"]} ${expected_response_code}
+
+Execute Put And Check Response
+ [Documentation] Request "Put" url path and expect REST response code.
+ [Arguments] ${expected_response_code} ${url_path}
+ # Description of arguments:
+ # expected_response_code Expected REST status codes.
+ # url_path URL path.
+ ${resp}= Openbmc Put Request ${url_path}
+ Should Be Equal As Strings ${resp.status_code} ${expected_response_code}
+
+Execute Put And Expect Success
+ [Documentation] Request "Put" on url path.
+ [Arguments] ${url_path} ${parm}
+ # Description of arguments:
+ # url_path URL path.
+ # parm Value/string to be set.
+ # expected_response_code Expected REST status codes.
+ ${parmDict}= Create Dictionary data=${parm}
+ ${resp}= Openbmc Put Request ${url_path} data=${parmDict}
+ Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
+
+Execute Post And Check Response
+ [Documentation] Request Post url path and expect REST response code.
+ [Arguments] ${expected_response_code} ${url_path}
+ # Description of arguments:
+ # expected_response_code Expected REST status codes.
+ # url_path URL path.
+ ${resp}= Openbmc Post Request ${url_path}
+ Should Be Equal As Strings ${resp.status_code} ${expected_response_code}
+
+Execute Post And Check Data
+ [Arguments] ${url_path} ${parm}
+ [Documentation] Request Post on url path and expected non empty data.
+ # Description of arguments:
+ # url_path URL path.
+ ${data}= Create Dictionary data=@{data}
+ ${resp}= Openbmc Post Request ${url_path} data=${data}
+ Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
+ ${jsondata}= To JSON ${resp.content}
+ Should Not Be Empty ${jsondata["data"]}
+
+Execute Delete And Check Response
+ [Documentation] Request "Delete" url path and expected REST response code.
+ [Arguments] ${expected_response_code} ${url_path}
+ # Description of arguments:
+ # expected_response_code Expected REST status codes.
+ # url_path URL path.
+ ${resp}= Openbmc Delete Request ${url_path}
+ Should Be Equal As Strings ${resp.status_code} ${expected_response_code}