Skip to content

Commit

Permalink
tests: fix tests
Browse files Browse the repository at this point in the history
Add missing binding and reorganize constructor parameters
  • Loading branch information
drupol committed Mar 1, 2023
1 parent 87109f6 commit 1dc9838
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 39 deletions.
39 changes: 6 additions & 33 deletions spec/EcPhp/CasBundle/Security/CasAuthenticatorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
use EcPhp\CasLib\Response\Factory\ProxyFailureFactory;
use EcPhp\CasLib\Response\Factory\ServiceValidateFactory;
use loophp\psr17\Psr17;
use loophp\UnalteredPsrHttpMessageBridgeBundle\Factory\UnalteredPsrHttpFactory;
use Nyholm\Psr7\Factory\Psr17Factory;
use Nyholm\Psr7\Response;
use Nyholm\Psr7\ServerRequest;
Expand All @@ -42,29 +41,6 @@ class CasAuthenticatorSpec extends ObjectBehavior
{
public function it_can_check_if_authentication_is_supported_when_a_user_is_logged_in()
{
$cas = $this->getCas();

$psr17Factory = new Psr17Factory();

$psrHttpMessageFactory = new PsrHttpFactory(
$psr17Factory,
$psr17Factory,
$psr17Factory,
$psr17Factory
);

$casResponseBuilder = new CasResponseBuilder(
new AuthenticationFailureFactory(),
new ProxyFactory(),
new ProxyFailureFactory(),
new ServiceValidateFactory()
);

$casUserProvider = new CasUserProvider($casResponseBuilder, $psrHttpMessageFactory);

$this
->beConstructedWith($cas, $casUserProvider);

$this
->supports(Request::create('http://app'))
->shouldReturn(false);
Expand Down Expand Up @@ -101,7 +77,7 @@ public function it_can_check_if_authentication_is_supported_when_url_contains_a_

$casUserProvider = new CasUserProvider($casResponseBuilder, $psrHttpMessageFactory);

$this->beConstructedWith($cas, $casUserProvider);
$this->beConstructedWith($cas, $casUserProvider, new HttpFoundationFactory());

$this
->supports($requestOk)
Expand Down Expand Up @@ -134,7 +110,7 @@ public function it_can_check_if_authentication_is_supported_when_url_does_not_co

$casUserProvider = new CasUserProvider($casResponseBuilder, $psrHttpMessageFactory);

$this->beConstructedWith($cas, $casUserProvider);
$this->beConstructedWith($cas, $casUserProvider, new HttpFoundationFactory());

$this
->supports($requestNotOk)
Expand Down Expand Up @@ -181,7 +157,7 @@ public function it_can_check_the_credentials_when_service_and_ticket_parameters_

$casUserProvider = new CasUserProvider($casResponseBuilder, $psrHttpMessageFactory);

$this->beConstructedWith($cas, $casUserProvider);
$this->beConstructedWith($cas, $casUserProvider, new HttpFoundationFactory());

$this
->authenticate($request)
Expand Down Expand Up @@ -255,7 +231,7 @@ public function it_can_get_the_user_from_the_response(

$casUserProvider = new CasUserProvider($casResponseBuilder, $psrHttpMessageFactory);

$this->beConstructedWith($cas, $casUserProvider);
$this->beConstructedWith($cas, $casUserProvider, new HttpFoundationFactory());

$passport = $this
->authenticate($request);
Expand Down Expand Up @@ -343,7 +319,7 @@ public function it_cannot_check_the_credentials_when_ticket_is_missing(

$casUserProvider = new CasUserProvider($casResponseBuilder, $psrHttpMessageFactory);

$this->beConstructedWith($cas, $casUserProvider);
$this->beConstructedWith($cas, $casUserProvider, new HttpFoundationFactory());

$this
->shouldThrow(AuthenticationException::class)
Expand Down Expand Up @@ -391,12 +367,9 @@ public function let()
new ServiceValidateFactory()
);

$unalteredPsrHttpMessageFactory = new UnalteredPsrHttpFactory($psrHttpMessageFactory, $psr17Factory);

$casUserProvider = new CasUserProvider($casResponseBuilder, $psrHttpMessageFactory);

$this
->beConstructedWith($cas, $casUserProvider);
$this->beConstructedWith($cas, $casUserProvider, new HttpFoundationFactory());
}

private function getCas(): SymfonyCasInterface
Expand Down
4 changes: 0 additions & 4 deletions src/Resources/config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use EcPhp\CasBundle\Controller\Logout;
use EcPhp\CasBundle\Controller\ProxyCallback;
use EcPhp\CasBundle\Security\CasAuthenticator;
use EcPhp\CasBundle\Security\CasEntryPoint;
use EcPhp\CasBundle\Security\Core\User\CasUserProvider;
use EcPhp\CasBundle\Security\Core\User\CasUserProviderInterface;
use EcPhp\CasLib\Cas;
Expand Down Expand Up @@ -105,7 +104,4 @@
$services
->set(ProxyCallback::class)
->tag('controller.service_arguments');

$services
->set(CasEntryPoint::class);
};
4 changes: 2 additions & 2 deletions src/Security/CasAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
final class CasAuthenticator extends AbstractAuthenticator implements AuthenticationEntryPointInterface
{
public function __construct(
private readonly SymfonyCasInterface $cas,
private readonly CasUserProviderInterface $userProvider,
private readonly HttpFoundationFactoryInterface $httpFoundationFactory,
private readonly SymfonyCasInterface $cas
private readonly HttpFoundationFactoryInterface $httpFoundationFactory
) {
}

Expand Down

0 comments on commit 1dc9838

Please sign in to comment.