Skip to content

Commit fc5137a

Browse files
committed
Merge branch '6.4' into 7.0
* 6.4: replace wurstmeister Docker images for Kafka and Zookeeper [PasswordHasher] Make bcrypt nul byte hash test tolerant to PHP related failures [HttpClient] Revert fixing curl default options [VarExporter] fix proxy helper when a method returns null [Validator] Update Dutch (nl) translation Fix exception thrown during `LDAP_MODIFY_BATCH_REMOVE_ALL` batch operations Fix various warnings across components test suite
2 parents 4a9d377 + 72cbd0b commit fc5137a

File tree

18 files changed

+204
-48
lines changed

18 files changed

+204
-48
lines changed

.github/workflows/integration-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ jobs:
9999
ports:
100100
- 4566:4566
101101
zookeeper:
102-
image: wurstmeister/zookeeper:3.4.6
102+
image: zookeeper
103103
kafka:
104-
image: wurstmeister/kafka:2.12-2.0.1
104+
image: bitnami/kafka:3.7
105105
ports:
106106
- 9092:9092
107107
env:

src/Symfony/Component/DependencyInjection/Tests/Config/ContainerParametersResourceCheckerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function testSupports()
4040
*/
4141
public function testIsFresh(callable $mockContainer, $expected)
4242
{
43-
$mockContainer($this->container);
43+
$mockContainer($this->container, $this);
4444

4545
$this->assertSame($expected, $this->resourceChecker->isFresh($this->resource, time()));
4646
}
@@ -55,9 +55,9 @@ public static function isFreshProvider()
5555
$container->method('getParameter')->with('locales')->willReturn(['nl', 'es']);
5656
}, false];
5757

