Skip to content

Commit e90a4aa

Browse files
author
Oleksandr Gorkun
committed
MC-30971: CSP policies must be defined in a single header
1 parent e417dfb commit e90a4aa

File tree

2 files changed

+3
-16
lines changed

2 files changed

+3
-16
lines changed

dev/tests/integration/testsuite/Magento/Csp/Model/Policy/Renderer/SimplePolicyHeaderRendererTest.php

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,7 @@ public function testRenderRestrictMode(): void
5353

5454
$this->assertNotEmpty($header = $this->response->getHeader('Content-Security-Policy'));
5555
$this->assertEmpty($this->response->getHeader('Content-Security-Policy-Report-Only'));
56-
$contentSecurityPolicyContent = [];
57-
if ($header instanceof \ArrayIterator) {
58-
foreach ($header as $item) {
59-
$contentSecurityPolicyContent[] = $item->getFieldValue();
60-
}
61-
}
62-
$this->assertEquals(['default-src https://magento.com \'self\';'], $contentSecurityPolicyContent);
56+
$this->assertEquals('default-src https://magento.com \'self\';', $header->getFieldValue());
6357
}
6458

6559
/**
@@ -79,15 +73,9 @@ public function testRenderRestrictWithReportingMode(): void
7973

8074
$this->assertNotEmpty($header = $this->response->getHeader('Content-Security-Policy'));
8175
$this->assertEmpty($this->response->getHeader('Content-Security-Policy-Report-Only'));
82-
$contentSecurityPolicyContent = [];
83-
if ($header instanceof \ArrayIterator) {
84-
foreach ($header as $item) {
85-
$contentSecurityPolicyContent[] = $item->getFieldValue();
86-
}
87-
}
8876
$this->assertEquals(
89-
['default-src https://magento.com \'self\'; report-uri /csp-reports/; report-to report-endpoint;'],
90-
$contentSecurityPolicyContent
77+
'default-src https://magento.com \'self\'; report-uri /csp-reports/; report-to report-endpoint;',
78+
$header->getFieldValue()
9179
);
9280
$this->assertNotEmpty($reportToHeader = $this->response->getHeader('Report-To'));
9381
$this->assertNotEmpty($reportData = json_decode("[{$reportToHeader->getFieldValue()}]", true));

lib/internal/Magento/Framework/HTTP/PhpEnvironment/Response.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ public function sendHeaders()
211211
header($header->toString(), false);
212212
}
213213

214-
$this->headersSent = true;
215214
return $this;
216215
}
217216
}

0 commit comments

Comments
 (0)