Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Added NTLM authentication support to Zend\Soap\Client\DotNet. #3202

Closed
wants to merge 3 commits into from
Closed

Added NTLM authentication support to Zend\Soap\Client\DotNet. #3202

wants to merge 3 commits into from

Conversation

jessiehernandez
Copy link
Contributor

This commit adds NTLM authentication support to the DotNet SOAP client, which I needed for a project I'm working on at my job. I'm a newbie to git (I use SVN for the most part), so if I did anything wrong just let me know. I ran the tests successfully locally, though I had to change a $this->once() call in the test to $this->any(), as I was getting a Bus error from PHPUnit (it does not happen on the test suite I have at work).

Comments/suggestions welcome.


// @codingStandardsIgnoreStart

namespace Zend\Soap
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of use braces end the statement with a ;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use different files for different namespaces

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not possible, as this trick is needed to "mock" out the call_user_func call
in Zend\Soap\Client. Inside Zend\Soap\Client::_doRequest, a call is made
as call_user_func(array($client,'SoapClient::__doRequest')...). There is
absolutely no way I can mock this out from PHPUnit. I am forced to resort
to defining call_user_func inside the namespace in order to intercept the
call and make sure the base method is called when NTLM authentication is
not used.

Jessie

On Tue, Dec 11, 2012 at 3:10 PM, Maks [email protected] wrote:

In tests/ZendTest/Soap/Client/DotNetTest.php:

