Skip to content

Commit 5f26022

Browse files
committed
Merge branch '7.0' into 7.1
* 7.0: 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 5a00a8b + fc5137a commit 5f26022

File tree

18 files changed

+201
-45
lines changed

18 files changed

+201
-45
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function testSupports()
3939
*/
4040
public function testIsFresh(callable $mockContainer, $expected)
4141
{
42-
$mockContainer($this->container);
42+
$mockContainer($this->container, $this);
4343

4444
$this->assertSame($expected, $this->resourceChecker->isFresh($this->resource, time()));
4545
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ public function __construct(
181181
curl_multi_remove_handle($multi->handle, $ch);
182182
curl_setopt_array($ch, [
183183
\CURLOPT_NOPROGRESS => true,
184+
\CURLOPT_PROGRESSFUNCTION => null,
185+
\CURLOPT_HEADERFUNCTION => null,
186+
\CURLOPT_WRITEFUNCTION => null,
187+
\CURLOPT_READFUNCTION => null,
184188
\CURLOPT_INFILE => null,
185189
]);
186190

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
@@ -99,16 +99,44 @@ public function testBcryptWithLongPassword()
9999
$this->assertTrue($hasher->verify($hasher->hash($plainPassword), $plainPassword));
100100
}
101101

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

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

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

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)