58-
yield 'fresh on every identical parameters' => [function (MockObject $container) {
59-
$container->expects(self::exactly(2))->method('hasParameter')->willReturn(true);
60-
$container->expects(self::exactly(2))->method('getParameter')
58+
yield 'fresh on every identical parameters' => [function (MockObject $container, TestCase $testCase) {
59+
$container->expects($testCase->exactly(2))->method('hasParameter')->willReturn(true);
60+
$container->expects($testCase->exactly(2))->method('getParameter')
6161
->willReturnCallback(function (...$args) {
6262
static $series = [
6363
[['locales'], ['fr', 'en']],

src/Symfony/Component/HttpClient/Response/CurlResponse.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ public function __construct(CurlClientState $multi, \CurlHandle|string $ch, ?arr
177177
curl_multi_remove_handle($multi->handle, $ch);
178178
curl_setopt_array($ch, [
179179
\CURLOPT_NOPROGRESS => true,
180+
\CURLOPT_PROGRESSFUNCTION => null,
181+
\CURLOPT_HEADERFUNCTION => null,
182+
\CURLOPT_WRITEFUNCTION => null,
183+
\CURLOPT_READFUNCTION => null,
180184
\CURLOPT_INFILE => null,
181185
]);
182186

src/Symfony/Component/Ldap/Adapter/ExtLdap/UpdateOperation.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,15 @@ public function __construct(int $operationType, string $attribute, ?array $value
4848

4949
public function toArray(): array
5050
{
51-
return [
51+
$op = [
5252
'attrib' => $this->attribute,
5353
'modtype' => $this->operationType,
54-
'values' => $this->values,
5554
];
55+
56+
if (\LDAP_MODIFY_BATCH_REMOVE_ALL !== $this->operationType) {
57+
$op['values'] = $this->values;
58+
}
59+
60+
return $op;
5661
}
5762
}

src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,23 @@ public function testLdapAddAttributeValuesError()
265265
$entryManager->addAttributeValues($entry, 'mail', $entry->getAttribute('mail'));
266266
}
267267

268+
public function testLdapApplyOperationsRemoveAll()
269+
{
270+
$entryManager = $this->adapter->getEntryManager();
271+
272+
$result = $this->executeSearchQuery(1);
273+
$entry = $result[0];
274+
275+
$entryManager->applyOperations($entry->getDn(), [new UpdateOperation(\LDAP_MODIFY_BATCH_REMOVE_ALL, 'mail', null)]);
276+
277+
$result = $this->executeSearchQuery(1);
278+
$entry = $result[0];
279+
280+
$this->assertNull($entry->getAttribute('mail'));
281+
282+
$entryManager->addAttributeValues($entry, 'mail', ['[email protected]', '[email protected]']);
283+
}
284+
268285
public function testLdapApplyOperationsRemoveAllWithArrayError()
269286
{
270287
$entryManager = $this->adapter->getEntryManager();

src/Symfony/Component/PasswordHasher/Tests/Hasher/NativePasswordHasherTest.php

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,44 @@ public function testBcryptWithLongPassword()
9898
$this->assertTrue($hasher->verify($hasher->hash($plainPassword), $plainPassword));
9999
}
100100

101-
public function testBcryptWithNulByte()
101+
/**
102+
* @requires PHP < 8.4
103+
*/
104+
public function testBcryptWithNulByteWithNativePasswordHash()
102105
{
103106
$hasher = new NativePasswordHasher(null, null, 4, \PASSWORD_BCRYPT);
104107
$plainPassword = "a\0b";
105108

106-
if (\PHP_VERSION_ID < 80218 || \PHP_VERSION_ID >= 80300 && \PHP_VERSION_ID < 80305) {
107-
// password_hash() does not accept passwords containing NUL bytes since PHP 8.2.18 and 8.3.5
108-
$this->assertFalse($hasher->verify(password_hash($plainPassword, \PASSWORD_BCRYPT, ['cost' => 4]), $plainPassword));
109+
try {
110+
$hash = password_hash($plainPassword, \PASSWORD_BCRYPT, ['cost' => 4]);
111+
} catch (\Throwable $throwable) {
112+
// we skip the test in case the current PHP version does not support NUL bytes in passwords
113+
// with bcrypt
114+
//
115+
// @see https://github.com/php/php-src/commit/11f2568767660ffe92fbc6799800e01203aad73a
116+
if (str_contains($throwable->getMessage(), 'Bcrypt password must not contain null character')) {
117+
$this->markTestSkipped('password_hash() does not accept passwords containing NUL bytes.');
118+
}
119+
120+
throw $throwable;
109121
}
110122

123+
if (null === $hash) {
124+
// we also skip the test in case password_hash() returns null as
125+
// implemented in security patches backports
126+
//
127+
// @see https://github.com/shivammathur/php-src-backports/commit/d22d9ebb29dce86edd622205dd1196a2796c08c7
128+
$this->markTestSkipped('password_hash() does not accept passwords containing NUL bytes.');
129+
}
130+
131+
$this->assertTrue($hasher->verify($hash, $plainPassword));
132+
}
133+
134+
public function testPasswordNulByteGracefullyHandled()
135+
{
136+
$hasher = new NativePasswordHasher(null, null, 4, \PASSWORD_BCRYPT);
137+
$plainPassword = "a\0b";
138+
111139
$this->assertTrue($hasher->verify($hasher->hash($plainPassword), $plainPassword));
112140
}
113141

src/Symfony/Component/PasswordHasher/Tests/Hasher/SodiumPasswordHasherTest.php

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,45 @@ public function testBcryptWithLongPassword()
7373
$this->assertTrue($hasher->verify((new NativePasswordHasher(null, null, 4, \PASSWORD_BCRYPT))->hash($plainPassword), $plainPassword));
7474
}
7575

76-
public function testBcryptWithNulByte()
76+
/**
77+
* @requires PHP < 8.4
78+
*/
79+
public function testBcryptWithNulByteWithNativePasswordHash()
7780
{
7881
$hasher = new SodiumPasswordHasher(null, null);
7982
$plainPassword = "a\0b";
8083

81-
if (\PHP_VERSION_ID < 80218 || \PHP_VERSION_ID >= 80300 && \PHP_VERSION_ID < 80305) {
82-
// password_hash() does not accept passwords containing NUL bytes since PHP 8.2.18 and 8.3.5
83-
$this->assertFalse($hasher->verify(password_hash($plainPassword, \PASSWORD_BCRYPT, ['cost' => 4]), $plainPassword));
84+
try {
85+
$hash = password_hash($plainPassword, \PASSWORD_BCRYPT, ['cost' => 4]);
86+
} catch (\Throwable $throwable) {
87+
// we skip the test in case the current PHP version does not support NUL bytes in passwords
88+
// with bcrypt
89+
//
90+
// @see https://github.com/php/php-src/commit/11f2568767660ffe92fbc6799800e01203aad73a
91+
if (str_contains($throwable->getMessage(), 'Bcrypt password must not contain null character')) {
92+
$this->markTestSkipped('password_hash() does not accept passwords containing NUL bytes.');
93+
}
94+
95+
throw $throwable;
8496
}
8597

86-
$this->assertTrue($hasher->verify((new NativePasswordHasher(null, null, 4, \PASSWORD_BCRYPT))->hash($plainPassword), $plainPassword));
98+
if (null === $hash) {
99+
// we also skip the test in case password_hash() returns null as
100+
// implemented in security patches backports
101+
//
102+
// @see https://github.com/shivammathur/php-src-backports/commit/d22d9ebb29dce86edd622205dd1196a2796c08c7
103+
$this->markTestSkipped('password_hash() does not accept passwords containing NUL bytes.');
104+
}
105+
106+
$this->assertTrue($hasher->verify($hash, $plainPassword));
107+
}
108+
109+
public function testPasswordNulByteGracefullyHandled()
110+
{
111+
$hasher = new SodiumPasswordHasher(null, null);
112+
$plainPassword = "a\0b";
113+
114+
$this->assertTrue($hasher->verify($hasher->hash($plainPassword), $plainPassword));
87115
}
88116

89117
public function testUserProvidedSaltIsNotUsed()

src/Symfony/Component/Routing/Tests/Generator/Dumper/CompiledUrlGeneratorDumperTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ protected function tearDown(): void
4848
parent::tearDown();
4949

5050
@unlink($this->testTmpFilepath);
51+
@unlink($this->largeTestTmpFilepath);
5152
}
5253

5354
public function testDumpWithRoutes()

src/Symfony/Component/Serializer/Tests/Normalizer/Features/CallbacksTestTrait.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,13 @@ public function testUncallableCallbacks($callbacks)
126126
$normalizer->normalize($obj, null, ['callbacks' => $callbacks]);
127127
}
128128

129-
public function provideNormalizeCallbacks()
129+
public static function provideNormalizeCallbacks()
130130
{
131131
return [
132132
'Change a string' => [
133133
[
134134
'bar' => function ($bar) {
135-
$this->assertEquals('baz', $bar);
135+
static::assertEquals('baz', $bar);
136136

137137
return 'baz';
138138
},
@@ -143,11 +143,11 @@ public function provideNormalizeCallbacks()
143143
'Null an item' => [
144144
[
145145
'bar' => function ($value, $object, $attributeName, $format, $context) {
146-
$this->assertSame('baz', $value);
147-
$this->assertInstanceOf(CallbacksObject::class, $object);
148-
$this->assertSame('bar', $attributeName);
149-
$this->assertSame('any', $format);
150-
$this->assertArrayHasKey('circular_reference_limit_counters', $context);
146+
static::assertSame('baz', $value);
147+
static::assertInstanceOf(CallbacksObject::class, $object);
148+
static::assertSame('bar', $attributeName);
149+
static::assertSame('any', $format);
150+
static::assertArrayHasKey('circular_reference_limit_counters', $context);
151151
},
152152
],
153153
'baz',
@@ -156,7 +156,7 @@ public function provideNormalizeCallbacks()
156156
'Format a date' => [
157157
[
158158
'bar' => function ($bar) {
159-
$this->assertInstanceOf(\DateTimeImmutable::class, $bar);
159+
static::assertInstanceOf(\DateTimeImmutable::class, $bar);
160160

161161
return $bar->format('d-m-Y H:i:s');
162162
},
@@ -188,13 +188,13 @@ public function provideNormalizeCallbacks()
188188
];
189189
}
190190

191-
public function provideDenormalizeCallbacks(): array
191+
public static function provideDenormalizeCallbacks(): array
192192
{
193193
return [
194194
'Change a string' => [
195195
[
196196
'bar' => function ($bar) {
197-
$this->assertEquals('bar', $bar);
197+
static::assertEquals('bar', $bar);
198198

199199
return $bar;
200200
},
@@ -205,11 +205,11 @@ public function provideDenormalizeCallbacks(): array
205205
'Null an item' => [
206206
[
207207
'bar' => function ($value, $object, $attributeName, $format, $context) {
208-
$this->assertSame('baz', $value);
209-
$this->assertTrue(is_a($object, CallbacksObject::class, true));
210-
$this->assertSame('bar', $attributeName);
211-
$this->assertSame('any', $format);
212-
$this->assertIsArray($context);
208+
static::assertSame('baz', $value);
209+
static::assertTrue(is_a($object, CallbacksObject::class, true));
210+
static::assertSame('bar', $attributeName);
211+
static::assertSame('any', $format);
212+
static::assertIsArray($context);
213213
},
214214
],
215215
'baz',
@@ -218,7 +218,7 @@ public function provideDenormalizeCallbacks(): array
218218
'Format a date' => [
219219
[
220220
'bar' => function ($bar) {
221-
$this->assertIsString($bar);
221+
static::assertIsString($bar);
222222

223223
return \DateTimeImmutable::createFromFormat('d-m-Y H:i:s', $bar);
224224
},
@@ -250,13 +250,13 @@ public function provideDenormalizeCallbacks(): array
250250
];
251251
}
252252

253-
public function providerDenormalizeCallbacksWithTypedProperty(): array
253+
public static function providerDenormalizeCallbacksWithTypedProperty(): array
254254
{
255255
return [
256256
'Change a typed string' => [
257257
[
258258
'foo' => function ($foo) {
259-
$this->assertEquals('foo', $foo);
259+
static::assertEquals('foo', $foo);
260260

261261
return $foo;
262262
},
@@ -267,11 +267,11 @@ public function providerDenormalizeCallbacksWithTypedProperty(): array
267267
'Null an typed item' => [
268268
[
269269
'foo' => function ($value, $object, $attributeName, $format, $context) {
270-
$this->assertSame('fool', $value);
271-
$this->assertTrue(is_a($object, CallbacksObject::class, true));
272-
$this->assertSame('foo', $attributeName);
273-
$this->assertSame('any', $format);
274-
$this->assertIsArray($context);
270+
static::assertSame('fool', $value);
271+
static::assertTrue(is_a($object, CallbacksObject::class, true));
272+
static::assertSame('foo', $attributeName);
273+
static::assertSame('any', $format);
274+
static::assertIsArray($context);
275275
},
276276
],
277277
'fool',
@@ -280,7 +280,7 @@ public function providerDenormalizeCallbacksWithTypedProperty(): array
280280
];
281281
}
282282

283-
public function provideInvalidCallbacks()
283+
public static function provideInvalidCallbacks()
284284
{
285285
return [
286286
[['bar' => null]],

src/Symfony/Component/Serializer/Tests/Normalizer/Features/CircularReferenceTestTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ abstract protected function getNormalizerForCircularReference(array $defaultCont
2323

2424
abstract protected function getSelfReferencingModel();
2525

26-
public function provideUnableToNormalizeCircularReference(): array
26+
public static function provideUnableToNormalizeCircularReference(): array
2727
{
2828
return [
2929
[[], [], 1],

0 commit comments

Comments
 (0)