From 6d004567fabd3bc7b58c780fc6b7fe4a6feafeae Mon Sep 17 00:00:00 2001 From: Tomas Cechvala Date: Wed, 25 Nov 2015 10:08:35 +0100 Subject: [PATCH] Adding option to specify headers in Utils If not specified, default header is used. Different header for POST request in GBP. Change-Id: I8caa7152cc2076c97d573ebed9ca2290140c8e41 Signed-off-by: Tomas Cechvala --- csit/libraries/GBP/RestconfUtils.robot | 4 ++-- csit/libraries/Utils.robot | 6 +++--- .../groupbasedpolicy/GBP/3-node/gbp1/001_set_odl.robot | 2 +- .../GBP/3-node/gbp2-multitenant/001_set_odl.robot | 2 +- csit/variables/Variables.py | 1 + 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/csit/libraries/GBP/RestconfUtils.robot b/csit/libraries/GBP/RestconfUtils.robot index 535c698eed..6d496cc039 100644 --- a/csit/libraries/GBP/RestconfUtils.robot +++ b/csit/libraries/GBP/RestconfUtils.robot @@ -31,14 +31,14 @@ Unregister L2Endpoints [Documentation] Unregister Endpoints L2Endpoints from ODL : FOR ${endpoint} IN @{l2_eps} \ ${l2_data} = Create L2 Endpoint JSON Data ${endpoint} - \ Post Elements To URI ${ENDPOINT_UNREG_PATH} ${l2_data} + \ Post Elements To URI ${ENDPOINT_UNREG_PATH} ${l2_data} ${HEADERS_YANG_JSON} Unregister L3Endpoints [Arguments] ${l3_eps} [Documentation] Unregister Endpoints L3Endpoints from ODL : FOR ${endpoint} IN @{l3_eps} \ ${l3_data} = Create L3 Endpoint JSON Data ${endpoint} - \ Post Elements To URI ${ENDPOINT_UNREG_PATH} ${l3_data} + \ Post Elements To URI ${ENDPOINT_UNREG_PATH} ${l3_data} ${HEADERS_YANG_JSON} Create L2 Endpoint JSON Data [Arguments] ${endpoint} diff --git a/csit/libraries/Utils.robot b/csit/libraries/Utils.robot index 85412c1aa2..951bcc319f 100644 --- a/csit/libraries/Utils.robot +++ b/csit/libraries/Utils.robot @@ -288,7 +288,7 @@ Concatenate the String [Return] ${output} Post Elements To URI - [Arguments] ${rest_uri} ${data} + [Arguments] ${rest_uri} ${data} ${headers}=${headers} [Documentation] Perform a POST rest operation, using the URL and data provided ${resp} = RequestsLibrary.Post Request session ${rest_uri} data=${data} headers=${headers} Should Be Equal As Strings ${resp.status_code} 200 @@ -306,13 +306,13 @@ Remove All Elements At URI And Verify Should Be Equal As Strings ${resp.status_code} 404 Add Elements To URI From File - [Arguments] ${dest_uri} ${data_file} + [Arguments] ${dest_uri} ${data_file} ${headers}=${headers} ${body} OperatingSystem.Get File ${data_file} ${resp} RequestsLibrary.Put Request session ${dest_uri} data=${body} headers=${headers} Should Be Equal As Strings ${resp.status_code} 200 Post Elements To URI From File - [Arguments] ${dest_uri} ${data_file} + [Arguments] ${dest_uri} ${data_file} ${headers}=${headers} ${body} OperatingSystem.Get File ${data_file} ${resp} RequestsLibrary.Post Request session ${dest_uri} data=${body} headers=${headers} Should Be Equal As Strings ${resp.status_code} 200 diff --git a/csit/suites/groupbasedpolicy/GBP/3-node/gbp1/001_set_odl.robot b/csit/suites/groupbasedpolicy/GBP/3-node/gbp1/001_set_odl.robot index fea2008905..4375aef4d1 100644 --- a/csit/suites/groupbasedpolicy/GBP/3-node/gbp1/001_set_odl.robot +++ b/csit/suites/groupbasedpolicy/GBP/3-node/gbp1/001_set_odl.robot @@ -25,7 +25,7 @@ Register Endpoints [Documentation] Endpoints registration @{endpoint_files} = OperatingSystem.List Files In Directory ${ENDPOINTS_GBP1_DIR} vethl*.*json absolute : FOR ${endpoint_file} IN @{endpoint_files} - \ Post Elements To URI From File ${ENDPOINT_REG_PATH} ${endpoint_file} + \ Post Elements To URI From File ${ENDPOINT_REG_PATH} ${endpoint_file} ${HEADERS_YANG_JSON} Put Tenant [Documentation] Send GBP policy to ODL diff --git a/csit/suites/groupbasedpolicy/GBP/3-node/gbp2-multitenant/001_set_odl.robot b/csit/suites/groupbasedpolicy/GBP/3-node/gbp2-multitenant/001_set_odl.robot index 3ec1c83b2e..7ce20cee2b 100644 --- a/csit/suites/groupbasedpolicy/GBP/3-node/gbp2-multitenant/001_set_odl.robot +++ b/csit/suites/groupbasedpolicy/GBP/3-node/gbp2-multitenant/001_set_odl.robot @@ -25,7 +25,7 @@ Register Endpoints [Documentation] Endpoints registration @{endpoint_files} = OperatingSystem.List Files In Directory ${ENDPOINTS_GBP2_DIR} vethl*.*json absolute : FOR ${endpoint_file} IN @{endpoint_files} - \ Post Elements To URI From File ${ENDPOINT_REG_PATH} ${endpoint_file} + \ Post Elements To URI From File ${ENDPOINT_REG_PATH} ${endpoint_file} ${HEADERS_YANG_JSON} Put Tenants [Documentation] Send GBP policy to ODL diff --git a/csit/variables/Variables.py b/csit/variables/Variables.py index 8c4f71c867..228eb32aed 100644 --- a/csit/variables/Variables.py +++ b/csit/variables/Variables.py @@ -160,6 +160,7 @@ PASSWORD = 'EMPTY' AUTH = [u'admin', u'admin'] SCOPE = 'sdn' HEADERS = {'Content-Type': 'application/json'} +HEADERS_YANG_JSON = {'Content-Type': 'application/yang.data+json'} HEADERS_XML = {'Content-Type': 'application/xml'} ACCEPT_XML = {'Accept': 'application/xml'} ACCEPT_JSON = {'Accept': 'application/json'} -- 2.36.6