InMemoryAccessTokenHandler example

use Symfony\Component\Security\Http\Tests\Authenticator\InMemoryAccessTokenHandler;

class HeaderAccessTokenAuthenticatorTest extends TestCase
{
    private InMemoryUserProvider $userProvider;
    private AccessTokenAuthenticator $authenticator;
    private AccessTokenHandlerInterface $accessTokenHandler;

    protected function setUp(): void
    {
        $this->userProvider = new InMemoryUserProvider();
        $this->accessTokenHandler = new InMemoryAccessTokenHandler();
    }

    /** * @dataProvider provideSupportData */
    public function testSupport($request)
    {
        $this->setUpAuthenticator();

        $this->assertNull($this->authenticator->supports($request));
    }

    
use Symfony\Component\Security\Http\Tests\Authenticator\InMemoryAccessTokenHandler;

class QueryAccessTokenAuthenticatorTest extends TestCase
{
    private InMemoryUserProvider $userProvider;
    private AccessTokenAuthenticator $authenticator;
    private AccessTokenHandlerInterface $accessTokenHandler;

    protected function setUp(): void
    {
        $this->userProvider = new InMemoryUserProvider();
        $this->accessTokenHandler = new InMemoryAccessTokenHandler();
    }

    public function testSupport()
    {
        $this->setUpAuthenticator();
        $request = new Request();
        $request->query->set('access_token', 'INVALID_ACCESS_TOKEN');

        $this->assertNull($this->authenticator->supports($request));
    }

    
use Symfony\Component\Security\Http\Tests\Authenticator\InMemoryAccessTokenHandler;

class FormEncodedBodyAccessTokenAuthenticatorTest extends TestCase
{
    private InMemoryUserProvider $userProvider;
    private AccessTokenAuthenticator $authenticator;
    private AccessTokenHandlerInterface $accessTokenHandler;

    protected function setUp(): void
    {
        $this->userProvider = new InMemoryUserProvider();
        $this->accessTokenHandler = new InMemoryAccessTokenHandler();
    }

    public function testSupport()
    {
        $this->setUpAuthenticator();
        $request = new Request([][][][][]['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
        $request->request->set('access_token', 'INVALID_ACCESS_TOKEN');
        $request->setMethod(Request::METHOD_POST);

        $this->assertNull($this->authenticator->supports($request));
    }

    
use Symfony\Component\Security\Http\Tests\Authenticator\InMemoryAccessTokenHandler;

class ChainedAccessTokenExtractorsTest extends TestCase
{
    private InMemoryUserProvider $userProvider;
    private AccessTokenAuthenticator $authenticator;
    private AccessTokenHandlerInterface $accessTokenHandler;

    protected function setUp(): void
    {
        $this->userProvider = new InMemoryUserProvider();
        $this->accessTokenHandler = new InMemoryAccessTokenHandler();
    }

    /** * @dataProvider provideSupportData */
    public function testSupport($request)
    {
        $this->setUpAuthenticator();

        $this->assertNull($this->authenticator->supports($request));
    }

    
Home | Imprint | This part of the site doesn't use cookies.