diff --git a/.travis.yml b/.travis.yml index 6ae33a8..d215c77 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,20 +15,20 @@ matrix: env: COMPOSER_FLAGS="--prefer-lowest" before_install: - - if [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then INI_FILE=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; else INI_FILE=/etc/hhvm/php.ini; fi; - - echo "memory_limit = -1" >> $INI_FILE - - echo "session.gc_probability = 0" >> $INI_FILE + - echo "memory_limit = -1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini + - echo "session.gc_probability = 0" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - composer self-update - composer --version - if [ "$TRAVIS_PHP_VERSION" == "7.1" ]; then wget http://get.sensiolabs.org/php-cs-fixer.phar -O php-cs-fixer.phar; fi - if [ "$TRAVIS_PHP_VERSION" == "7.1" ]; then php php-cs-fixer.phar --version; fi + - if [ "$TRAVIS_PHP_VERSION" == "7.1" ]; then wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.1.0/php-coveralls.phar; fi install: - - COMPOSER_ROOT_VERSION=dev-master composer update --prefer-source $COMPOSER_FLAGS + - COMPOSER_ROOT_VERSION=dev-master composer update --prefer-source --no-interaction $COMPOSER_FLAGS script: - if [ "$TRAVIS_PHP_VERSION" == "7.1" ]; then php php-cs-fixer.phar fix --dry-run -v; fi - if [ "$TRAVIS_PHP_VERSION" == "7.1" ]; then bin/phpunit --coverage-clover build/logs/clover.xml; else bin/phpunit; fi after_script: - - if [[ "$TRAVIS_PHP_VERSION" == "7.1" ]]; then php bin/coveralls -v; fi; + - if [[ "$TRAVIS_PHP_VERSION" == "7.1" ]]; then php php-coveralls.phar -v; fi; diff --git a/composer.json b/composer.json index 827e6d4..a6cc9c4 100644 --- a/composer.json +++ b/composer.json @@ -19,16 +19,16 @@ } }, "require": { - "php": ">=5.5.1", - "symfony/framework-bundle": "~2.3|~3.0|~4.0", - "symfony/security-bundle": "~2.3|~3.0|~4.0", - "lightsaml/symfony-bridge": "~1.0" + "php": ">=5.6", + "symfony/framework-bundle": "~2.7|~3.0|~4.0", + "symfony/security-bundle": "~2.7|~3.0|~4.0", + "lightsaml/symfony-bridge": "~1.3" }, "require-dev": { - "phpunit/phpunit": "~4.6|~5.3", - "symfony/symfony": "~2.3|~3.0|~4.0", - "symfony/monolog-bundle": "~2.3|~3.0|~4.0", - "satooshi/php-coveralls": "~0.6" + "phpunit/phpunit": "^5.7", + "sebastian/comparator": "^1.2.4|~2.0|~3.0", + "symfony/symfony": "~2.7|~3.0|~4.0", + "symfony/monolog-bundle": "~2.7|~3.0|~4.0" }, "config": { "bin-dir": "bin" diff --git a/tests/LightSaml/SpBundle/Tests/Controller/DefaultControllerTest.php b/tests/LightSaml/SpBundle/Tests/Controller/DefaultControllerTest.php index b3ae9ef..68d3dc5 100644 --- a/tests/LightSaml/SpBundle/Tests/Controller/DefaultControllerTest.php +++ b/tests/LightSaml/SpBundle/Tests/Controller/DefaultControllerTest.php @@ -45,7 +45,7 @@ public function test_metadata_action_returns_response_from_profile() */ private function getContainerMock() { - return $this->getMock(\Symfony\Component\DependencyInjection\ContainerInterface::class); + return $this->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)->getMock(); } /** @@ -53,7 +53,7 @@ private function getContainerMock() */ private function getProfileBuilderMock() { - return $this->getMock(\LightSaml\Builder\Profile\ProfileBuilderInterface::class); + return $this->getMockBuilder(\LightSaml\Builder\Profile\ProfileBuilderInterface::class)->getMock(); } /** @@ -71,7 +71,7 @@ private function getContextMock() */ private function getActionMock() { - return $this->getMock(\LightSaml\Action\ActionInterface::class); + return $this->getMockBuilder(\LightSaml\Action\ActionInterface::class)->getMock(); } /** @@ -79,6 +79,6 @@ private function getActionMock() */ private function getHttpResponseContextMock() { - return $this->getMock(\LightSaml\Context\Profile\HttpResponseContext::class); + return $this->getMockBuilder(\LightSaml\Context\Profile\HttpResponseContext::class)->getMock(); } } diff --git a/tests/LightSaml/SpBundle/Tests/Functional/FunctionalTest.php b/tests/LightSaml/SpBundle/Tests/Functional/FunctionalTest.php index d872d55..d88d818 100644 --- a/tests/LightSaml/SpBundle/Tests/Functional/FunctionalTest.php +++ b/tests/LightSaml/SpBundle/Tests/Functional/FunctionalTest.php @@ -1,17 +1,29 @@ remove(__DIR__.'/app/cache'); + } + + public function test_metadata() { $client = static::createClient(); @@ -52,7 +64,7 @@ public function test_discovery() public function test_login() { $client = static::createClient(); - $client->getContainer()->set('session', $sessionMock = $this->getMock(SessionInterface::class)); + $client->getContainer()->set('session', $sessionMock = $this->getMockBuilder(SessionInterface::class)->getMock()); $crawler = $client->request('GET', '/saml/login?idp=https://localhost/lightSAML/lightSAML-IDP'); @@ -80,7 +92,7 @@ public function test_sessions() $ssoState->addSsoSession((new SsoSessionState())->setIdpEntityId('idp1')->setSpEntityId('sp1')); $ssoState->addSsoSession((new SsoSessionState())->setIdpEntityId('idp2')->setSpEntityId('sp2')); - $ssoStateStoreMock = $this->getMock(SsoStateStoreInterface::class); + $ssoStateStoreMock = $this->getMockBuilder(SsoStateStoreInterface::class)->getMock(); $ssoStateStoreMock->method('get') ->willReturn($ssoState); diff --git a/tests/LightSaml/SpBundle/Tests/Functional/app/config.yml b/tests/LightSaml/SpBundle/Tests/Functional/app/config.yml index 8fce629..ffcf731 100644 --- a/tests/LightSaml/SpBundle/Tests/Functional/app/config.yml +++ b/tests/LightSaml/SpBundle/Tests/Functional/app/config.yml @@ -5,7 +5,7 @@ framework: csrf_protection: ~ templating: { engines: ['twig'] } session: - handler_id: session.handler.native_file + storage_id: session.mock_storage monolog: handlers: @@ -15,7 +15,7 @@ monolog: handler: nested nested: type: stream - path: %kernel.logs_dir%/%kernel.environment%.log + path: "%kernel.logs_dir%/%kernel.environment%.log" level: debug security: @@ -32,18 +32,23 @@ light_saml_symfony_bridge: entity_id: https://localhost/lightSAML/SPBundle credentials: - - certificate: %kernel.root_dir%/../../../../../../vendor/lightsaml/lightsaml/web/sp/saml.crt - key: %kernel.root_dir%/../../../../../../vendor/lightsaml/lightsaml/web/sp/saml.key + certificate: "%kernel.root_dir%/../../../../../../vendor/lightsaml/lightsaml/web/sp/saml.crt" + key: "%kernel.root_dir%/../../../../../../vendor/lightsaml/lightsaml/web/sp/saml.key" password: ~ party: idp: files: - - %kernel.root_dir%/../../../../../../vendor/lightsaml/lightsaml/web/sp/openidp.feide.no.xml - - %kernel.root_dir%/../../../../../../vendor/lightsaml/lightsaml/web/sp/localhost-lightsaml-lightsaml-idp.xml - - %kernel.root_dir%/../../../../../../vendor/lightsaml/lightsaml/web/sp/testshib-providers.xml + - "%kernel.root_dir%/../../../../../../vendor/lightsaml/lightsaml/web/sp/openidp.feide.no.xml" + - "%kernel.root_dir%/../../../../../../vendor/lightsaml/lightsaml/web/sp/localhost-lightsaml-lightsaml-idp.xml" + - "%kernel.root_dir%/../../../../../../vendor/lightsaml/lightsaml/web/sp/testshib-providers.xml" store: id_state: id_store services: + session.mock_storage: + class: Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage id_store: class: LightSaml\Store\Id\IdArrayStore + lightsaml.store.sso_state: + class: LightSaml\Store\Sso\SsoStateFixedStore + public: true \ No newline at end of file diff --git a/tests/LightSaml/SpBundle/Tests/LightSamlSpBundleTest.php b/tests/LightSaml/SpBundle/Tests/LightSamlSpBundleTest.php index 1dc0d2c..e9a9d1b 100644 --- a/tests/LightSaml/SpBundle/Tests/LightSamlSpBundleTest.php +++ b/tests/LightSaml/SpBundle/Tests/LightSamlSpBundleTest.php @@ -28,7 +28,7 @@ public function test_build_adds_security_extension() */ private function getContainerBuilderMock() { - return $this->getMock(\Symfony\Component\DependencyInjection\ContainerBuilder::class); + return $this->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerBuilder::class)->getMock(); } /** @@ -36,6 +36,6 @@ private function getContainerBuilderMock() */ private function getExtensionMock() { - return $this->getMock(\Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension::class); + return $this->getMockBuilder(\Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension::class)->getMock(); } } diff --git a/tests/LightSaml/SpBundle/Tests/Security/Authentication/Provider/LightsSamlSpAuthenticationProviderTest.php b/tests/LightSaml/SpBundle/Tests/Security/Authentication/Provider/LightsSamlSpAuthenticationProviderTest.php index ec74c46..ebb9486 100755 --- a/tests/LightSaml/SpBundle/Tests/Security/Authentication/Provider/LightsSamlSpAuthenticationProviderTest.php +++ b/tests/LightSaml/SpBundle/Tests/Security/Authentication/Provider/LightsSamlSpAuthenticationProviderTest.php @@ -365,7 +365,7 @@ public function test_calls_token_factory_if_provided() public function test_throws_logic_exception_on_unsupported_token() { $provider = new LightsSamlSpAuthenticationProvider('main'); - $provider->authenticate($this->getMock(TokenInterface::class)); + $provider->authenticate($this->getMockBuilder(TokenInterface::class)->getMock()); } /** @@ -460,7 +460,7 @@ public function test_throws_authentication_exception_when_unable_to_resolve_user */ private function getUserCheckerMock() { - return $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface'); + return $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock(); } /** @@ -468,7 +468,7 @@ private function getUserCheckerMock() */ private function getUserMock() { - return $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + return $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); } /** @@ -476,7 +476,7 @@ private function getUserMock() */ private function getUserProviderMock() { - return $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface'); + return $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserProviderInterface::class)->getMock(); } /** @@ -484,7 +484,7 @@ private function getUserProviderMock() */ private function getUsernameMapperMock() { - return $this->getMock(UsernameMapperInterface::class); + return $this->getMockBuilder(UsernameMapperInterface::class)->getMock(); } /** @@ -492,7 +492,7 @@ private function getUsernameMapperMock() */ private function getUserCreatorMock() { - return $this->getMock(UserCreatorInterface::class); + return $this->getMockBuilder(UserCreatorInterface::class)->getMock(); } /** @@ -500,7 +500,7 @@ private function getUserCreatorMock() */ private function getAttributeMapperMock() { - return $this->getMock(AttributeMapperInterface::class); + return $this->getMockBuilder(AttributeMapperInterface::class)->getMock(); } /** @@ -508,6 +508,6 @@ private function getAttributeMapperMock() */ private function getTokenFactoryMock() { - return $this->getMock(SamlSpTokenFactoryInterface::class); + return $this->getMockBuilder(SamlSpTokenFactoryInterface::class)->getMock(); } } diff --git a/tests/LightSaml/SpBundle/Tests/Security/Firewall/LightSamlSpListenerTest.php b/tests/LightSaml/SpBundle/Tests/Security/Firewall/LightSamlSpListenerTest.php index 6c4586a..9c81a5e 100644 --- a/tests/LightSaml/SpBundle/Tests/Security/Firewall/LightSamlSpListenerTest.php +++ b/tests/LightSaml/SpBundle/Tests/Security/Firewall/LightSamlSpListenerTest.php @@ -109,7 +109,7 @@ private function getContextMock() */ private function getActionMock() { - return $this->getMock(\LightSaml\Action\ActionInterface::class); + return $this->getMockBuilder(\LightSaml\Action\ActionInterface::class)->getMock(); } /** @@ -117,7 +117,7 @@ private function getActionMock() */ private function getProfileBuilderMock() { - return $this->getMock(\LightSaml\Builder\Profile\ProfileBuilderInterface::class); + return $this->getMockBuilder(\LightSaml\Builder\Profile\ProfileBuilderInterface::class)->getMock(); } /** @@ -125,7 +125,7 @@ private function getProfileBuilderMock() */ private function getRequestMock() { - return $this->getMock(\Symfony\Component\HttpFoundation\Request::class); + return $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->getMock(); } /** @@ -133,7 +133,7 @@ private function getRequestMock() */ private function getResponseMock() { - return $this->getMock(\Symfony\Component\HttpFoundation\Response::class); + return $this->getMockBuilder(\Symfony\Component\HttpFoundation\Response::class)->getMock(); } /** @@ -141,7 +141,7 @@ private function getResponseMock() */ private function getSessionMock() { - return $this->getMock(\Symfony\Component\HttpFoundation\Session\SessionInterface::class); + return $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\SessionInterface::class)->getMock(); } /** @@ -160,9 +160,9 @@ private function getGetResponseEventMock() private function getTokenStorageMock() { if (class_exists('\Symfony\Bundle\SecurityBundle\Command\UserPasswordEncoderCommand')) { - return $this->getMock(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class); + return $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); } else { // for symfony/security-bundle <= 2.6 - return $this->getMock(\Symfony\Component\Security\Core\SecurityContextInterface::class); + return $this->getMockBuilder(\Symfony\Component\Security\Core\SecurityContextInterface::class)->getMock(); } } @@ -171,7 +171,7 @@ private function getTokenStorageMock() */ private function getAuthenticationManagerMock() { - return $this->getMock(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class); + return $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(); } /** @@ -179,7 +179,7 @@ private function getAuthenticationManagerMock() */ private function getSessionAuthenticationStrategyMock() { - return $this->getMock(\Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface::class); + return $this->getMockBuilder(\Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface::class)->getMock(); } /** @@ -187,7 +187,7 @@ private function getSessionAuthenticationStrategyMock() */ private function getHttpUtilsMock() { - return $this->getMock(\Symfony\Component\Security\Http\HttpUtils::class); + return $this->getMockBuilder(\Symfony\Component\Security\Http\HttpUtils::class)->getMock(); } /** @@ -195,7 +195,7 @@ private function getHttpUtilsMock() */ private function getAuthenticationSuccessHandlerMock() { - return $this->getMock(\Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface::class); + return $this->getMockBuilder(\Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface::class)->getMock(); } /** @@ -203,6 +203,6 @@ private function getAuthenticationSuccessHandlerMock() */ private function getAuthenticationFailureHandlerMock() { - return $this->getMock(\Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface::class); + return $this->getMockBuilder(\Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface::class)->getMock(); } }