Fix PcepOperations requests 87/111087/3
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 27 Mar 2024 00:54:21 +0000 (01:54 +0100)
committerSangwook Ha <sangwook.ha@verizon.com>
Wed, 27 Mar 2024 17:57:08 +0000 (10:57 -0700)
When 'url' for RequestsLibrary.Post_On_Session starts with a word that
complies with the pattern of URL scheme followed by a colon, e.g.
'network-topology-pcep:add-lsp', then it becomes the entire URL and
the base URL for the session is ignored by 'urljoin':

https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin
https://datatracker.ietf.org/doc/html/rfc3986.html#section-3.1

To avoid this issue remove the common URL base path '/rests/operations'
from the session base URL and add it Post_on_Session.

Change-Id: I88c990788c41ff2772577f0302217e30f55c9fc6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
csit/libraries/PcepOperations.robot

index 23383afe005797c1895bd4aa8563ed65f737eeb6..1a37c05948809726872be675a1f010d02b2a87fb 100644 (file)
@@ -25,14 +25,13 @@ Setup_Pcep_Operations
     [Documentation]    Creates Requests session to be used by subsequent keywords.
     RequestsLibrary.Create_Session
     ...    alias=pcep_session
-    ...    url=http://${ODL_SYSTEM_IP}:${RESTCONFPORT}/rests/operations/
+    ...    url=http://${ODL_SYSTEM_IP}:${RESTCONFPORT}
     ...    headers=${HEADERS_XML}
     ...    auth=${AUTH}
 
 Teardown_Pcep_Operations
     [Documentation]    Teardown to pair with Setup (otherwise no-op).
-    Log    TODO: The following line does not seem to be implemented by RequestsLibrary. Look for a workaround.
-    # Delete_Session    pcep_session
+    RequestsLibrary.Delete_All_Sessions
 
 Add_Xml_Lsp_Return_Json
     [Documentation]    Instantiate LSP according to XML data and return response (json) text.
@@ -58,9 +57,10 @@ Remove_Xml_Lsp_Return_Json
 Operate_Xml_Lsp_Return_Json
     [Documentation]    Post XML data to given pcep-operations URI, check status_code is 200 and return response text (JSON).
     [Arguments]    ${uri_part}    ${xml_data}
+    ${uri_path}=    BuiltIn.Set_Variable    /rests/operations/${uri_part}
     ${response}=    RequestsLibrary.POST On Session
     ...    alias=pcep_session
-    ...    url=${uri_part}
+    ...    url=${uri_path}
     ...    data=${xml_data}
     ...    expected_status=any
     Log    ${xml_data}