djoos / EscapeWSSEAuthenticationBundle

Symfony bundle to implement WSSE authentication
http://symfony.com/doc/current/cookbook/security/custom_authentication_provider.html
137 stars 59 forks source link

Unit Tests fail #72

Closed Drachenkaetzchen closed 8 years ago

Drachenkaetzchen commented 9 years ago

I tried to write a bugfix for #69, however, the unit tests for the stock repository version fail:

PHP Warning:  Erroneous data format for unserializing 'Mock_TokenInterface_278f77bc' in /usr/share/php/PHPUnit/Framework/MockObject/Generator.php on line 247
PHP Stack trace:
PHP   1. {main}() /usr/bin/phpunit:0
PHP   2. PHPUnit_TextUI_Command::main($exit = *uninitialized*) /usr/bin/phpunit:46
PHP   3. PHPUnit_TextUI_Command->run($argv = array (0 => '/usr/bin/phpunit'), $exit = TRUE) /usr/share/php/PHPUnit/TextUI/Command.php:129
PHP   4. PHPUnit_TextUI_Command->handleArguments($argv = array (0 => '/usr/bin/phpunit')) /usr/share/php/PHPUnit/TextUI/Command.php:138
PHP   5. PHPUnit_Util_Configuration->getTestSuiteConfiguration($testSuiteFilter = NULL) /usr/share/php/PHPUnit/TextUI/Command.php:657
PHP   6. PHPUnit_Util_Configuration->getTestSuite($testSuiteNode = class DOMElement { public $tagName = 'testsuite'; public $schemaTypeInfo = NULL; public $nodeName = 'testsuite'; public $nodeValue = '\n            ./Tests\n        '; public $nodeType = 1; public $parentNode = '(object value omitted)'; public $childNodes = '(object value omitted)'; public $firstChild = '(object value omitted)'; public $lastChild = '(object value omitted)'; public $previousSibling = '(object value omitted)'; public $nextSibling = '(object value omitted)'; public $attributes = '(object value omitted)'; public $ownerDocument = '(object value omitted)'; public $namespaceURI = NULL; public $prefix = ''; public $localName = 'testsuite'; public $baseURI = '/home/felicitus/repos/EscapeWSSEAuthenticationBundle/phpunit.xml.dist'; public $textContent = '\n            ./Tests\n        ' }, $testSuiteFilter = NULL) /usr/share/php/PHPUnit/Util/Configuration.php:776
PHP   7. PHPUnit_Framework_TestSuite->addTestFiles($filenames = array (0 => '/home/felicitus/repos/EscapeWSSEAuthenticationBundle/Tests/DependencyInjection/Security/Factory/FactoryTest.php', 1 => '/home/felicitus/repos/EscapeWSSEAuthenticationBundle/Tests/Security/Core/Authentication/Provider/ProviderTest.php', 2 => '/home/felicitus/repos/EscapeWSSEAuthenticationBundle/Tests/Security/Http/EntryPoint/EntryPointTest.php', 3 => '/home/felicitus/repos/EscapeWSSEAuthenticationBundle/Tests/Security/Http/Firewall/ListenerTest.php')) /usr/share/php/PHPUnit/Util/Configuration.php:860
PHP   8. PHPUnit_Framework_TestSuite->addTestFile($filename = '/home/felicitus/repos/EscapeWSSEAuthenticationBundle/Tests/Security/Core/Authentication/Provider/ProviderTest.php', $phptOptions = *uninitialized*) /usr/share/php/PHPUnit/Framework/TestSuite.php:416
PHP   9. PHPUnit_Framework_TestSuite->addTestSuite($testClass = class ReflectionClass { public $name = 'Escape\\WSSEAuthenticationBundle\\Tests\\Security\\Core\\Authentication\\Provider\\ProviderTest' }) /usr/share/php/PHPUnit/Framework/TestSuite.php:389
PHP  10. PHPUnit_Framework_TestSuite->__construct($theClass = class ReflectionClass { public $name = 'Escape\\WSSEAuthenticationBundle\\Tests\\Security\\Core\\Authentication\\Provider\\ProviderTest' }, $name = *uninitialized*) /usr/share/php/PHPUnit/Framework/TestSuite.php:315
PHP  11. PHPUnit_Framework_TestSuite->addTestMethod($class = class ReflectionClass { public $name = 'Escape\\WSSEAuthenticationBundle\\Tests\\Security\\Core\\Authentication\\Provider\\ProviderTest' }, $method = class ReflectionMethod { public $name = 'supports'; public $class = 'Escape\\WSSEAuthenticationBundle\\Tests\\Security\\Core\\Authentication\\Provider\\ProviderTest' }) /usr/share/php/PHPUnit/Framework/TestSuite.php:212
PHP  12. PHPUnit_Framework_TestSuite::createTest($theClass = class ReflectionClass { public $name = 'Escape\\WSSEAuthenticationBundle\\Tests\\Security\\Core\\Authentication\\Provider\\ProviderTest' }, $name = 'supports') /usr/share/php/PHPUnit/Framework/TestSuite.php:834
PHP  13. PHPUnit_Util_Test::getProvidedData($className = 'Escape\\WSSEAuthenticationBundle\\Tests\\Security\\Core\\Authentication\\Provider\\ProviderTest', $methodName = 'supports') /usr/share/php/PHPUnit/Framework/TestSuite.php:481
PHP  14. ReflectionMethod->invoke(class Escape\WSSEAuthenticationBundle\Tests\Security\Core\Authentication\Provider\ProviderTest { private $userProvider = NULL; private $providerKey = NULL; private $encoder = NULL; private $user = NULL; private $nonceCache = NULL; protected $backupGlobals = NULL; protected $backupGlobalsBlacklist = array (); protected $backupStaticAttributes = NULL; protected $backupStaticAttributesBlacklist = array (); protected $runTestInSeparateProcess = NULL; protected $preserveGlobalState = TRUE; private ${PHPUnit_Framework_TestCase}:inIsolation = FALSE; private ${PHPUnit_Framework_TestCase}:data = array (); private ${PHPUnit_Framework_TestCase}:dataName = ''; private ${PHPUnit_Framework_TestCase}:useErrorHandler = NULL; private ${PHPUnit_Framework_TestCase}:useOutputBuffering = NULL; private ${PHPUnit_Framework_TestCase}:expectedException = NULL; private ${PHPUnit_Framework_TestCase}:expectedExceptionMessage = ''; private ${PHPUnit_Framework_TestCase}:expectedExceptionCode = NULL; private ${PHPUnit_Framework_TestCase}:required = array ('PHP' => NULL, 'PHPUnit' => NULL, 'functions' => array (...), 'extensions' => array (...)); private ${PHPUnit_Framework_TestCase}:name = NULL; private ${PHPUnit_Framework_TestCase}:dependencies = array (); private ${PHPUnit_Framework_TestCase}:dependencyInput = array (); private ${PHPUnit_Framework_TestCase}:iniSettings = array (); private ${PHPUnit_Framework_TestCase}:locale = array (); private ${PHPUnit_Framework_TestCase}:mockObjects = array (); private ${PHPUnit_Framework_TestCase}:status = NULL; private ${PHPUnit_Framework_TestCase}:statusMessage = ''; private ${PHPUnit_Framework_TestCase}:numAssertions = 0; private ${PHPUnit_Framework_TestCase}:result = NULL; private ${PHPUnit_Framework_TestCase}:testResult = NULL; private ${PHPUnit_Framework_TestCase}:output = ''; private ${PHPUnit_Framework_TestCase}:outputExpectedRegex = NULL; private ${PHPUnit_Framework_TestCase}:outputExpectedString = NULL; private ${PHPUnit_Framework_TestCase}:hasPerformedExpectationsOnOutput = FALSE; private ${PHPUnit_Framework_TestCase}:outputCallback = FALSE; private ${PHPUnit_Framework_TestCase}:outputBufferingActive = FALSE }) /usr/share/php/PHPUnit/Util/Test.php:262
PHP  15. Escape\WSSEAuthenticationBundle\Tests\Security\Core\Authentication\Provider\ProviderTest->providerSupports() /usr/share/php/PHPUnit/Util/Test.php:262
PHP  16. PHPUnit_Framework_TestCase->getMock($originalClassName = 'Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface', $methods = *uninitialized*, $arguments = *uninitialized*, $mockClassName = *uninitialized*, $callOriginalConstructor = *uninitialized*, $callOriginalClone = *uninitialized*, $callAutoload = *uninitialized*, $cloneArguments = *uninitialized*) /home/felicitus/repos/EscapeWSSEAuthenticationBundle/Tests/Security/Core/Authentication/Provider/ProviderTest.php:98
PHP  17. PHPUnit_Framework_MockObject_Generator::getMock($originalClassName = 'Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface', $methods = array (), $arguments = array (), $mockClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE, $callAutoload = TRUE, $cloneArguments = FALSE) /usr/share/php/PHPUnit/Framework/TestCase.php:1318
PHP  18. PHPUnit_Framework_MockObject_Generator::getObject($code = 'class Mock_TokenInterface_278f77bc implements PHPUnit_Framework_MockObject_MockObject, Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface\n{\n    private static $__phpunit_staticInvocationMocker;\n    private $__phpunit_invocationMocker;\n\n    public function __clone()\n    {\n        $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();\n    }\n\n    public function __toString()\n    {\n        $arguments = array();\n        $count     = func_num_args();\...', $className = 'Mock_TokenInterface_278f77bc', $originalClassName = 'Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface', $callOriginalConstructor = TRUE, $callAutoload = TRUE, $arguments = array ()) /usr/share/php/PHPUnit/Framework/MockObject/Generator.php:216
PHP  19. unserialize('O:28:"Mock_TokenInterface_278f77bc":0:{}') /usr/share/php/PHPUnit/Framework/MockObject/Generator.php:247

