From 2f505bf9a889ddaf530fe975967589f6c6993e39 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 16 Mar 2015 22:49:47 +0100 Subject: use correct host in proxy tests --- _test/tests/inc/httpclient_https_proxy.test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to '_test') diff --git a/_test/tests/inc/httpclient_https_proxy.test.php b/_test/tests/inc/httpclient_https_proxy.test.php index 9402e91af..7a54bb92e 100644 --- a/_test/tests/inc/httpclient_https_proxy.test.php +++ b/_test/tests/inc/httpclient_https_proxy.test.php @@ -2,7 +2,7 @@ require_once dirname(__FILE__).'/httpclient_http_proxy.test.php'; class httpclient_https_proxy_test extends httpclient_http_proxy_test { - protected $url = 'https://www.dokuwiki.org/README'; + protected $url = 'https://test.dokuwiki.org/README'; public function setUp(){ // skip tests when this PHP has no SSL support @@ -27,4 +27,4 @@ class httpclient_https_proxy_test extends httpclient_http_proxy_test { $this->assertFalse($data); $this->assertEquals(-150, $http->status); } -} \ No newline at end of file +} -- cgit v1.2.3 From 09513545a4776e31b5fb113bd8741df1df878816 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 18 Mar 2015 11:19:04 +0100 Subject: give better error message in HTTPClient for failed crypto setup --- _test/tests/inc/httpclient_http_proxy.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '_test') diff --git a/_test/tests/inc/httpclient_http_proxy.test.php b/_test/tests/inc/httpclient_http_proxy.test.php index c44dc7ed7..79b8f8e5e 100644 --- a/_test/tests/inc/httpclient_http_proxy.test.php +++ b/_test/tests/inc/httpclient_http_proxy.test.php @@ -15,7 +15,7 @@ class httpclient_http_proxy_test extends DokuWikiTest { $http->proxy_port = 8080; $data = $http->get($this->url); - $this->assertFalse($data === false, 'HTTP response '.$http->error); + $this->assertFalse($data === false, 'HTTP response: '.$http->error.' ['.$this->url.']'); $this->assertTrue(strpos($data,'DokuWiki') !== false, 'response content'); } } \ No newline at end of file -- cgit v1.2.3 From d387bf5e958e9d25a7192d1f5e5280ac0eb82da7 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 18 Mar 2015 20:27:10 +0100 Subject: correct error checking for bz2 file reading The code reading .bz2 compressed files did not correctly check for possible read errors. In case of a corrupted file this could have led to an infinite loop. Thanks to Filippo Cavallarin from www.segment.technology for dicovering this bug. --- _test/tests/inc/io_readfile.test.php | 53 ++++++++++++++++++++++++++++ _test/tests/inc/io_readfile/corrupt.txt.bz2 | 1 + _test/tests/inc/io_readfile/corrupt.txt.gz | Bin 0 -> 31 bytes _test/tests/inc/io_readfile/test.txt.bz2 | Bin 0 -> 49 bytes _test/tests/inc/io_readfile/test.txt.gz | Bin 0 -> 31 bytes 5 files changed, 54 insertions(+) create mode 100644 _test/tests/inc/io_readfile.test.php create mode 100644 _test/tests/inc/io_readfile/corrupt.txt.bz2 create mode 100644 _test/tests/inc/io_readfile/corrupt.txt.gz create mode 100644 _test/tests/inc/io_readfile/test.txt.bz2 create mode 100644 _test/tests/inc/io_readfile/test.txt.gz (limited to '_test') diff --git a/_test/tests/inc/io_readfile.test.php b/_test/tests/inc/io_readfile.test.php new file mode 100644 index 000000000..e3e90cd8d --- /dev/null +++ b/_test/tests/inc/io_readfile.test.php @@ -0,0 +1,53 @@ +markTestSkipped('skipping all zlib tests. Need zlib extension'); + } + } + + /* + * dependency for tests needing zlib extension to pass + */ + public function test_ext_bz2() { + if (!extension_loaded('bz2')) { + $this->markTestSkipped('skipping all bzip2 tests. Need bz2 extension'); + } + } + + function test_plain(){ + // since git converts line endings, we can't check in this test file but have to create it ourselves + $plain = TMP_DIR.'/test.txt'; + file_put_contents($plain, "The\015\012Test\015\012"); + + $this->assertEquals("The\012Test\012", io_readFile($plain)); + $this->assertEquals("The\015\012Test\015\012", io_readFile($plain, false)); + $this->assertEquals(false, io_readFile(__DIR__.'/io_readfile/nope.txt')); + } + + /** + * @depends test_ext_zlib + */ + function test_gzfiles(){ + $this->assertEquals("The\012Test\012", io_readFile(__DIR__.'/io_readfile/test.txt.gz')); + $this->assertEquals("The\015\012Test\015\012", io_readFile(__DIR__.'/io_readfile/test.txt.gz', false)); + $this->assertEquals(false, io_readFile(__DIR__.'/io_readfile/nope.txt.gz')); + $this->assertEquals(false, io_readFile(__DIR__.'/io_readfile/corrupt.txt.gz')); + } + + /** + * @depends test_ext_bz2 + */ + function test_bzfiles(){ + $this->assertEquals("The\012Test\012", io_readFile(__DIR__.'/io_readfile/test.txt.bz2')); + $this->assertEquals("The\015\012Test\015\012", io_readFile(__DIR__.'/io_readfile/test.txt.bz2', false)); + $this->assertEquals(false, io_readFile(__DIR__.'/io_readfile/nope.txt.bz2')); + $this->assertEquals(false, io_readFile(__DIR__.'/io_readfile/corrupt.txt.bz2')); + } + +} \ No newline at end of file diff --git a/_test/tests/inc/io_readfile/corrupt.txt.bz2 b/_test/tests/inc/io_readfile/corrupt.txt.bz2 new file mode 100644 index 000000000..97f742919 --- /dev/null +++ b/_test/tests/inc/io_readfile/corrupt.txt.bz2 @@ -0,0 +1 @@ +BZh91AY&SYXHd¬ \ No newline at end of file diff --git a/_test/tests/inc/io_readfile/corrupt.txt.gz b/_test/tests/inc/io_readfile/corrupt.txt.gz new file mode 100644 index 000000000..f7f5d3397 Binary files /dev/null and b/_test/tests/inc/io_readfile/corrupt.txt.gz differ diff --git a/_test/tests/inc/io_readfile/test.txt.bz2 b/_test/tests/inc/io_readfile/test.txt.bz2 new file mode 100644 index 000000000..3d4e1b226 Binary files /dev/null and b/_test/tests/inc/io_readfile/test.txt.bz2 differ diff --git a/_test/tests/inc/io_readfile/test.txt.gz b/_test/tests/inc/io_readfile/test.txt.gz new file mode 100644 index 000000000..8ac8f7d40 Binary files /dev/null and b/_test/tests/inc/io_readfile/test.txt.gz differ -- cgit v1.2.3 From 6abea1c0be56a2cb5575c8921c3e6661ed565697 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 18 Mar 2015 21:55:59 +0100 Subject: fixed HTTPS proxy tests, our tests now run on httpbin.org This also reverses the order of crypto protocols tried again. Using TLS first again. related to #915 --- _test/tests/inc/httpclient_http_proxy.test.php | 2 +- _test/tests/inc/httpclient_https_proxy.test.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to '_test') diff --git a/_test/tests/inc/httpclient_http_proxy.test.php b/_test/tests/inc/httpclient_http_proxy.test.php index 79b8f8e5e..dae801dbd 100644 --- a/_test/tests/inc/httpclient_http_proxy.test.php +++ b/_test/tests/inc/httpclient_http_proxy.test.php @@ -3,7 +3,7 @@ require_once (__DIR__ . '/httpclient_mock.php'); class httpclient_http_proxy_test extends DokuWikiTest { - protected $url = 'http://test.dokuwiki.org/README'; + protected $url = 'http://httpbin.org/user-agent'; /** * @group internet diff --git a/_test/tests/inc/httpclient_https_proxy.test.php b/_test/tests/inc/httpclient_https_proxy.test.php index 7a54bb92e..cf5b9a8b9 100644 --- a/_test/tests/inc/httpclient_https_proxy.test.php +++ b/_test/tests/inc/httpclient_https_proxy.test.php @@ -2,7 +2,7 @@ require_once dirname(__FILE__).'/httpclient_http_proxy.test.php'; class httpclient_https_proxy_test extends httpclient_http_proxy_test { - protected $url = 'https://test.dokuwiki.org/README'; + protected $url = 'https://httpbin.org/user-agent'; public function setUp(){ // skip tests when this PHP has no SSL support -- cgit v1.2.3 From 8599a179b08d4cdcf1c8895bacde82aad9df101f Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 18 Mar 2015 22:43:45 +0100 Subject: corrupted the gz test file more it seems that different zlib versions behave different with corrupted files. Some return false, some return whatever they still can read from the file. the file now should no longer be readable by any version. --- _test/tests/inc/io_readfile/corrupt.txt.gz | Bin 31 -> 31 bytes 1 file changed, 0 insertions(+), 0 deletions(-) (limited to '_test') diff --git a/_test/tests/inc/io_readfile/corrupt.txt.gz b/_test/tests/inc/io_readfile/corrupt.txt.gz index f7f5d3397..9d7666f47 100644 Binary files a/_test/tests/inc/io_readfile/corrupt.txt.gz and b/_test/tests/inc/io_readfile/corrupt.txt.gz differ -- cgit v1.2.3