ombre42 / robotframework-sudslibrary

Web service testing library for Robot Framework
Apache License 2.0
29 stars 44 forks source link

SudsLibrary does not work with an authenticating proxy. #18

Open yahman72 opened 10 years ago

yahman72 commented 10 years ago

SudsLibrary does not work with an authenticating proxy. The proxy settings are ignored when calling a SOAP method. This seems to be the case with python 2.7, but not with 2.5 (at least not with jython 2.5)

============================================
Test Case:
--------------------------------------------
*** Settings ***
Library                 SudsLibrary
Library                 Collections
Resource                resourceFile.txt

*** Test Cases ***  
SudsLib Case
    Create Soap Client          ${CURDIR}/sudsExample.wsdl
    Set Proxies                 http                    http://${USERNAME}:${PASSWORD}@${HW_PROXYURL}
    ${dbl array}=               Create Wsdl Object      ArrayOfDouble  
    Append To List              ${dbl array.double}     2.0  
    Append To List              ${dbl array.double}     3.0  
    ${result}=                  Call Soap Method        GetStatistics       ${dbl array} 
    Should Be Equal As Numbers  ${result.Average}       2.5  

Test Execution:
--------------------------------------------
> pybot -L INFO -b debug.txt src\test\robotframework\atp_tests\soap.txt
==============================================================================
Soap
==============================================================================
SudsLib Case                                                          | FAIL |
URLError: 
------------------------------------------------------------------------------
Soap                                                                  | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
==============================================================================
Debug:   D:\jnu\projects\rfw_tst\debug.txt
Output:  D:\jnu\projects\rfw_tst\output.xml
Log:     D:\jnu\projects\rfw_tst\log.html
Report:  D:\jnu\projects\rfw_tst\report.html

