Use the reCAPTCHA Enterprise API.
This commit is contained in:
@@ -50,7 +50,8 @@ class LoginTest extends PageTestCase {
|
||||
public function testTheFormHasATokenAndTheCaptcha(): void {
|
||||
$body = $this->get('/publish/login')['body'];
|
||||
$this->assertSame($this->session()['csrf_token'], $this->csrfToken($body));
|
||||
$this->assertStringContainsString('data-sitekey="test-site-key"', $body);
|
||||
$this->assertStringContainsString('data-sitekey="test-site-key" data-action="login"', $body);
|
||||
$this->assertStringContainsString('https://www.google.com/recaptcha/enterprise.js', $body);
|
||||
}
|
||||
|
||||
public function testTheRightPasswordLogsIn(): void {
|
||||
@@ -130,6 +131,18 @@ class LoginTest extends PageTestCase {
|
||||
$this->assertSame(array(), $this->queries('/FROM editors/'));
|
||||
}
|
||||
|
||||
public static function failedAssessments(): array {
|
||||
return array(array('wrong-host'), array('wrong-action'), array('api-error'), array('unreachable'));
|
||||
}
|
||||
|
||||
#[DataProvider('failedAssessments')]
|
||||
public function testAFailedAssessmentBlocksTheLogin(string $response): void {
|
||||
$answer = $this->login('secret', array('g-recaptcha-response' => $response));
|
||||
$this->assertStringContainsString('Please complete the captcha.', $answer['body']);
|
||||
$this->assertSame(array(), $this->queries('/FROM editors/'));
|
||||
$this->assertArrayNotHasKey('editor', $this->session());
|
||||
}
|
||||
|
||||
public function testFiveFailuresBlockTheLogin(): void {
|
||||
for ($i = 0; $i < 5; $i++)
|
||||
$this->login('wrong');
|
||||
|
||||
Reference in New Issue
Block a user