<commit_before><?php
namespace Sil\SilAuth\tests\fakes;

use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
use Psr\Log\LoggerInterface;
use Sil\Idp\IdBroker\Client\IdBrokerClient;
use Sil\SilAuth\auth\IdBroker;

abstract class FakeIdBroker extends IdBroker
{
    public function __construct(
        string $baseUri,
        string $accessToken,
        LoggerInterface $logger,
        string $idpDomainName = 'fake.example.com'
    ) {
        parent::__construct($baseUri, $accessToken, $logger, $idpDomainName);
        
        // Now replace the client with one that will return the desired response.
        $this->client = new IdBrokerClient($baseUri, $accessToken, [
            'http_client_options' => [
                'handler' => HandlerStack::create(new MockHandler([
                    
                    /* Set up several, since this may be called multiple times
                     * during a test: */
                    $this->getDesiredResponse(),
                    $this->getDesiredResponse(),
                    $this->getDesiredResponse(),
                    $this->getDesiredResponse(),
                    $this->getDesiredResponse(),
                    $this->getDesiredResponse(),
                    $this->getDesiredResponse(),
                    $this->getDesiredResponse(),
                    $this->getDesiredResponse(),
                    $this->getDesiredResponse(),
                ])),
            ],
        ]);
    }
    
    abstract protected function getDesiredResponse();
}
<commit_msg>Allow more dummy calls to ID Broker.<commit_after><?php
namespace Sil\SilAuth\tests\fakes;

use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
use Psr\Log\LoggerInterface;
use Sil\SilAuth\auth\Authenticator;
use Sil\Idp\IdBroker\Client\IdBrokerClient;
use Sil\SilAuth\auth\IdBroker;

abstract class FakeIdBroker extends IdBroker
{
    public function __construct(
        string $baseUri,
        string $accessToken,
        LoggerInterface $logger,
        string $idpDomainName = 'fake.example.com'
    ) {
        parent::__construct($baseUri, $accessToken, $logger, $idpDomainName);
        
        // Now replace the client with one that will return the desired response.
        $this->client = new IdBrokerClient($baseUri, $accessToken, [
            'http_client_options' => [
                'handler' => HandlerStack::create(new MockHandler(
                    
                    /* Set up several, since this may be called multiple times
                     * during a test: */
                    array_fill(
                        0,
                        Authenticator::BLOCK_AFTER_NTH_FAILED_LOGIN * 2,
                        $this->getDesiredResponse()
                    )
                )),
            ],
        ]);
    }
    
    abstract protected function getDesiredResponse();
}

{'fraction_non_alphanumeric': 0.09670710571923744, 'fraction_numerical': 0.0006932409012131716, 'mean_word_length': 1.871641791044776, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, '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': '3082243', 'n_tokens_mistral': 768, 'n_tokens_neox': 738, 'n_words': 165}