Debug log:
--------------------------------------------
==============================================================================
20140917 09:36:18.135 - INFO - +- START TEST: SudsLib Case [ ]
------------------------------------------------------------------------------
20140917 09:36:18.135 - INFO - +-- START KW: SudsLibrary.Create Soap Client [ D:\\jnu\\projects\\rfw_tst\\src\\test\\robotframework\\atp_tests/sudsExample.wsdl ]
20140917 09:36:18.291 - INFO - Using WSDL at file:///D:/jnu/projects/rfw_tst/src/test/robotframework/atp_tests/sudsExample.wsdl
Suds ( https://fedorahosted.org/suds/ )  version: 0.4 GA  build: R699-20100913

Service ( Statistics ) tns="http://www.webserviceX.NET"
   Prefixes (1)
      ns0 = "http://www.webserviceX.NET"
   Ports (2):
      (StatisticsSoap)
         Methods (1):
            GetStatistics(ArrayOfDouble X, )
         Types (1):
            ArrayOfDouble
      (StatisticsSoap12)
         Methods (1):
            GetStatistics(ArrayOfDouble X, )
         Types (1):
            ArrayOfDouble
20140917 09:36:18.292 - INFO - +-- END KW: SudsLibrary.Create Soap Client (157)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20140917 09:36:18.292 - INFO - +-- START KW: SudsLibrary.Set Proxies [ http | http://${USERNAME}:${PASSWORD}@${HW_PROXYURL} ]
20140917 09:36:18.293 - INFO - +-- END KW: SudsLibrary.Set Proxies (1)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20140917 09:36:18.293 - INFO - +-- START KW: ${dbl array} = SudsLibrary.Create Wsdl Object [ ArrayOfDouble ]
20140917 09:36:18.293 - INFO - ${dbl array} = (ArrayOfDouble){
   double[] = 
 }
20140917 09:36:18.294 - INFO - +-- END KW: ${dbl array} = SudsLibrary.Create Wsdl Object (0)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20140917 09:36:18.294 - INFO - +-- START KW: Collections.Append To List [ ${dbl array.double} | 2.0 ]
20140917 09:36:18.294 - INFO - +-- END KW: Collections.Append To List (0)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20140917 09:36:18.295 - INFO - +-- START KW: Collections.Append To List [ ${dbl array.double} | 3.0 ]
20140917 09:36:18.295 - INFO - +-- END KW: Collections.Append To List (0)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20140917 09:36:18.295 - INFO - +-- START KW: ${result} = SudsLibrary.Call Soap Method [ GetStatistics | ${dbl array} ]
20140917 09:36:18.298 - INFO - Sending:


  
  
    
      
        2.0
        3.0
      
    
  

20140917 09:36:39.941 - FAIL - URLError: 
20140917 09:36:39.942 - DEBUG - Traceback (most recent call last):
  File "c:\Python27\lib\site-packages\SudsLibrary\proxy.py", line 49, in call_soap_method
    return self._call(None, None, False, name, *args)
  File "c:\Python27\lib\site-packages\SudsLibrary\proxy.py", line 111, in _call
    received = method(*args)
  File "c:\Python27\lib\site-packages\suds\client.py", line 542, in __call__
    return client.invoke(args, kwargs)
  File "c:\Python27\lib\site-packages\suds\client.py", line 602, in invoke
    result = self.send(soapenv)
  File "c:\Python27\lib\site-packages\suds\client.py", line 637, in send
    reply = transport.send(request)
  File "c:\Python27\lib\site-packages\suds\transport\https.py", line 64, in send
    return  HttpTransport.send(self, request)
  File "c:\Python27\lib\site-packages\suds\transport\http.py", line 77, in send
    fp = self.u2open(u2request)
  File "c:\Python27\lib\site-packages\suds\transport\http.py", line 118, in u2open
    return url.open(u2request)
  File "c:\Python27\lib\urllib2.py", line 408, in open
    response = self._open(req, data)
  File "c:\Python27\lib\urllib2.py", line 428, in _open
    '_open', req)
  File "c:\Python27\lib\urllib2.py", line 386, in _call_chain
    result = func(*args)
  File "c:\Python27\lib\urllib2.py", line 1229, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "c:\Python27\lib\urllib2.py", line 1199, in do_open
    raise URLError(err)
20140917 09:36:39.942 - INFO - +-- END KW: ${result} = SudsLibrary.Call Soap Method (21647)
------------------------------------------------------------------------------
20140917 09:36:39.944 - INFO - +- END TEST: SudsLib Case (21809)
------------------------------------------------------------------------------
20140917 09:36:39.946 - INFO - + END SUITE: Soap (21945)
==============================================================================

============================================

I also have an jython (2.5.3) installation and there this works

============================================
Test Execution:
--------------------------------------------
==============================================================================
Atp Tests
==============================================================================
Atp Tests.Soap
==============================================================================
SudsLib Case                                                          | PASS |
------------------------------------------------------------------------------
Atp Tests.Soap                                                        | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================
Atp Tests                                                             | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================
Debug:   D:\jnu\projects\rfw_tst\target\robotframework-reports\debug.txt
Output:  D:\jnu\projects\rfw_tst\target\robotframework-reports\output.xml
XUnit:   D:\jnu\projects\rfw_tst\target\robotframework-reports\TEST-atp_tests.xml
Log:     D:\jnu\projects\rfw_tst\target\robotframework-reports\log.html
Report:  D:\jnu\projects\rfw_tst\target\robotframework-reports\report.html

Debug log:
--------------------------------------------
==============================================================================
20140917 09:43:27.402 - INFO - +-- START TEST: SudsLib Case [ ]
------------------------------------------------------------------------------
20140917 09:43:27.404 - INFO - +--- START KW: SudsLibrary.Create Soap Client [ D:\\jnu\\projects\\rfw_tst\\src\\test\\robotframework\\atp_tests/sudsExample.wsdl ]
20140917 09:43:27.465 - INFO - Using WSDL at file:///D|/jnu/projects/rfw_tst/src/test/robotframework/atp_tests/sudsExample.wsdl
Suds ( https://fedorahosted.org/suds/ )  version: 0.4 GA  build: R699-20100913

Service ( Statistics ) tns="http://www.webserviceX.NET"
   Prefixes (1)
      ns0 = "http://www.webserviceX.NET"
   Ports (2):
      (StatisticsSoap)
         Methods (1):
            GetStatistics(ArrayOfDouble X, )
         Types (1):
            ArrayOfDouble
      (StatisticsSoap12)
         Methods (1):
            GetStatistics(ArrayOfDouble X, )
         Types (1):
            ArrayOfDouble
20140917 09:43:27.468 - INFO - +--- END KW: SudsLibrary.Create Soap Client (64)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20140917 09:43:27.470 - INFO - +--- START KW: SudsLibrary.Set Proxies [ http | http://${USERNAME}:${PASSWORD}@${HW_PROXYURL} ]
20140917 09:43:27.472 - INFO - +--- END KW: SudsLibrary.Set Proxies (2)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20140917 09:43:27.474 - INFO - +--- START KW: ${dbl array} = SudsLibrary.Create Wsdl Object [ ArrayOfDouble ]
20140917 09:43:27.477 - INFO - ${dbl array} = (ArrayOfDouble){
   double[] = 
 }
20140917 09:43:27.478 - INFO - +--- END KW: ${dbl array} = SudsLibrary.Create Wsdl Object (3)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20140917 09:43:27.479 - INFO - +--- START KW: Collections.Append To List [ ${dbl array.double} | 2.0 ]
20140917 09:43:27.484 - INFO - +--- END KW: Collections.Append To List (5)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20140917 09:43:27.486 - INFO - +--- START KW: Collections.Append To List [ ${dbl array.double} | 3.0 ]
20140917 09:43:27.491 - INFO - +--- END KW: Collections.Append To List (6)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20140917 09:43:27.493 - INFO - +--- START KW: ${result} = SudsLibrary.Call Soap Method [ GetStatistics | ${dbl array} ]
20140917 09:43:27.769 - INFO - Sending:


  
  
    
      
        2.0
        3.0
      
    
  

20140917 09:43:42.549 - INFO - Received:


  
    
      5
      2.5
      0.5
      0.5
      -2.5
    
  

20140917 09:43:42.568 - INFO - ${result} = (reply){
   Sums = 5.0
   Average = 2.5
   StandardDeviation = 0.5
   skewness = 0.5
   Kurtosis = -2.5
 }
20140917 09:43:42.569 - INFO - +--- END KW: ${result} = SudsLibrary.Call Soap Method (15073)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20140917 09:43:42.570 - INFO - +--- START KW: BuiltIn.Should Be Equal As Numbers [ ${result.Average} | 2.5 ]
20140917 09:43:42.573 - INFO - Argument types are:


20140917 09:43:42.575 - INFO - +--- END KW: BuiltIn.Should Be Equal As Numbers (5)
------------------------------------------------------------------------------
20140917 09:43:42.577 - INFO - +-- END TEST: SudsLib Case (15177)
------------------------------------------------------------------------------
20140917 09:43:42.626 - INFO - +- END SUITE: Atp Tests.Soap (17146)
==============================================================================
20140917 09:43:42.652 - INFO - + END SUITE: Atp Tests (17378)
==============================================================================  
============================================
yahman72 commented 10 years ago

FYI - this issue might be caused by the urllib/urllib2 libraries. After troubleshooting a bit I figured out that those libraries ignore the proxy settings. If I define an environment variable called "http_proxy" and give it a dummy value e.g. "http://dummy.proxy.com" things start to work i.e. the proxy settings given with the "Set Proxies" keyword are applied.

ombre42 commented 9 years ago

thank you for reporting this. it will take some time to investigate. If this is fixed in suds-jurko, I'm thinking about making that fork the default instead of the original suds.