Add test to ensure HTTP_RANGE headers do not reload captcha

[MAILPOET-5032]
This commit is contained in:
David Remer
2023-01-27 14:35:39 +02:00
committed by Aschepikov
parent 351c8a0bd7
commit b17a9cb4ae

View File

@ -68,6 +68,22 @@ class CaptchaRendererTest extends \MailPoetTest {
expect($firstCaptcha['phrase'])->notEquals($secondCaptcha['phrase']);
}
/**
* We need to ensure that a new captcha phrase is created when reloading
*/
public function testItDoesNotChangeCaptchaWhenAudioRangeHeaderChanges() {
$this->session->init();
$sessionId = $this->session->getId();
$fistAudio = $this->testee->renderAudio($sessionId, true);
$firstCaptcha = $this->session->getCaptchaHash();
$_SERVER['HTTP_RANGE'] = 'bytes:0-1';
$secondAudio = $this->testee->renderAudio($sessionId, true);
$secondCaptcha = $this->session->getCaptchaHash();
unset($_SERVER['HTTP_RANGE']);
expect($fistAudio)->Equals($secondAudio);
expect($firstCaptcha['phrase'])->Equals($secondCaptcha['phrase']);
}
/**
* We need to make sure that the audio presented to a listener plays the same captcha
* the image shows.