<commit_before><?php
namespace Bolt\Tests;

use Bolt\AccessControl\AccessChecker;
use Bolt\AccessControl\Token\Token;
use Bolt\Storage\Entity;
use Symfony\Component\HttpFoundation\Request;

/**
 * Test for AccessControl\AccessChecker
 *
 * @author <NAME> <<EMAIL>>
 */
class AccessCheckerTest extends BoltUnitTest
{
    public function tearDown()
    {
        $this->resetDb();
    }

    public function testLoadAccessControl()
    {
        $accessControl = $this->getAccessControl();
        $this->assertInstanceOf('Bolt\AccessControl\AccessChecker', $accessControl);
    }

    public function testIsValidSessionNoCookie()
    {
        $accessControl = $this->getAccessControl();
        $this->assertInstanceOf('Bolt\AccessControl\AccessChecker', $accessControl);

        $response = $accessControl->isValidSession(null);
        $this->assertFalse($response);
    }
<commit_msg>[Tests] AccessControl\AccessChecker::IsValidSession() invalid user name<commit_after><?php
namespace Bolt\Tests;

use Bolt\AccessControl\AccessChecker;
use Bolt\AccessControl\Token\Token;
use Bolt\Storage\Entity;
use Symfony\Component\HttpFoundation\Request;

/**
 * Test for AccessControl\AccessChecker
 *
 * @author <NAME> <<EMAIL>>
 */
class AccessCheckerTest extends BoltUnitTest
{
    public function tearDown()
    {
        $this->resetDb();
    }

    public function testLoadAccessControl()
    {
        $accessControl = $this->getAccessControl();
        $this->assertInstanceOf('Bolt\AccessControl\AccessChecker', $accessControl);
    }

    public function testIsValidSessionNoCookie()
    {
        $accessControl = $this->getAccessControl();
        $this->assertInstanceOf('Bolt\AccessControl\AccessChecker', $accessControl);

        $response = $accessControl->isValidSession(null);
        $this->assertFalse($response);
    }


    /**
     * @expectedException        \InvalidArgumentException
     * @expectedExceptionMessage getAuthToken required a name and salt to be provided.
     */
    public function testIsValidSessionInvalidUsername()
    {
        $app = $this->getApp();

        $userEntity = new Entity\Users();
        $tokenEntity = new Entity\Authtoken();

        $userEntity->setUsername(null);
        $tokenEntity->setSalt('vinagre');

        $token = new Token($userEntity, $tokenEntity);

        $app['session']->start();
        $app['session']->set('authentication', $token);

        $accessControl = $this->getAccessControl();
        $this->assertInstanceOf('Bolt\AccessControl\AccessChecker', $accessControl);

        $response = $accessControl->isValidSession($token);
        $this->assertFalse($response);
    }

{'fraction_non_alphanumeric': 0.1302710843373494, 'fraction_numerical': 0.0, 'mean_word_length': 3.5652920962199315, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4623151', 'n_tokens_mistral': 739, 'n_tokens_neox': 738, 'n_words': 127}