1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-13 20:24:08 +02:00

Merge pull request #6802 from marc1706/ticket/17493

[ticket/17493] Drop support for jabber
This commit is contained in:
Marc Alexander
2025-04-24 19:47:48 +02:00
committed by GitHub
85 changed files with 359 additions and 3050 deletions

View File

@@ -152,7 +152,6 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case
'user_post_sortby_dir' => 'a',
'user_notify' => 0,
'user_notify_pm' => 1,
'user_notify_type' => 0,
'user_allow_pm' => 1,
'user_allow_viewonline' => 1,
'user_allow_viewemail' => 1,
@@ -165,7 +164,6 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case
'user_sig' => '',
'user_sig_bbcode_uid' => '',
'user_sig_bbcode_bitfield' => '',
'user_jabber' => '',
'user_actkey' => '',
'user_actkey_expiration' => 0,
'user_newpasswd' => '',

View File

@@ -263,7 +263,7 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca
protected function get_user_data($username)
{
$db = $this->get_db();
$sql = 'SELECT user_id, username, user_type, user_email, user_newpasswd, user_lang, user_notify_type, user_actkey, user_inactive_reason, reset_token, reset_token_expiration
$sql = 'SELECT user_id, username, user_type, user_email, user_newpasswd, user_lang, user_actkey, user_inactive_reason, reset_token, reset_token_expiration
FROM ' . USERS_TABLE . "
WHERE username = '" . $db->sql_escape($username) . "'";
$result = $db->sql_query($sql);

View File

@@ -1,83 +0,0 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
require_once __DIR__ . '/../../phpBB/includes/functions_user.php';
require_once __DIR__ . '/validate_data_helper.php';
class phpbb_functions_validate_jabber_test extends phpbb_test_case
{
protected $helper;
protected function setUp(): void
{
parent::setUp();
$this->helper = new phpbb_functions_validate_data_helper($this);
}
public function test_validate_jabber()
{
$this->helper->assert_valid_data(array(
'empty' => array(
array(),
'',
array('jabber'),
),
'no_seperator' => array(
array('WRONG_DATA'),
'testjabber.ccc',
array('jabber'),
),
'no_user' => array(
array('WRONG_DATA'),
'@jabber.ccc',
array('jabber'),
),
'no_realm' => array(
array('WRONG_DATA'),
'user@',
array('jabber'),
),
'dot_realm' => array(
array('WRONG_DATA'),
'user@.....',
array('jabber'),
),
'-realm' => array(
array('WRONG_DATA'),
'user@-jabber.ccc',
array('jabber'),
),
'realm-' => array(
array('WRONG_DATA'),
'user@jabber.ccc-',
array('jabber'),
),
'correct' => array(
array(),
'user@jabber.09A-z.org',
array('jabber'),
),
'prohibited' => array(
array('WRONG_DATA'),
'u@ser@jabber.ccc.org',
array('jabber'),
),
'prohibited_char' => array(
array('WRONG_DATA'),
'u<s>er@jabber.ccc.org',
array('jabber'),
),
));
}
}

View File

@@ -119,7 +119,6 @@ class phpbb_messenger_method_email_test extends \phpbb_test_case
public function test_miscellaneous(): void
{
$this->assertEquals(email::NOTIFY_EMAIL, $this->method_email->get_id());
$this->assertEquals('email', $this->method_email->get_queue_object_name());
$this->assertFalse($this->method_email->is_enabled());
$this->config->offsetSet('email_enable', true);

View File

@@ -1,311 +0,0 @@
<?php
use phpbb\config\config;
use phpbb\language\language;
use phpbb\language\language_file_loader;
use phpbb\messenger\method\jabber;
use phpbb\messenger\method\messenger_interface;
use phpbb\messenger\queue;
use phpbb\path_helper;
use phpbb\symfony_request;
use phpbb\template\assets_bag;
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
class phpbb_messenger_method_jabber_test extends \phpbb_test_case
{
protected $assets_bag;
protected $cache_path;
protected config $config;
protected $dispatcher;
protected $extension_manager;
protected jabber $method_jabber;
protected $method_base;
protected $language;
protected $log;
protected $path_helper;
protected queue $queue;
protected $request;
protected $twig_extensions_collection;
protected $twig_lexer;
protected $user;
public function setUp(): void
{
global $config, $request, $symfony_request, $user, $phpbb_root_path, $phpEx;
$this->assets_bag = new assets_bag();
$this->cache_path = $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/twig';
$this->config = new config([
'force_server_vars' => false,
'jab_username' => 'test',
'jab_password' => 'password',
'jab_use_ssl' => false,
'jab_host' => 'localhost',
'jab_port' => 5222,
'jab_verify_peer' => true,
'jab_verify_peer_name' => true,
'jab_allow_self_signed' => false,
]);
$config = $this->config;
$this->dispatcher = $this->getMockBuilder('\phpbb\event\dispatcher')
->disableOriginalConstructor()
->getMock();
$this->filesystem = new \phpbb\filesystem\filesystem();
$this->language = new language(new language_file_loader($phpbb_root_path, $phpEx));
$this->queue = $this->createMock(queue::class);
$this->request = new phpbb_mock_request();
$request = $this->request;
$this->symfony_request = new symfony_request(new phpbb_mock_request());
$symfony_request = $this->symfony_request;
$this->user = $this->getMockBuilder('\phpbb\user')
->setConstructorArgs([$this->language, '\phpbb\datetime'])
->getMock();
$user = $this->user;
$user->page['root_script_path'] = 'phpbb/';
$this->user->host = 'yourdomain.com';
$this->path_helper = new path_helper(
$this->symfony_request,
$this->request,
$phpbb_root_path,
$phpEx
);
$phpbb_container = new phpbb_mock_container_builder;
$this->twig_extensions_collection = new \phpbb\di\service_collection($phpbb_container);
$twig = new \phpbb\template\twig\environment(
$this->assets_bag,
$this->config,
$this->filesystem,
$this->path_helper,
$this->cache_path,
null,
new \phpbb\template\twig\loader(''),
$this->dispatcher,
array(
'cache' => false,
'debug' => false,
'auto_reload' => true,
'autoescape' => false,
)
);
$this->twig_lexer = new \phpbb\template\twig\lexer($twig);
$this->extension_manager = new phpbb_mock_extension_manager(
__DIR__ . '/',
array(
'vendor2/foo' => array(
'ext_name' => 'vendor2/foo',
'ext_active' => '1',
'ext_path' => 'ext/vendor2/foo/',
),
)
);
$this->log = $this->createMock(\phpbb\log\log_interface::class);
$this->method_jabber = new jabber(
$this->assets_bag,
$this->config,
$this->dispatcher,
$this->language,
$this->queue,
$this->path_helper,
$this->request,
$this->twig_extensions_collection,
$this->twig_lexer,
$this->user,
$phpbb_root_path,
$this->cache_path,
$this->extension_manager,
$this->log
);
}
public function test_miscellaneous()
{
$this->method_jabber->init();
$this->assertEquals(messenger_interface::NOTIFY_IM, $this->method_jabber->get_id());
$this->assertEquals('jabber', $this->method_jabber->get_queue_object_name());
$this->assertFalse($this->method_jabber->is_enabled());
$this->config->set('jab_enable', true);
$this->assertTrue($this->method_jabber->is_enabled());
$this->assertEquals(@extension_loaded('openssl'), $this->method_jabber->can_use_ssl());
}
public function test_stream_options()
{
$this->method_jabber->init();
$this->assertEquals($this->method_jabber, $this->method_jabber->stream_options([
'allow_self_signed' => true,
]));
$stream_options_reflection = new \ReflectionProperty($this->method_jabber, 'stream_options');
$stream_options = $stream_options_reflection->getValue($this->method_jabber);
$this->assertEquals([
'ssl' => [
'allow_self_signed' => false,
'verify_peer' => true,
'verify_peer_name' => true,
],
], $stream_options);
$this->method_jabber->ssl(true);
$this->assertEquals($this->method_jabber, $this->method_jabber->stream_options([
'allow_self_signed' => true,
]));
$stream_options = $stream_options_reflection->getValue($this->method_jabber);
$this->assertEquals([
'ssl' => [
'allow_self_signed' => true,
'verify_peer' => true,
'verify_peer_name' => true,
],
], $stream_options);
}
public function test_port_ssl_switch()
{
$port_reflection = new \ReflectionProperty($this->method_jabber, 'port');
$this->method_jabber->port();
$this->assertEquals(5222, $port_reflection->getValue($this->method_jabber));
$this->method_jabber->ssl(true)
->port();
$this->assertEquals(5223, $port_reflection->getValue($this->method_jabber));
}
public function test_username()
{
$jabber_reflection = new \ReflectionClass($this->method_jabber);
$username_reflection = $jabber_reflection->getProperty('username');
$jid_reflection = $jabber_reflection->getProperty('jid');
$this->method_jabber->username('foo@bar');
$this->assertEquals(['foo', 'bar'], $jid_reflection->getValue($this->method_jabber));
$this->assertEquals('foo', $username_reflection->getValue($this->method_jabber));
$this->method_jabber->username('bar@baz@qux');
$this->assertEquals(['bar', 'baz@qux'], $jid_reflection->getValue($this->method_jabber));
$this->assertEquals('bar', $username_reflection->getValue($this->method_jabber));
}
public function test_server()
{
$jabber_reflection = new \ReflectionClass($this->method_jabber);
$connect_server_reflection = $jabber_reflection->getProperty('connect_server');
$server_reflection = $jabber_reflection->getProperty('server');
$this->method_jabber->server();
$this->assertEquals('localhost', $connect_server_reflection->getValue($this->method_jabber));
$this->assertEquals('localhost', $server_reflection->getValue($this->method_jabber));
$this->method_jabber->server('foobar.com');
$this->assertEquals('foobar.com', $connect_server_reflection->getValue($this->method_jabber));
$this->assertEquals('foobar.com', $server_reflection->getValue($this->method_jabber));
$this->method_jabber->username('foo@bar.com');
$this->method_jabber->server('foobar.com');
$this->assertEquals('foobar.com', $connect_server_reflection->getValue($this->method_jabber));
$this->assertEquals('bar.com', $server_reflection->getValue($this->method_jabber));
}
public function test_encrypt_password()
{
$this->method_jabber->init();
$this->method_jabber->password('password');
$data = [
'realm' => 'example.com',
'nonce' => '12345',
'cnonce' => 'abcde',
'digest-uri' => 'xmpp/example.com',
'nc' => '00000001',
'qop' => 'auth',
];
$expected = md5(sprintf(
'%s:%s:%s:%s:%s:%s',
md5(pack('H32', md5('test:example.com:password')) . ':12345:abcde'),
$data['nonce'],
$data['nc'],
$data['cnonce'],
$data['qop'],
md5('AUTHENTICATE:xmpp/example.com')
));
$this->assertEquals($expected, $this->method_jabber->encrypt_password($data));
}
public function test_parse_data()
{
$data = 'key1="value1",key2="value2",key3="value3"';
$expected = [
'key1' => 'value1',
'key2' => 'value2',
'key3' => 'value3',
];
$this->assertEquals($expected, $this->method_jabber->parse_data($data));
}
public function test_implode_data()
{
$data = [
'key1' => 'value1',
'key2' => 'value2',
'key3' => 'value3',
];
$expected = 'key1="value1",key2="value2",key3="value3"';
$this->assertEquals($expected, $this->method_jabber->implode_data($data));
}
public function test_xmlize()
{
$xml = '<root><child key="value">content</child></root>';
$result = $this->method_jabber->xmlize($xml);
$this->assertArrayHasKey('root', $result);
$this->assertArrayHasKey('child', $result['root'][0]['#']);
$this->assertEquals('content', $result['root'][0]['#']['child'][0]['#']);
$this->assertEquals(['key' => 'value'], $result['root'][0]['#']['child'][0]['@']);
}
public function test_send_xml()
{
$jabber_mock = $this->getMockBuilder(jabber::class)
->setConstructorArgs([
$this->assets_bag,
$this->config,
$this->dispatcher,
$this->language,
$this->queue,
$this->path_helper,
$this->request,
$this->twig_extensions_collection,
$this->twig_lexer,
$this->user,
'',
'',
$this->extension_manager,
$this->log,
])
->onlyMethods(['send_xml'])
->getMock();
$jabber_mock->expects($this->once())
->method('send_xml')
->with('<message>Test</message>')
->willReturn(true);
$this->assertTrue($jabber_mock->send_xml('<message>Test</message>'));
}
}

View File

@@ -202,20 +202,14 @@ class phpbb_messenger_queue_test extends phpbb_test_case
// First save queue data
$this->assertFileDoesNotExist($this->cache_file);
$this->messenger_queue->init('email', 5);
$this->messenger_queue->init('jabber', 10);
$this->assertEquals([
'email' => [
'package_size' => 5,
'data' => [],
],
'jabber' => [
'package_size' => 10,
'data' => [],
]
], $this->messenger_queue->get_data());
$this->messenger_queue->put('email', ['data1']);
$this->messenger_queue->put('jabber', ['data2']);
$this->messenger_queue->save();
$this->assertFileExists($this->cache_file);
$this->assertEquals([], $this->messenger_queue->get_data());
@@ -239,27 +233,10 @@ class phpbb_messenger_queue_test extends phpbb_test_case
], $queue_data['email']);
unset($queue_data['email']);
});
$jabber_method = $this->getMockBuilder('phpbb\messenger\method\jabber')
->disableOriginalConstructor()
->onlyMethods(['get_queue_object_name', 'process_queue'])
->getMock();
$jabber_method->method('get_queue_object_name')
->willReturn('jabber');
$jabber_method->method('process_queue')
->willReturnCallback(function(array &$queue_data) {
$this->assertEquals([
'package_size' => 10,
'data' => [
['data2'],
],
], $queue_data['jabber']);
unset($queue_data['jabber']);
});
$this->service_collection->method('getIterator')
->willReturn(new \ArrayIterator([
'email' => $email_method,
'jabber' => $jabber_method,
]));
// Process the queue

