Skip to content

Commit 0c66f91

Browse files
committed
Fix missing sprintf and add tests
1 parent 64a5a10 commit 0c66f91

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

src/Symfony/Component/Mime/Crypto/DkimSigner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function sign(Message $message, array $options = []): Message
6262
{
6363
$options += $this->defaultOptions;
6464
if (!\in_array($options['algorithm'], [self::ALGO_SHA256, self::ALGO_ED25519], true)) {
65-
throw new InvalidArgumentException('Invalid DKIM signing algorithm "%s".', $options['algorithm']);
65+
throw new InvalidArgumentException(sprintf('Invalid DKIM signing algorithm "%s".', $options['algorithm']));
6666
}
6767
$headersToIgnore['return-path'] = true;
6868
$headersToIgnore['x-transport'] = true;

src/Symfony/Component/Mime/Tests/Crypto/DkimSignerTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Mime\Address;
1717
use Symfony\Component\Mime\Crypto\DkimSigner;
1818
use Symfony\Component\Mime\Email;
19+
use Symfony\Component\Mime\Message;
1920

2021
/**
2122
* @group time-sensitive
@@ -90,6 +91,21 @@ public function getSignData()
9091
];
9192
}
9293

94+
public function testSignWithUnsupportedAlgorithm()
95+
{
96+
$message = $this->createMock(Message::class);
97+
98+
$signer = new DkimSigner(self::$pk, 'testdkim.symfony.net', 'sf', [
99+
'algorithm' => 'unsupported-value',
100+
]);
101+
102+
$this->expectExceptionObject(
103+
new \LogicException('Invalid DKIM signing algorithm "unsupported-value".')
104+
);
105+
106+
$signer->sign($message, []);
107+
}
108+
93109
/**
94110
* @dataProvider getCanonicalizeHeaderData
95111
*/

src/Symfony/Component/Security/Http/Firewall/AccessListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class AccessListener extends AbstractListener
3737
public function __construct(TokenStorageInterface $tokenStorage, AccessDecisionManagerInterface $accessDecisionManager, AccessMapInterface $map, bool $exceptionOnNoToken = false)
3838
{
3939
if (false !== $exceptionOnNoToken) {
40-
throw new \LogicException('Argument $exceptionOnNoToken of "%s()" must be set to "false".', __METHOD__);
40+
throw new \LogicException(sprintf('Argument $exceptionOnNoToken of "%s()" must be set to "false".', __METHOD__));
4141
}
4242

4343
$this->tokenStorage = $tokenStorage;

src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,4 +266,18 @@ public function testLazyPublicPagesShouldNotAccessTokenStorage()
266266
$listener = new AccessListener($tokenStorage, $this->createMock(AccessDecisionManagerInterface::class), $accessMap, false);
267267
$listener(new LazyResponseEvent(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST)));
268268
}
269+
270+
public function testConstructWithTrueExceptionOnNoToken()
271+
{
272+
$tokenStorage = $this->createMock(TokenStorageInterface::class);
273+
$tokenStorage->expects($this->never())->method(self::anything());
274+
275+
$accessMap = $this->createMock(AccessMapInterface::class);
276+
277+
$this->expectExceptionObject(
278+
new \LogicException('Argument $exceptionOnNoToken of "Symfony\Component\Security\Http\Firewall\AccessListener::__construct()" must be set to "false".')
279+
);
280+
281+
new AccessListener($tokenStorage, $this->createMock(AccessDecisionManagerInterface::class), $accessMap, true);
282+
}
269283
}

0 commit comments

Comments
 (0)