forked from symfony/ux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LiveComponent] Check secret is not empty + add missing [SensitivePar…
…ameter] Improve security before we allow secret customization for LiveComponents (cf symfony#2453) I consider this a fix as passing an empty string for secret produce the same hash as passing null... which is deprecated for obvious reasons.
- Loading branch information
Showing
4 changed files
with
70 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/LiveComponent/tests/Unit/LiveComponentHydratorTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\UX\LiveComponent\Tests\Unit; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\PropertyAccess\PropertyAccessorInterface; | ||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface; | ||
use Symfony\UX\LiveComponent\LiveComponentHydrator; | ||
use Symfony\UX\LiveComponent\Metadata\LiveComponentMetadataFactory; | ||
|
||
final class LiveComponentHydratorTest extends TestCase | ||
{ | ||
public function testConstructWithEmptySecret(): void | ||
{ | ||
$this->expectException(\InvalidArgumentException::class); | ||
$this->expectExceptionMessage('A non-empty secret is required.'); | ||
|
||
new LiveComponentHydrator( | ||
[], | ||
$this->createMock(PropertyAccessorInterface::class), | ||
$this->createMock(LiveComponentMetadataFactory::class), | ||
$this->createMock(NormalizerInterface::class), | ||
'', | ||
); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/LiveComponent/tests/Unit/Util/FingerprintCalculatorTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\UX\LiveComponent\Tests\Unit\Util; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Symfony\UX\LiveComponent\Util\FingerprintCalculator; | ||
|
||
final class FingerprintCalculatorTest extends TestCase | ||
{ | ||
public function testConstructWithEmptySecret(): void | ||
{ | ||
$this->expectException(\InvalidArgumentException::class); | ||
$this->expectExceptionMessage('A non-empty secret is required.'); | ||
|
||
new FingerprintCalculator(''); | ||
} | ||
} |