@@ -0,0 +1,262 @@
+<?php
+/**

Use different files for different namespaces


Reply to this email directly or view it on GitHubhttps://github.com//pull/3202/files#r2383929.

/**
* Returns the cURL client that is being used.
*
* @return \Zend\Http\Client\Adapter\Curl The cURL client.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

annotation value can be simply "CurlClient"; they're resolved based on imports and/or current namespace.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, wasn't sure on the coding standard requirement in this area.
Thanks, Matthew!

Jessie Hernandez

On Tue, Dec 11, 2012 at 3:28 PM, weierophinney [email protected]:

In library/Zend/Soap/Client/DotNet.php:

  •    $curlClient->write('POST', $uri, 1.1, $headers, $request);
    
  •    $response = HttpResponse::fromString($curlClient->read());
    
  •    $curlClient->close();
    
  •    // Save headers
    
  •    $this->lastRequestHeaders  = $this->flattenHeaders($headers);
    
  •    $this->lastResponseHeaders = $response->getHeaders()->toString();
    
  •    // Return only the XML body
    
  •    return $response->getBody();
    
  • }
  • /**
  • \* Returns the cURL client that is being used.
    
  • *
    
  • \* @return \Zend\Http\Client\Adapter\Curl The cURL client.
    

annotation value can be simply "CurlClient"; they're resolved based on
imports and/or current namespace.


Reply to this email directly or view it on GitHubhttps://github.com//pull/3202/files#r2384187.

@ghost ghost assigned weierophinney Dec 11, 2012
weierophinney added a commit that referenced this pull request Dec 11, 2012
- Moved call_user_func override into separate file
- Moved MockCallUserFunc class into separate class file
- Passes php-cs-fixer, and tests run
@Maks3w
Copy link
Member

Maks3w commented Dec 13, 2012

Seems this has broken Travis Tests

PHP 5.4.8 (cli) (built: Nov 22 2012 13:07:18)

ZendTest/Soap:
PHPUnit 3.7.10 by Sebastian Bergmann.

Configuration read from /home/travis/builds/zendframework/zf2/tests/phpunit.xml.dist

Segmentation fault
SS.....................

@jessiehernandez
Copy link
Contributor Author

Works fine under PHPUnit 3.7.10 using Zend Server CE's current PHP version (5.3.14). I'm going to compile 5.4.8 and see if that is the culprit.

$ ~/projects/phpunit/usr/local/zend/bin/phpunit ZendTest/Soap
PHPUnit 3.7.10 by Sebastian Bergmann.

Configuration read from /Users/jessie/projects/zf2/tests/phpunit.xml.dist

SS................................I............................ 63 / 165 ( 38%)
..................................I............................ 126 / 165 ( 76%)
.......................................

Time: 2 seconds, Memory: 10.00Mb

OK, but incomplete or skipped tests!
Tests: 165, Assertions: 330, Incomplete: 2, Skipped: 2.

@jessiehernandez
Copy link
Contributor Author

I'm happy to report that the segfault has nothing to do with my changes. I removed all three files (DotNet.php, calc_user_func.php and MockCallUserFunc.php) and I still get the segfault (this was using PHP 5.4.9). Here's the output:

jessie-hernandezs-macbook-pro:tests jessie$ find ZendTest/Soap
ZendTest/Soap
ZendTest/Soap/_files
ZendTest/Soap/_files/cert_file
ZendTest/Soap/_files/commontypes.php
ZendTest/Soap/_files/fulltests
ZendTest/Soap/_files/fulltests/server1.php
ZendTest/Soap/_files/fulltests/server2.php
ZendTest/Soap/_files/wsdl_documentation.wsdl
ZendTest/Soap/_files/wsdl_example.wsdl
ZendTest/Soap/AutoDiscover
ZendTest/Soap/AutoDiscover/OnlineTest.php
ZendTest/Soap/AutoDiscoverTest.php
ZendTest/Soap/Client
ZendTest/Soap/ClientTest.php
ZendTest/Soap/schemas
ZendTest/Soap/schemas/wsdl.xsd
ZendTest/Soap/Server
ZendTest/Soap/Server/_files
ZendTest/Soap/Server/_files/calculator.wsdl
ZendTest/Soap/Server/DocumentLiteralWrapperTest.php
ZendTest/Soap/ServerTest.php
ZendTest/Soap/TestAsset
ZendTest/Soap/TestAsset/cert_file
ZendTest/Soap/TestAsset/commontypes.php
ZendTest/Soap/TestAsset/fulltests
ZendTest/Soap/TestAsset/fulltests/server1.php
ZendTest/Soap/TestAsset/fulltests/server2.php
ZendTest/Soap/TestAsset/MyCalculatorService.php
ZendTest/Soap/TestAsset/wsdl_documentation.wsdl
ZendTest/Soap/TestAsset/wsdl_example.wsdl
ZendTest/Soap/TestAsset/WsdlTestClass.php
ZendTest/Soap/Wsdl
ZendTest/Soap/Wsdl/ArrayOfTypeComplexStrategyTest.php
ZendTest/Soap/Wsdl/ArrayOfTypeSequenceStrategyTest.php
ZendTest/Soap/Wsdl/CompositeStrategyTest.php
ZendTest/Soap/Wsdl/DefaultComplexTypeTest.php
ZendTest/Soap/WsdlTest.php

$ phpunit ZendTest/Soap
PHPUnit 3.7.10 by Sebastian Bergmann.

Configuration read from /Users/jessie/projects/zf2/tests/phpunit.xml.dist

SS.........................Segmentation fault: 11

@jessiehernandez
Copy link
Contributor Author

After adding the --stderr option to PHPUnit and increasing the ulimit, it all worked (I stopped getting the segfault on the codebase before my changes and after them):

$ find ZendTest/Soap
ZendTest/Soap
ZendTest/Soap/.DS_Store
ZendTest/Soap/_files
ZendTest/Soap/_files/cert_file
ZendTest/Soap/_files/commontypes.php
ZendTest/Soap/_files/fulltests
ZendTest/Soap/_files/fulltests/server1.php
ZendTest/Soap/_files/fulltests/server2.php
ZendTest/Soap/_files/wsdl_documentation.wsdl
ZendTest/Soap/_files/wsdl_example.wsdl
ZendTest/Soap/AutoDiscover
ZendTest/Soap/AutoDiscover/OnlineTest.php
ZendTest/Soap/AutoDiscoverTest.php
ZendTest/Soap/Client
ZendTest/Soap/Client/DotNetTest.php
ZendTest/Soap/ClientTest.php
ZendTest/Soap/schemas
ZendTest/Soap/schemas/wsdl.xsd
ZendTest/Soap/Server
ZendTest/Soap/Server/_files
ZendTest/Soap/Server/_files/calculator.wsdl
ZendTest/Soap/Server/DocumentLiteralWrapperTest.php
ZendTest/Soap/ServerTest.php
ZendTest/Soap/TestAsset
ZendTest/Soap/TestAsset/call_user_func.php
ZendTest/Soap/TestAsset/cert_file
ZendTest/Soap/TestAsset/commontypes.php
ZendTest/Soap/TestAsset/fulltests
ZendTest/Soap/TestAsset/fulltests/server1.php
ZendTest/Soap/TestAsset/fulltests/server2.php
ZendTest/Soap/TestAsset/MockCallUserFunc.php
ZendTest/Soap/TestAsset/MyCalculatorService.php
ZendTest/Soap/TestAsset/wsdl_documentation.wsdl
ZendTest/Soap/TestAsset/wsdl_example.wsdl
ZendTest/Soap/TestAsset/WsdlTestClass.php
ZendTest/Soap/Wsdl
ZendTest/Soap/Wsdl/ArrayOfTypeComplexStrategyTest.php
ZendTest/Soap/Wsdl/ArrayOfTypeSequenceStrategyTest.php
ZendTest/Soap/Wsdl/CompositeStrategyTest.php
ZendTest/Soap/Wsdl/DefaultComplexTypeTest.php
ZendTest/Soap/WsdlTest.php

$ phpunit --stderr ZendTest/Soap
PHPUnit 3.7.10 by Sebastian Bergmann.

Configuration read from /Users/jessie/projects/zf2/tests/phpunit.xml.dist

SS................................I............................ 63 / 165 ( 38%)
..................................I............................ 126 / 165 ( 76%)
.......................................

Time: 0 seconds, Memory: 8.50Mb

OK, but incomplete or skipped tests!
Tests: 165, Assertions: 329, Incomplete: 2, Skipped: 2.

weierophinney added a commit to zendframework/zend-soap that referenced this pull request May 15, 2015
- Moved call_user_func override into separate file
- Moved MockCallUserFunc class into separate class file
- Passes php-cs-fixer, and tests run
weierophinney added a commit to zendframework/zend-soap that referenced this pull request May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants