Skip to content

Commit

Permalink
upgrade to lightsaml/symfony-bridge 1.3 to support symfony 4
Browse files Browse the repository at this point in the history
  • Loading branch information
tmilos committed May 23, 2018
1 parent b3cf8d9 commit 91d2470
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 49 deletions.
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ 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();
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|\LightSaml\Builder\Profile\ProfileBuilderInterface
*/
private function getProfileBuilderMock()
{
return $this->getMock(\LightSaml\Builder\Profile\ProfileBuilderInterface::class);
return $this->getMockBuilder(\LightSaml\Builder\Profile\ProfileBuilderInterface::class)->getMock();
}

/**
Expand All @@ -71,14 +71,14 @@ private function getContextMock()
*/
private function getActionMock()
{
return $this->getMock(\LightSaml\Action\ActionInterface::class);
return $this->getMockBuilder(\LightSaml\Action\ActionInterface::class)->getMock();
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|\LightSaml\Context\Profile\HttpResponseContext
*/
private function getHttpResponseContextMock()
{
return $this->getMock(\LightSaml\Context\Profile\HttpResponseContext::class);
return $this->getMockBuilder(\LightSaml\Context\Profile\HttpResponseContext::class)->getMock();
}
}
18 changes: 15 additions & 3 deletions tests/LightSaml/SpBundle/Tests/Functional/FunctionalTest.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
<?php

namespace LightSaml\SpBundle\Tests\Controller;
namespace LightSaml\SpBundle\Tests\Functional;

use LightSaml\State\Sso\SsoSessionState;
use LightSaml\State\Sso\SsoState;
use LightSaml\Store\Sso\SsoStateStoreInterface;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpFoundation\Session\SessionInterface;

class FunctionalTest extends WebTestCase
{
const OWN_ENTITY_ID = 'https://localhost/lightSAML/SPBundle';

protected function setUp()
{
parent::setUp();
require_once __DIR__.'/app/AppKernel.php';
$_SERVER['KERNEL_CLASS'] = \AppKernel::class;
$_SERVER['KERNEL_DIR'] = __DIR__.'/app';
$fs = new Filesystem();
$fs->remove(__DIR__.'/app/cache');
}


public function test_metadata()
{
$client = static::createClient();
Expand Down Expand Up @@ -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');

Expand Down Expand Up @@ -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);

Expand Down
19 changes: 12 additions & 7 deletions tests/LightSaml/SpBundle/Tests/Functional/app/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ framework:
csrf_protection: ~
templating: { engines: ['twig'] }
session:
handler_id: session.handler.native_file
storage_id: session.mock_storage

monolog:
handlers:
Expand All @@ -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:
Expand All @@ -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
4 changes: 2 additions & 2 deletions tests/LightSaml/SpBundle/Tests/LightSamlSpBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ 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();
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|\Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension
*/
private function getExtensionMock()
{
return $this->getMock(\Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension::class);
return $this->getMockBuilder(\Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension::class)->getMock();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

/**
Expand Down Expand Up @@ -460,54 +460,54 @@ 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();
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|\Symfony\Component\Security\Core\User\UserInterface
*/
private function getUserMock()
{
return $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
return $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock();
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|\Symfony\Component\Security\Core\User\UserProviderInterface
*/
private function getUserProviderMock()
{
return $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface');
return $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserProviderInterface::class)->getMock();
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|\LightSaml\SpBundle\Security\User\UsernameMapperInterface
*/
private function getUsernameMapperMock()
{
return $this->getMock(UsernameMapperInterface::class);
return $this->getMockBuilder(UsernameMapperInterface::class)->getMock();
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|\LightSaml\SpBundle\Security\User\UserCreatorInterface
*/
private function getUserCreatorMock()
{
return $this->getMock(UserCreatorInterface::class);
return $this->getMockBuilder(UserCreatorInterface::class)->getMock();
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|\LightSaml\SpBundle\Security\User\AttributeMapperInterface
*/
private function getAttributeMapperMock()
{
return $this->getMock(AttributeMapperInterface::class);
return $this->getMockBuilder(AttributeMapperInterface::class)->getMock();
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|SamlSpTokenFactoryInterface
*/
private function getTokenFactoryMock()
{
return $this->getMock(SamlSpTokenFactoryInterface::class);
return $this->getMockBuilder(SamlSpTokenFactoryInterface::class)->getMock();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,39 +109,39 @@ private function getContextMock()
*/
private function getActionMock()
{
return $this->getMock(\LightSaml\Action\ActionInterface::class);
return $this->getMockBuilder(\LightSaml\Action\ActionInterface::class)->getMock();
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|\LightSaml\Builder\Profile\ProfileBuilderInterface
*/
private function getProfileBuilderMock()
{
return $this->getMock(\LightSaml\Builder\Profile\ProfileBuilderInterface::class);
return $this->getMockBuilder(\LightSaml\Builder\Profile\ProfileBuilderInterface::class)->getMock();
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|\Symfony\Component\HttpFoundation\Request
*/
private function getRequestMock()
{
return $this->getMock(\Symfony\Component\HttpFoundation\Request::class);
return $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->getMock();
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|\Symfony\Component\HttpFoundation\Response
*/
private function getResponseMock()
{
return $this->getMock(\Symfony\Component\HttpFoundation\Response::class);
return $this->getMockBuilder(\Symfony\Component\HttpFoundation\Response::class)->getMock();
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|\Symfony\Component\HttpFoundation\Session\SessionInterface
*/
private function getSessionMock()
{
return $this->getMock(\Symfony\Component\HttpFoundation\Session\SessionInterface::class);
return $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\SessionInterface::class)->getMock();
}

/**
Expand All @@ -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();
}
}

Expand All @@ -171,38 +171,38 @@ 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();
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|\Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface
*/
private function getSessionAuthenticationStrategyMock()
{
return $this->getMock(\Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface::class);
return $this->getMockBuilder(\Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface::class)->getMock();
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|\Symfony\Component\Security\Http\HttpUtils
*/
private function getHttpUtilsMock()
{
return $this->getMock(\Symfony\Component\Security\Http\HttpUtils::class);
return $this->getMockBuilder(\Symfony\Component\Security\Http\HttpUtils::class)->getMock();
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|\Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface
*/
private function getAuthenticationSuccessHandlerMock()
{
return $this->getMock(\Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface::class);
return $this->getMockBuilder(\Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface::class)->getMock();
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|\Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface
*/
private function getAuthenticationFailureHandlerMock()
{
return $this->getMock(\Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface::class);
return $this->getMockBuilder(\Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface::class)->getMock();
}
}

0 comments on commit 91d2470

Please sign in to comment.