Warning: Erroneous data format for unserializing 'Mock_TokenInterface_278f77bc' in /usr/share/php/PHPUnit/Framework/MockObject/Generator.php on line 247
djoos commented 9 years ago

Hi @felicitus,

this doesn't seem to be this bundle's issue to me...

Which version of PHPUnit are you running and which version of PHP?

Thanks in advance!

Kind regards, David

Drachenkaetzchen commented 9 years ago

PHP 5.6.12, phpunit 4.7.6.

Note that this also fails on Travis on PHP 5.5 and PHP 5.6 with a similar message, see this travis log

Here's the complete output:

felicitus@feli-t420s.feli-home.felicitus.org ~/repos # git clone https://github.com/escapestudios/EscapeWSSEAuthenticationBundle.gitCloning into 'EscapeWSSEAuthenticationBundle'...
remote: Counting objects: 961, done.
remote: Total 961 (delta 0), reused 0 (delta 0), pack-reused 961
Receiving objects: 100% (961/961), 139.20 KiB | 0 bytes/s, done.
Resolving deltas: 100% (326/326), done.
Checking connectivity... done.
felicitus@feli-t420s.feli-home.felicitus.org ~/repos # php --version
PHP 5.6.12-1 (cli) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
felicitus@feli-t420s.feli-home.felicitus.org ~/repos # phpunit --version
PHPUnit 4.7.6 by Sebastian Bergmann and contributors.

