From ae252916108f3006ebdc26545f130442054f0eec Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 4 Feb 2018 18:41:24 +0100 Subject: [PATCH 1/3] [HttpKernel] fix FC --- src/Symfony/Component/HttpKernel/Tests/ClientTest.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Tests/ClientTest.php b/src/Symfony/Component/HttpKernel/Tests/ClientTest.php index 1ac72c73595c2..051d5d47c0265 100644 --- a/src/Symfony/Component/HttpKernel/Tests/ClientTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/ClientTest.php @@ -97,6 +97,7 @@ public function testFilterResponseSupportsStreamedResponses() public function testUploadedFile() { $source = tempnam(sys_get_temp_dir(), 'source'); + file_put_contents($source, '1'); $target = sys_get_temp_dir().'/sf.moved.file'; @unlink($target); @@ -104,8 +105,8 @@ public function testUploadedFile() $client = new Client($kernel); $files = array( - array('tmp_name' => $source, 'name' => 'original', 'type' => 'mime/original', 'size' => 123, 'error' => UPLOAD_ERR_OK), - new UploadedFile($source, 'original', 'mime/original', 123, UPLOAD_ERR_OK, true), + array('tmp_name' => $source, 'name' => 'original', 'type' => 'mime/original', 'size' => 1, 'error' => UPLOAD_ERR_OK), + new UploadedFile($source, 'original', 'mime/original', 1, UPLOAD_ERR_OK, true), ); $file = null; @@ -120,7 +121,7 @@ public function testUploadedFile() $this->assertEquals('original', $file->getClientOriginalName()); $this->assertEquals('mime/original', $file->getClientMimeType()); - $this->assertEquals('123', $file->getClientSize()); + $this->assertSame(1, $file->getClientSize()); $this->assertTrue($file->isValid()); } From 5f9471ef47c0f9e4a2d67dce797c653a87534add Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 5 Feb 2018 16:46:42 +0100 Subject: [PATCH 2/3] use libsodium to run Argon2i related tests --- .travis.yml | 8 ++++++++ .../DependencyInjection/Fixtures/yml/argon2i_encoder.yml | 2 +- .../Tests/Functional/UserPasswordEncoderCommandTest.php | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 245b37487624a..8cbcc71c82525 100644 --- a/.travis.yml +++ b/.travis.yml @@ -149,7 +149,15 @@ before_install: ([[ $deps ]] || tfold ext.symfony_debug 'cd src/Symfony/Component/Debug/Resources/ext && phpize && ./configure && make && echo extension = $(pwd)/modules/symfony_debug.so >> '"$INI") tfold ext.apcu tpecl apcu-4.0.11 apcu.so elif [[ ! $skip && $PHP = 7.* ]]; then + # install libsodium + if [[ ! -e ~/php-ext/$(php -r "echo basename(ini_get('extension_dir'));")/libsodium/sodium.so ]]; then + sudo add-apt-repository ppa:ondrej/php -y + sudo apt-get update -q + sudo apt-get install libsodium-dev -y + fi + tfold ext.apcu tpecl apcu-5.1.6 apcu.so + tfold ext.libsodium tpecl libsodium sodium.so tfold ext.mongodb tpecl mongodb-1.4.0RC1 mongodb.so fi diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/argon2i_encoder.yml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/argon2i_encoder.yml index a51e766005456..6a1f925160fbf 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/argon2i_encoder.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/argon2i_encoder.yml @@ -1,6 +1,6 @@ security: encoders: - JMS\FooBundle\Entity\User6: + JMS\FooBundle\Entity\User7: algorithm: argon2i providers: diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php index fa0be42c5d940..01b2ce303acfa 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php @@ -86,7 +86,7 @@ public function testEncodePasswordArgon2i() $this->assertContains('Password encoding succeeded', $output); $encoder = new Argon2iPasswordEncoder(); - preg_match('# Encoded password\s+(\$argon2i\$[\w\d,=\$+\/]+={0,2})\s+#', $output, $matches); + preg_match('# Encoded password\s+(\$argon2id\$[\w\d,=\$+\/]+={0,2})\s+#', $output, $matches); $hash = $matches[1]; $this->assertTrue($encoder->isPasswordValid($hash, 'password', null)); } @@ -272,7 +272,7 @@ protected function tearDown() private function setupArgon2i() { putenv('COLUMNS='.(119 + strlen(PHP_EOL))); - $kernel = $this->createKernel(array('test_case' => 'PasswordEncode', 'root_config' => 'argon2i')); + $kernel = $this->createKernel(array('test_case' => 'PasswordEncode', 'root_config' => 'argon2i.yml')); $kernel->boot(); $application = new Application($kernel); From ba22f0c0f3af13adf216262791383ec053cbd3d6 Mon Sep 17 00:00:00 2001 From: Thomas Counsell Date: Tue, 6 Feb 2018 16:18:24 +0000 Subject: [PATCH 3/3] Test for Issue #26065: leading spaces in YAML multi-line string literals When dumping an object to YAML. If the first line of a mult-line string literal starts with spaces then the YAML spec says you need to use a [block indentation indicator][1]. [1]: http://www.yaml.org/spec/1.2/spec.html#id2793979 --- .../Component/Yaml/Tests/DumperTest.php | 77 +++---------------- ...eral_block_leading_space_in_first_line.yml | 4 + 2 files changed, 15 insertions(+), 66 deletions(-) create mode 100644 src/Symfony/Component/Yaml/Tests/Fixtures/multiple_lines_as_literal_block_leading_space_in_first_line.yml diff --git a/src/Symfony/Component/Yaml/Tests/DumperTest.php b/src/Symfony/Component/Yaml/Tests/DumperTest.php index a29dff20f76db..0a8c023d017fe 100644 --- a/src/Symfony/Component/Yaml/Tests/DumperTest.php +++ b/src/Symfony/Component/Yaml/Tests/DumperTest.php @@ -77,35 +77,6 @@ public function testIndentationInConstructor() $this->assertEquals($expected, $dumper->dump($this->array, 4, 0)); } - /** - * @group legacy - */ - public function testSetIndentation() - { - $this->dumper->setIndentation(7); - - $expected = <<<'EOF' -'': bar -foo: '#bar' -'foo''bar': { } -bar: - - 1 - - foo -foobar: - foo: bar - bar: - - 1 - - foo - foobar: - foo: bar - bar: - - 1 - - foo - -EOF; - $this->assertEquals($expected, $this->dumper->dump($this->array, 4, 0)); - } - public function testSpecifications() { $files = $this->parser->parse(file_get_contents($this->path.'/index.yml')); @@ -213,16 +184,6 @@ public function testObjectSupportEnabled() $this->assertEquals('{ foo: !php/object \'O:30:"Symfony\Component\Yaml\Tests\A":1:{s:1:"a";s:3:"foo";}\', bar: 1 }', $dump, '->dump() is able to dump objects'); } - /** - * @group legacy - */ - public function testObjectSupportEnabledPassingTrue() - { - $dump = $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, false, true); - - $this->assertEquals('{ foo: !php/object \'O:30:"Symfony\Component\Yaml\Tests\A":1:{s:1:"a";s:3:"foo";}\', bar: 1 }', $dump, '->dump() is able to dump objects'); - } - public function testObjectSupportDisabledButNoExceptions() { $dump = $this->dumper->dump(array('foo' => new A(), 'bar' => 1)); @@ -238,33 +199,6 @@ public function testObjectSupportDisabledWithExceptions() $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE); } - /** - * @group legacy - * @expectedException \Symfony\Component\Yaml\Exception\DumpException - */ - public function testObjectSupportDisabledWithExceptionsPassingTrue() - { - $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, true); - } - - public function testEmptyArray() - { - $dump = $this->dumper->dump(array()); - $this->assertEquals('{ }', $dump); - - $dump = $this->dumper->dump(array(), 0, 0, Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE); - $this->assertEquals('[]', $dump); - - $dump = $this->dumper->dump(array(), 9, 0, Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE); - $this->assertEquals('[]', $dump); - - $dump = $this->dumper->dump(new \ArrayObject(), 0, 0, Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE | Yaml::DUMP_OBJECT_AS_MAP); - $this->assertEquals('{ }', $dump); - - $dump = $this->dumper->dump(new \stdClass(), 0, 0, Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE | Yaml::DUMP_OBJECT_AS_MAP); - $this->assertEquals('{ }', $dump); - } - /** * @dataProvider getEscapeSequences */ @@ -454,6 +388,17 @@ public function testDumpMultiLineStringAsScalarBlock() $this->assertSame(file_get_contents(__DIR__.'/Fixtures/multiple_lines_as_literal_block.yml'), $this->dumper->dump($data, 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK)); } + public function testDumpMultiLineStringAsScalarBlockWhenFirstLineHasLeadingSpace() + { + $data = array( + 'data' => array( + 'multi_line' => " the first line has leading spaces\nThe second line does not.", + ), + ); + + $this->assertSame(file_get_contents(__DIR__.'/Fixtures/multiple_lines_as_literal_block_leading_space_in_first_line.yml'), $this->dumper->dump($data, 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK)); + } + public function testCarriageReturnIsMaintainedWhenDumpingAsMultiLineLiteralBlock() { $this->assertSame("- \"a\\r\\nb\\nc\"\n", $this->dumper->dump(array("a\r\nb\nc"), 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK)); diff --git a/src/Symfony/Component/Yaml/Tests/Fixtures/multiple_lines_as_literal_block_leading_space_in_first_line.yml b/src/Symfony/Component/Yaml/Tests/Fixtures/multiple_lines_as_literal_block_leading_space_in_first_line.yml new file mode 100644 index 0000000000000..3f2dedd10e682 --- /dev/null +++ b/src/Symfony/Component/Yaml/Tests/Fixtures/multiple_lines_as_literal_block_leading_space_in_first_line.yml @@ -0,0 +1,4 @@ +data: + multi_line: |4 + the first line has leading spaces + The second line does not.