<?php

namespace App\Tests\Controller;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class OAuthControllerTest extends WebTestCase
{
    public function testSsoLoginRedirectsToKeycloak(): void
    {
        $client = static::createClient();
        $client->request('GET', '/connection/sso/login');

        self::assertResponseRedirects();
        self::assertStringContainsString('auth.esy-web.dev', $client->getResponse()->headers->get('Location'));
    }

    public function testSsoLogoutRedirectsToHome(): void
    {
        $client = static::createClient();
        $client->request('GET', '/connection/sso/logout');

        self::assertResponseRedirects('/');
    }

    public function testSsoCheckRedirectsToLogin(): void
    {
        $client = static::createClient();
        $client->request('GET', '/connection/sso/check');

        // Without OAuth token, the authenticator redirects to login
        self::assertResponseRedirects();
    }
}
