From b17a9cb4aeeb1dfb99f376d4f174384b093d074e Mon Sep 17 00:00:00 2001 From: David Remer Date: Fri, 27 Jan 2023 14:35:39 +0200 Subject: [PATCH] Add test to ensure HTTP_RANGE headers do not reload captcha [MAILPOET-5032] --- .../Subscription/Captcha/CaptchaRendererTest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/mailpoet/tests/integration/Subscription/Captcha/CaptchaRendererTest.php b/mailpoet/tests/integration/Subscription/Captcha/CaptchaRendererTest.php index 412917964f..55728919f2 100644 --- a/mailpoet/tests/integration/Subscription/Captcha/CaptchaRendererTest.php +++ b/mailpoet/tests/integration/Subscription/Captcha/CaptchaRendererTest.php @@ -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.