felicitus@feli-t420s.feli-home.felicitus.org ~/repos # cd EscapeWSSEAuthenticationBundle/
felicitus@feli-t420s.feli-home.felicitus.org ~/repos/EscapeWSSEAuthenticationBundle # composer install
Loading composer repositories with package information
Installing dependencies (including require-dev)
  - Installing symfony/event-dispatcher (dev-master 10133ce)
    Cloning 10133cee322c79d3d4efdc0269eddc5e5c93d76e

  - Installing psr/log (dev-master 9e45edc)
    Cloning 9e45edca52cc9c954680072c93e621f8b71fab26

  - Installing symfony/debug (2.8.x-dev 795e333)
    Cloning 795e333a070c564dde1ac55dff8f774b2970b2b2

  - Installing symfony/http-foundation (dev-master 508a157)
    Cloning 508a1578ba61a2b833e6cff7eb8b32346a7b7391

  - Installing symfony/http-kernel (2.8.x-dev fe76175)
    Cloning fe76175f4d6e59caf5c72e0fd67575dbb3658ccb

  - Installing symfony/translation (2.8.x-dev 606d2ea)
    Cloning 606d2ea556516d9c63f8efe2eba4feda85a0dda1

  - Installing symfony/routing (dev-master 03b684c)
    Cloning 03b684c47465c187c28e6064cd9d97465dc95bcb

  - Installing symfony/dependency-injection (2.8.x-dev e599650)
    Cloning e59965042e6c23db1b4999698eb1d1f55c8075d2

  - Installing doctrine/lexer (dev-master 83893c5)
    Cloning 83893c552fd2045dd78aef794c31e694c37c0b8c

  - Installing doctrine/annotations (dev-master f25c8aa)
    Cloning f25c8aab83e0c3e976fd7d19875f198ccf2f7535

  - Installing symfony/templating (dev-master e6a202e)
    Cloning e6a202ec85b0d73b8c683fd6835d6b2e835a793e

  - Installing symfony/stopwatch (dev-master d6ca061)
    Cloning d6ca061ae5c561463a27c56c97105345eb71d1aa

  - Installing symfony/security (dev-master 4b4674a)
    Cloning 4b4674a5df8797756a24b7790507394258075c10

  - Installing symfony/filesystem (dev-master 062d0c4)
    Cloning 062d0c4b01cfd8ab94957ddf2e9598dcbae2b56a

  - Installing symfony/config (2.8.x-dev a1e8e51)
    Cloning a1e8e51ed2d591bb1827d04fd1d320cd4f03e5fe

  - Installing symfony/asset (dev-master 7b4113b)
    Cloning 7b4113b34fc4220e224a4aec2a89a3d394d94e55

  - Installing symfony/framework-bundle (2.8.x-dev 768a0db)
    Cloning 768a0dbc64fee15ff144399bd3552a4b2d1ca72b

  - Installing symfony/security-acl (dev-master 2b22539)
    Cloning 2b22539c83027c24e06bac933a8d586e683ca335

  - Installing symfony/security-bundle (2.8.x-dev a35afd0)
    Cloning a35afd0b83dca85a2cf671430a3f5489cb89fa4a

  - Installing doctrine/collections (dev-master 866e100)
    Cloning 866e100a425b8b73d15393fd081c6bf067f05bf9

  - Installing doctrine/cache (dev-master dd47003)
    Cloning dd47003641aa5425820c0ec8a6f4a85e7412ffcd

  - Installing doctrine/inflector (dev-master 3a422c7)
    Cloning 3a422c73f7bc556d39571f436b61fd58ccae0eb0

  - Installing doctrine/common (dev-master 9f35e74)
    Cloning 9f35e74fcbe9011b660e0b423e98c83b7a8699c0

  - Installing symfony/finder (2.8.x-dev 142440d)
    Cloning 142440d48e10fd4b4f2ffb2d72fa0aad6f03cacf

