<commit_before><?php

namespace live627\AddonHelper\Tests;

use live627\AddonHelper\ServiceProvider;

require_once(__DIR__ . '/OharaTest.php');

class MockNonce extends \live627\AddonHelper\Nonce
{
    public function checkAttack()
    {
        try
        {
            $this->check();
            $result = 'CSRF check passed';
        }
        catch (\Exception $e)
        {
            // CSRF attack detected
            $result = $e->getMessage();
        }
        return $result;
    }
}

class NonceTest extends \PHPUnit_Framework_TestCase
{
    protected $loader;

    /**
     * @var Symfony\Component\HttpFoundation\Request
     */
    private $request;

    protected function setUp()
    {
		$obj=new MockOhara;
        $this->loader = new MockNonce($obj);
        $this->request = $obj->getContainer()->get('request');
    }

    public function testKey()
    {
        $actual = $this->loader->getKey();
        $this->assertContains('csrf_', $actual);

        $this->loader->setKey('trolololol');
        $actual = $this->loader->getKey();
        $this->assertSame('trolololol', $actual);
    }

    public function testTtl()
    {
        $actual = $this->loader->getTtl();
        $this->assertSame(900, $actual);

        $this->loader->setTtl(90);
        $actual = $this->loader->getTtl();
        $this->assertSame(90, $actual);
    }

    public function testMissingSessionToken()<commit_msg>test invalid ttl<commit_after><?php

namespace live627\AddonHelper\Tests;

use live627\AddonHelper\ServiceProvider;

require_once(__DIR__ . '/OharaTest.php');

class MockNonce extends \live627\AddonHelper\Nonce
{
    public function checkAttack()
    {
        try
        {
            $this->check();
            $result = 'CSRF check passed';
        }
        catch (\Exception $e)
        {
            // CSRF attack detected
            $result = $e->getMessage();
        }
        return $result;
    }
}

class NonceTest extends \PHPUnit_Framework_TestCase
{
    protected $loader;

    /**
     * @var Symfony\Component\HttpFoundation\Request
     */
    private $request;

    protected function setUp()
    {
		$obj=new MockOhara;
        $this->loader = new MockNonce($obj);
        $this->request = $obj->getContainer()->get('request');
    }

    public function testKey()
    {
        $actual = $this->loader->getKey();
        $this->assertContains('csrf_', $actual);

        $this->loader->setKey('trolololol');
        $actual = $this->loader->getKey();
        $this->assertSame('trolololol', $actual);
    }

    public function testTtl()
    {
        $actual = $this->loader->getTtl();
        $this->assertSame(900, $actual);

        $this->loader->setTtl(90);
        $actual = $this->loader->getTtl();
        $this->assertSame(90, $actual);
    }

    /**
     * @expectedException \InvalidArgumentException
     */
    public function testTtlNotInt()
    {
        $this->loader->setTtl(true);
    }

    public function testMissingSessionToken()
{'fraction_non_alphanumeric': 0.14671557185728576, 'fraction_numerical': 0.0106702234078026, 'mean_word_length': 2.260869565217391, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 49, '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': '725967', 'n_tokens_mistral': 940, 'n_tokens_neox': 909, 'n_words': 161}