mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 14:00:31 +02:00
[ticket/16764] Remove remote avatar functionality
PHPBB3-16764
This commit is contained in:
@@ -119,7 +119,6 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
|
||||
return array(
|
||||
'local',
|
||||
'upload',
|
||||
'remote',
|
||||
'gravatar',
|
||||
);
|
||||
}
|
||||
@@ -131,7 +130,6 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
|
||||
'avatar.driver.barfoo' => 'avatar.driver.barfoo',
|
||||
'avatar.driver.foobar' => 'avatar.driver.foobar',
|
||||
'avatar.driver.local' => 'avatar.driver.local',
|
||||
'avatar.driver.remote' => 'avatar.driver.remote',
|
||||
'avatar.driver.upload' => 'avatar.driver.upload',
|
||||
'avatar.driver.gravatar' => 'avatar.driver.gravatar',
|
||||
), $drivers);
|
||||
@@ -154,7 +152,6 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
|
||||
array('avatar.driver.local', null),
|
||||
array(AVATAR_GALLERY, null),
|
||||
array(AVATAR_UPLOAD, null),
|
||||
array(AVATAR_REMOTE, null),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -175,7 +172,6 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
|
||||
array('avatar.driver.local', 'avatar.driver.local'),
|
||||
array(AVATAR_GALLERY, 'avatar.driver.local'),
|
||||
array(AVATAR_UPLOAD, 'avatar.driver.upload'),
|
||||
array(AVATAR_REMOTE, 'avatar.driver.remote'),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -396,58 +392,4 @@ 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('AVATAR_URL_INVALID')),
|
||||
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
|
||||
array('2001:db8:0:0:0:0:2:1/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', 80, 80, array('AVATAR_URL_INVALID')),
|
||||
array('secure.gravatar.com/2001:db8:0:0:0:0:2:1/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', 80, 80, array('AVATAR_URL_INVALID')),
|
||||
array('secure.gravatar.com/127.0.0.1:80/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', 80, 80, array('AVATAR_URL_INVALID')),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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,
|
||||
));
|
||||
|
||||
$row = array();
|
||||
$error = array();
|
||||
|
||||
$return = $remote_avatar->process_form($request, null, $this->user, $row, $error);
|
||||
if (count($expected_error) > 0)
|
||||
{
|
||||
$this->assertFalse($return);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->assertNotEquals(false, $return);
|
||||
}
|
||||
$this->assertSame($expected_error, $error);
|
||||
}
|
||||
}
|
||||
|
@@ -55,12 +55,12 @@ class phpbb_functional_avatar_acp_groups_test extends phpbb_functional_common_av
|
||||
),
|
||||
),
|
||||
array(
|
||||
'The URL you specified is invalid.',
|
||||
'avatar_driver_remote',
|
||||
'EMAIL_INVALID_EMAIL',
|
||||
'avatar_driver_gravatar',
|
||||
array(
|
||||
'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg',
|
||||
'avatar_remote_width' => 80,
|
||||
'avatar_remote_height' => 80,
|
||||
'avatar_gravatar_email' => 'foobar123',
|
||||
'avatar_gravatar_width' => 120,
|
||||
'avatar_gravatar_height' => 120,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@@ -39,9 +39,11 @@ class phpbb_functional_avatar_acp_users_test extends phpbb_functional_common_ava
|
||||
// Remote avatar with correct link
|
||||
array(
|
||||
'USER_AVATAR_UPDATED',
|
||||
'avatar_driver_upload',
|
||||
'avatar_driver_gravatar',
|
||||
array(
|
||||
'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg',
|
||||
'avatar_gravatar_email' => 'test@example.com',
|
||||
'avatar_gravatar_width' => 80,
|
||||
'avatar_gravatar_height' => 80,
|
||||
),
|
||||
),
|
||||
// Reset avatar settings
|
||||
|
@@ -25,12 +25,14 @@ class phpbb_functional_avatar_ucp_groups_test extends phpbb_functional_common_av
|
||||
public function avatar_ucp_groups_data()
|
||||
{
|
||||
return array(
|
||||
// Incorrect URL
|
||||
// Gravatar with incorrect email
|
||||
array(
|
||||
'AVATAR_URL_INVALID',
|
||||
'avatar_driver_upload',
|
||||
'EMAIL_INVALID_EMAIL',
|
||||
'avatar_driver_gravatar',
|
||||
array(
|
||||
'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=80',
|
||||
'avatar_gravatar_email' => 'test.example.com',
|
||||
'avatar_gravatar_width' => 80,
|
||||
'avatar_gravatar_height' => 80,
|
||||
),
|
||||
),
|
||||
/*
|
||||
@@ -47,11 +49,11 @@ class phpbb_functional_avatar_ucp_groups_test extends phpbb_functional_common_av
|
||||
// Correct remote avatar
|
||||
array(
|
||||
'GROUP_UPDATED',
|
||||
'avatar_driver_remote',
|
||||
'avatar_driver_gravatar',
|
||||
array(
|
||||
'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg',
|
||||
'avatar_remote_width' => 80,
|
||||
'avatar_remote_height' => 80,
|
||||
'avatar_gravatar_email' => 'test@example.com',
|
||||
'avatar_gravatar_width' => 80,
|
||||
'avatar_gravatar_height' => 80,
|
||||
),
|
||||
),
|
||||
array(
|
||||
|
@@ -58,15 +58,17 @@ class phpbb_functional_avatar_ucp_users_test extends phpbb_functional_common_ava
|
||||
public function test_display_upload_avatar()
|
||||
{
|
||||
$this->assert_avatar_submit('PROFILE_UPDATED',
|
||||
'avatar_driver_upload',
|
||||
'avatar_driver_gravatar',
|
||||
array(
|
||||
'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg',
|
||||
)
|
||||
'avatar_gravatar_email' => 'test@example.com',
|
||||
'avatar_gravatar_width' => 80,
|
||||
'avatar_gravatar_height' => 80,
|
||||
),
|
||||
);
|
||||
|
||||
$crawler = self::request('GET', $this->get_url() . '&sid=' . $this->sid);
|
||||
$avatar_link = $crawler->filter('img')->attr('src');
|
||||
$crawler = self::request('GET', $avatar_link . '&sid=' . $this->sid, array(), false);
|
||||
self::request('GET', $avatar_link . '&sid=' . $this->sid, array(), false);
|
||||
$content = self::$client->getResponse()->getContent();
|
||||
self::assertEquals(false, stripos(trim($content), 'debug'), 'Output contains debug message');
|
||||
}
|
||||
|
@@ -35,7 +35,6 @@ abstract class phpbb_functional_common_avatar_test_case extends phpbb_functional
|
||||
$crawler = self::request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid);
|
||||
// Check the default entries we should have
|
||||
$this->assertContainsLang('ALLOW_GRAVATAR', $crawler->text());
|
||||
$this->assertContainsLang('ALLOW_REMOTE_UPLOAD', $crawler->text());
|
||||
$this->assertContainsLang('ALLOW_AVATARS', $crawler->text());
|
||||
$this->assertContainsLang('ALLOW_LOCAL', $crawler->text());
|
||||
|
||||
@@ -43,8 +42,6 @@ abstract class phpbb_functional_common_avatar_test_case extends phpbb_functional
|
||||
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
|
||||
$form['config[allow_avatar_local]']->select(1);
|
||||
$form['config[allow_avatar_gravatar]']->select(1);
|
||||
$form['config[allow_avatar_remote]']->select(1);
|
||||
$form['config[allow_avatar_remote_upload]']->select(1);
|
||||
$crawler = self::submit($form);
|
||||
$this->assertContainsLang('CONFIG_UPDATED', $crawler->text());
|
||||
}
|
||||
|
@@ -47,15 +47,12 @@ abstract class phpbb_functional_common_groups_test_case extends phpbb_functional
|
||||
|
||||
$crawler = self::request('GET', 'adm/index.php?i=board&mode=avatar&sid=' . $this->sid);
|
||||
// Check the default entries we should have
|
||||
$this->assertStringContainsString($this->lang('ALLOW_REMOTE_UPLOAD'), $crawler->text());
|
||||
$this->assertStringContainsString($this->lang('ALLOW_AVATARS'), $crawler->text());
|
||||
$this->assertStringContainsString($this->lang('ALLOW_LOCAL'), $crawler->text());
|
||||
|
||||
// Now start setting the needed settings
|
||||
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
|
||||
$form['config[allow_avatar_local]']->select(1);
|
||||
$form['config[allow_avatar_remote]']->select(1);
|
||||
$form['config[allow_avatar_remote_upload]']->select(1);
|
||||
$crawler = self::submit($form);
|
||||
$this->assertStringContainsString($this->lang('CONFIG_UPDATED'), $crawler->text());
|
||||
}
|
||||
@@ -84,34 +81,4 @@ abstract class phpbb_functional_common_groups_test_case extends phpbb_functional
|
||||
$crawler = self::submit($form);
|
||||
$this->assertStringContainsString($this->lang($expected), $crawler->text());
|
||||
}
|
||||
|
||||
public function group_avatar_min_max_data()
|
||||
{
|
||||
return array(
|
||||
array('avatar_driver_upload', 'avatar_upload_url', 'foo', 'AVATAR_URL_INVALID'),
|
||||
array('avatar_driver_upload', 'avatar_upload_url', 'foobar', 'AVATAR_URL_INVALID'),
|
||||
array('avatar_driver_upload', 'avatar_upload_url', 'http://www.phpbb.com/' . str_repeat('f', 240) . '.png', 'TOO_LONG'),
|
||||
array('avatar_driver_remote', 'avatar_remote_url', 'foo', 'AVATAR_URL_INVALID'),
|
||||
array('avatar_driver_remote', 'avatar_remote_url', 'foobar', 'AVATAR_URL_INVALID'),
|
||||
array('avatar_driver_remote', 'avatar_remote_url', 'http://www.phpbb.com/' . str_repeat('f', 240) . '.png', 'TOO_LONG'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider group_avatar_min_max_data
|
||||
*/
|
||||
public function test_group_avatar_min_max($avatar_type, $form_name, $input, $expected)
|
||||
{
|
||||
$this->login();
|
||||
$this->admin_login();
|
||||
$this->add_lang(array('ucp', 'acp/groups'));
|
||||
$this->enable_all_avatars();
|
||||
|
||||
$crawler = self::request('GET', $this->get_url() . '&g=5&sid=' . $this->sid);
|
||||
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
|
||||
$form['avatar_driver']->setValue($avatar_type);
|
||||
$form[$form_name]->setValue($input);
|
||||
$crawler = self::submit($form);
|
||||
$this->assertStringContainsString($this->lang($expected), $crawler->text());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user