symfony/http-kernel suggests installing symfony/browser-kit ()
symfony/http-kernel suggests installing symfony/class-loader ()
symfony/http-kernel suggests installing symfony/console ()
symfony/http-kernel suggests installing symfony/var-dumper ()
symfony/translation suggests installing symfony/yaml ()
symfony/routing suggests installing symfony/yaml (For using the YAML loader)
symfony/routing suggests installing symfony/expression-language (For using expression matching)
symfony/dependency-injection suggests installing symfony/yaml ()
symfony/dependency-injection suggests installing symfony/proxy-manager-bridge (Generate service proxies to lazy load them)
symfony/security suggests installing symfony/class-loader (For using the ACL generateSql script)
symfony/security suggests installing symfony/validator (For using the user password constraint)
symfony/security suggests installing doctrine/dbal (For using the built-in ACL implementation)
symfony/security suggests installing symfony/expression-language (For using the expression voter)
symfony/framework-bundle suggests installing symfony/console (For using the console commands)
symfony/framework-bundle suggests installing symfony/form (For using forms)
symfony/framework-bundle suggests installing symfony/validator (For using validation)
symfony/framework-bundle suggests installing symfony/yaml (For using the debug:config and lint:yaml commands)
symfony/framework-bundle suggests installing symfony/serializer (For using the serializer service)
symfony/security-acl suggests installing symfony/class-loader (For using the ACL generateSql script)
symfony/security-acl suggests installing doctrine/dbal (For using the built-in ACL implementation)
Writing lock file
Generating autoload files
felicitus@feli-t420s.feli-home.felicitus.org ~/repos/EscapeWSSEAuthenticationBundle # phpunit 
PHPUnit 4.7.6 by Sebastian Bergmann and contributors.

............................PHP Fatal error:  Call to undefined method Mock_SecurityContextInterface_9519890b::setToken() in /home/felicitus/repos/EscapeWSSEAuthenticationBundle/Security/Http/Firewall/Listener.php on line 88
djoos commented 9 years ago

Thanks @felicitus: I'll look into it and will get back to you!

djoos commented 8 years ago

Could you give this another go? This should now be fixed...

Thanks! David