View File

@@ -148,7 +148,6 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
$messenger_method_collection = new \phpbb\di\service_collection($phpbb_container);
$messenger_method_collection->add('messenger.method.email');
$messenger_method_collection->add('messenger.method.jabber');
$phpbb_container->set('messenger.method_collection', $messenger_method_collection);
$phpbb_container->compile();

View File

@@ -30,15 +30,33 @@ class phpbb_notification_convert_test extends phpbb_database_test_case
$this->db = $this->new_dbal();
$this->doctrine_db = $this->new_doctrine_dbal();
$factory = new \phpbb\db\tools\factory();
$db_tools = $factory->get($this->doctrine_db);
$core_tables = self::get_core_tables();
// Add user_notify_type column for testing this migration and set type
$db_tools->sql_column_add($core_tables['users'], 'user_notify_type', ['TINT:4', 0]);
$user_notify_type_map = [
1 => 0,
2 => 0,
3 => 1,
4 => 1,
5 => 2,
6 => 2,
];
foreach ($user_notify_type_map as $user_id => $notify_type)
{
$this->db->sql_query('UPDATE ' . $core_tables['users'] . ' SET user_notify_type = ' . (int) $notify_type . ' WHERE user_id = ' . (int) $user_id);
}
$this->migration = new \phpbb\db\migration\data\v310\notification_options_reconvert(
new \phpbb\config\config(array()),
$this->db,
$factory->get($this->doctrine_db),
$db_tools,
$phpbb_root_path,
$phpEx,
'phpbb_',
self::get_core_tables()
$core_tables
);
}

