diff options
author | Marc Alexander <admin@m-a-styles.de> | 2017-07-09 16:24:49 +0200 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2017-07-09 16:24:49 +0200 |
commit | 3fc3f55d349c9022de28fed85c3bfa2d317c5075 (patch) | |
tree | bc436c3ebda0e62ebbb8fbbe8d4ef360b2d3ef75 /tests/avatar | |
parent | aef138d8bc2cc2c74bc9951d136c7bc1e0cf3ad7 (diff) | |
parent | a281d526dc6cf48011c1d9e04399848f7c0c08c2 (diff) | |
download | forums-3fc3f55d349c9022de28fed85c3bfa2d317c5075.tar forums-3fc3f55d349c9022de28fed85c3bfa2d317c5075.tar.gz forums-3fc3f55d349c9022de28fed85c3bfa2d317c5075.tar.bz2 forums-3fc3f55d349c9022de28fed85c3bfa2d317c5075.tar.xz forums-3fc3f55d349c9022de28fed85c3bfa2d317c5075.zip |
Merge branch 'ticket/security/210' into ticket/security/210-rhea
Diffstat (limited to 'tests/avatar')
-rw-r--r-- | tests/avatar/manager_test.php | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index 924f1319a2..aff6160a95 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -384,4 +384,56 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case 'avatar_height' => 0, ), $row); } + + public function data_remote_avatar_url() + { + return array( + array('127.0.0.1:91?foo.jpg', 80, 80, array('AVATAR_URL_INVALID')), + array(gethostbyname('secure.gravatar.com') . '/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', 80, 80), + array('secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', 80, 80), + array(gethostbyname('secure.gravatar.com') . ':120/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', 80, 80, array('AVATAR_URL_INVALID')), + array('secure.gravatar.com:80/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', 80, 80, array('AVATAR_URL_INVALID')), + array('secure.gravatar.com:80?55502f40dc8b7c769880b10874abc9d0.jpg', 80, 80, array('AVATAR_URL_INVALID')), + array('secure.gravatar.com?55502f40dc8b7c769880b10874abc9d0.jpg', 80, 80, array('AVATAR_URL_INVALID')), // should be a 404 + ); + } + + /** + * @dataProvider data_remote_avatar_url + */ + public function test_remote_avatar_url($url, $width, $height, $expected_error = array()) + { + global $phpbb_root_path, $phpEx; + + if (!function_exists('get_preg_expression')) + { + require($phpbb_root_path . 'includes/functions.' . $phpEx); + } + + $this->config['server_name'] = 'foobar.com'; + + /** @var \phpbb\avatar\driver\remote $remote_avatar */ + $remote_avatar = $this->manager->get_driver('avatar.driver.remote', false); + + $request = new phpbb_mock_request(array(), array( + 'avatar_remote_url' => $url, + 'avatar_remote_width' => $width, + 'avatar_remote_height' => $height, + )); + + $user = new \phpbb\user('\phpbb\datetime'); + $row = array(); + $error = array(); + + $return = $remote_avatar->process_form($request, null, $user, $row, $error); + if (count($expected_error) > 0) + { + $this->assertFalse($return); + } + else + { + $this->assertNotEquals(false, $return); + } + $this->assertSame($expected_error, $error); + } } |