namespace Friendica\Test\src\Console;
use Friendica\Console\ServerBlock;
+use Friendica\Core\Config\IConfig;
-/**
- * @runTestsInSeparateProcesses
- * @preserveGlobalState disabled
- */
class ServerBlockConsoleTest extends ConsoleTest
{
protected $defaultBlockList = [
{
parent::setUp();
- $this->mockApp($this->root);
+ $this->configMock = \Mockery::mock(IConfig::class);
}
/**
{
$this->configMock
->shouldReceive('get')
- ->with('system', 'blocklist')
+ ->with('system', 'blocklist', [])
->andReturn($this->defaultBlockList)
->once();
- $console = new ServerBlock($this->consoleArgv);
+ $console = new ServerBlock($this->configMock, $this->consoleArgv);
$txt = $this->dumpExecute($console);
$output = <<<CONS
{
$this->configMock
->shouldReceive('get')
- ->with('system', 'blocklist')
+ ->with('system', 'blocklist', [])
->andReturn($this->defaultBlockList)
->once();
->andReturn(true)
->once();
- $console = new ServerBlock($this->consoleArgv);
+ $console = new ServerBlock($this->configMock, $this->consoleArgv);
$console->setArgument(0, 'add');
$console->setArgument(1, 'testme.now');
$console->setArgument(2, 'I like it!');
{
$this->configMock
->shouldReceive('get')
- ->with('system', 'blocklist')
+ ->with('system', 'blocklist', [])
->andReturn($this->defaultBlockList)
->once();
->andReturn(true)
->once();
- $console = new ServerBlock($this->consoleArgv);
+ $console = new ServerBlock($this->configMock, $this->consoleArgv);
$console->setArgument(0, 'add');
$console->setArgument(1, 'testme.now');
$txt = $this->dumpExecute($console);
{
$this->configMock
->shouldReceive('get')
- ->with('system', 'blocklist')
+ ->with('system', 'blocklist', [])
->andReturn($this->defaultBlockList)
->once();
->andReturn(true)
->once();
- $console = new ServerBlock($this->consoleArgv);
+ $console = new ServerBlock($this->configMock, $this->consoleArgv);
$console->setArgument(0, 'add');
$console->setArgument(1, 'pod.ordoevangelistarum.com');
$console->setArgument(2, 'Other reason');
{
$this->configMock
->shouldReceive('get')
- ->with('system', 'blocklist')
+ ->with('system', 'blocklist', [])
->andReturn($this->defaultBlockList)
->once();
->andReturn(true)
->once();
- $console = new ServerBlock($this->consoleArgv);
+ $console = new ServerBlock($this->configMock, $this->consoleArgv);
$console->setArgument(0, 'remove');
$console->setArgument(1, 'pod.ordoevangelistarum.com');
$txt = $this->dumpExecute($console);
*/
public function testBlockedServersWrongCommand()
{
- $console = new ServerBlock($this->consoleArgv);
+ $console = new ServerBlock($this->configMock, $this->consoleArgv);
$console->setArgument(0, 'wrongcommand');
$txt = $this->dumpExecute($console);
{
$this->configMock
->shouldReceive('get')
- ->with('system', 'blocklist')
+ ->with('system', 'blocklist', [])
->andReturn($this->defaultBlockList)
->once();
- $console = new ServerBlock($this->consoleArgv);
+ $console = new ServerBlock($this->configMock, $this->consoleArgv);
$console->setArgument(0, 'remove');
$console->setArgument(1, 'not.exiting');
$txt = $this->dumpExecute($console);
*/
public function testAddBlockedServerMissingArgument()
{
- $console = new ServerBlock($this->consoleArgv);
+ $console = new ServerBlock($this->configMock, $this->consoleArgv);
$console->setArgument(0, 'add');
$txt = $this->dumpExecute($console);
{
$this->configMock
->shouldReceive('get')
- ->with('system', 'blocklist')
+ ->with('system', 'blocklist', [])
->andReturn($this->defaultBlockList)
->once();
->andReturn(false)
->once();
- $console = new ServerBlock($this->consoleArgv);
+ $console = new ServerBlock($this->configMock, $this->consoleArgv);
$console->setArgument(0, 'add');
$console->setArgument(1, 'testme.now');
$txt = $this->dumpExecute($console);
{
$this->configMock
->shouldReceive('get')
- ->with('system', 'blocklist')
+ ->with('system', 'blocklist', [])
->andReturn($this->defaultBlockList)
->once();
->andReturn(false)
->once();
- $console = new ServerBlock($this->consoleArgv);
+ $console = new ServerBlock($this->configMock, $this->consoleArgv);
$console->setArgument(0, 'remove');
$console->setArgument(1, 'pod.ordoevangelistarum.com');
$txt = $this->dumpExecute($console);
*/
public function testRemoveBlockedServerMissingArgument()
{
- $console = new ServerBlock($this->consoleArgv);
+ $console = new ServerBlock($this->configMock, $this->consoleArgv);
$console->setArgument(0, 'remove');
$txt = $this->dumpExecute($console);
*/
public function testBlockedServersHelp()
{
- $console = new ServerBlock($this->consoleArgv);
+ $console = new ServerBlock($this->configMock, $this->consoleArgv);
$console->setOption('help', true);
$txt = $this->dumpExecute($console);
$help = <<<HELP
-console serverblock - Manage blocked servers
+console serverblock - Manage blocked server domain patterns
Usage
bin/console serverblock [-h|--help|-?] [-v]
- bin/console serverblock add <server> <reason> [-h|--help|-?] [-v]
- bin/console serverblock remove <server> [-h|--help|-?] [-v]
+ bin/console serverblock add <pattern> <reason> [-h|--help|-?] [-v]
+ bin/console serverblock remove <pattern> [-h|--help|-?] [-v]
Description
- With this tool, you can list the current blocked servers
- or you can add / remove a blocked server from the list
+ With this tool, you can list the current blocked server domain patterns
+ or you can add / remove a blocked server domain pattern from the list.
+
+ Patterns are case-insensitive shell wildcard comprising the following special characters:
+ - * : Any number of characters
+ - ? : Any single character
+ - [<char1><char2>...] : char1 or char2 or...
Options
-h|--help|-? Show help information