View File

@@ -4,7 +4,6 @@
<column>user_id</column>
<column>username</column>
<column>username_clean</column>
<column>user_notify_type</column>
<column>user_notify_pm</column>
<column>user_permissions</column>
<column>user_sig</column>
@@ -13,7 +12,6 @@
<value>1</value>
<value>1</value>
<value>0</value>
<value>0</value>
<value></value>
<value></value>
</row>
@@ -21,7 +19,6 @@
<value>2</value>
<value>2</value>
<value>2</value>
<value>0</value>
<value>1</value>
<value></value>
<value></value>
@@ -30,7 +27,6 @@
<value>3</value>
<value>3</value>
<value>3</value>
<value>1</value>
<value>0</value>
<value></value>
<value></value>
@@ -40,7 +36,6 @@
<value>4</value>
<value>4</value>
<value>1</value>
<value>1</value>
<value></value>
<value></value>
</row>
@@ -48,7 +43,6 @@
<value>5</value>
<value>5</value>
<value>5</value>
<value>2</value>
<value>0</value>
<value></value>
<value></value>
@@ -57,7 +51,6 @@
<value>6</value>
<value>6</value>
<value>6</value>
<value>2</value>
<value>1</value>
<value></value>
<value></value>

View File

@@ -107,7 +107,6 @@ class notification_method_email_test extends phpbb_tests_notification_base
$messenger_method_collection = new \phpbb\di\service_collection($phpbb_container);
$messenger_method_collection->add('messenger.method.email');
$messenger_method_collection->add('messenger.method.jabber');
$phpbb_container->set('messenger.method_collection', $messenger_method_collection);
$this->notification_method_email = $this->getMockBuilder('\phpbb\notification\method\email')

View File

@@ -161,7 +161,6 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
$messenger_method_collection = new \phpbb\di\service_collection($phpbb_container);
$messenger_method_collection->add('messenger.method.email');
$messenger_method_collection->add('messenger.method.jabber');
$phpbb_container->set('messenger.method_collection', $messenger_method_collection);
$phpbb_container->addCompilerPass(new phpbb\di\pass\markpublic_pass());