2017-09-15 00:41:04 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
|
|
|
|
*
|
|
|
|
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
|
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Test\Collaboration\Collaborators;
|
|
|
|
|
|
|
|
use OC\Collaboration\Collaborators\LookupPlugin;
|
2018-10-09 19:31:33 +03:00
|
|
|
use OC\Federation\CloudId;
|
2017-09-15 00:41:04 +03:00
|
|
|
use OCP\Collaboration\Collaborators\ISearchResult;
|
|
|
|
use OCP\Collaboration\Collaborators\SearchResultType;
|
2018-10-09 19:31:33 +03:00
|
|
|
use OCP\Federation\ICloudId;
|
|
|
|
use OCP\Federation\ICloudIdManager;
|
2017-09-15 00:41:04 +03:00
|
|
|
use OCP\Http\Client\IClient;
|
|
|
|
use OCP\Http\Client\IClientService;
|
|
|
|
use OCP\Http\Client\IResponse;
|
|
|
|
use OCP\IConfig;
|
2018-10-10 17:07:01 +03:00
|
|
|
use OCP\ILogger;
|
2018-10-09 19:31:33 +03:00
|
|
|
use OCP\IUser;
|
|
|
|
use OCP\IUserSession;
|
2020-06-24 17:49:16 +03:00
|
|
|
use OCP\Share\IShare;
|
2017-09-15 00:41:04 +03:00
|
|
|
use Test\TestCase;
|
|
|
|
|
|
|
|
class LookupPluginTest extends TestCase {
|
|
|
|
|
2020-08-11 22:32:18 +03:00
|
|
|
/** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
|
2017-09-15 00:41:04 +03:00
|
|
|
protected $config;
|
2020-08-11 22:32:18 +03:00
|
|
|
/** @var IClientService|\PHPUnit\Framework\MockObject\MockObject */
|
2017-09-15 00:41:04 +03:00
|
|
|
protected $clientService;
|
2020-08-11 22:32:18 +03:00
|
|
|
/** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */
|
2018-10-09 19:31:33 +03:00
|
|
|
protected $userSession;
|
2020-08-11 22:32:18 +03:00
|
|
|
/** @var ICloudIdManager|\PHPUnit\Framework\MockObject\MockObject */
|
2018-10-09 19:31:33 +03:00
|
|
|
protected $cloudIdManager;
|
2017-09-15 00:41:04 +03:00
|
|
|
/** @var LookupPlugin */
|
|
|
|
protected $plugin;
|
2020-08-11 22:32:18 +03:00
|
|
|
/** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */
|
2018-10-10 17:07:01 +03:00
|
|
|
protected $logger;
|
2017-09-15 00:41:04 +03:00
|
|
|
|
2019-11-27 17:27:18 +03:00
|
|
|
protected function setUp(): void {
|
2017-09-15 00:41:04 +03:00
|
|
|
parent::setUp();
|
|
|
|
|
2018-10-09 19:31:33 +03:00
|
|
|
$this->userSession = $this->createMock(IUserSession::class);
|
|
|
|
$this->cloudIdManager = $this->createMock(ICloudIdManager::class);
|
2017-09-15 00:41:04 +03:00
|
|
|
$this->config = $this->createMock(IConfig::class);
|
2018-10-10 17:07:01 +03:00
|
|
|
$this->logger = $this->createMock(ILogger::class);
|
2017-09-15 00:41:04 +03:00
|
|
|
$this->clientService = $this->createMock(IClientService::class);
|
2018-10-09 19:31:33 +03:00
|
|
|
$cloudId = $this->createMock(ICloudId::class);
|
|
|
|
$cloudId->expects($this->any())->method('getRemote')->willReturn('myNextcloud.net');
|
|
|
|
$user = $this->createMock(IUser::class);
|
|
|
|
$user->expects($this->any())->method('getCloudId')->willReturn('user@myNextcloud.net');
|
|
|
|
$this->userSession->expects($this->any())->method('getUser')
|
|
|
|
->willReturn($user);
|
|
|
|
$this->cloudIdManager->expects($this->any())->method('resolveCloudId')
|
2018-10-17 14:09:11 +03:00
|
|
|
->willReturnCallback(function ($cloudId) {
|
2018-10-09 19:31:33 +03:00
|
|
|
if ($cloudId === 'user@myNextcloud.net') {
|
|
|
|
return new CloudId('user@myNextcloud.net', 'user', 'myNextcloud.net');
|
|
|
|
}
|
|
|
|
return new CloudId('user@someNextcloud.net', 'user', 'someNextcloud.net');
|
|
|
|
});
|
|
|
|
|
2017-09-15 00:41:04 +03:00
|
|
|
|
2018-10-10 17:07:01 +03:00
|
|
|
$this->plugin = new LookupPlugin(
|
|
|
|
$this->config,
|
|
|
|
$this->clientService,
|
|
|
|
$this->userSession,
|
|
|
|
$this->cloudIdManager,
|
|
|
|
$this->logger
|
|
|
|
);
|
2017-09-15 00:41:04 +03:00
|
|
|
}
|
|
|
|
|
2018-10-17 14:09:11 +03:00
|
|
|
public function testSearchNoLookupServerURI() {
|
|
|
|
$this->config->expects($this->once())
|
|
|
|
->method('getAppValue')
|
2019-02-21 23:36:14 +03:00
|
|
|
->with('files_sharing', 'lookupServerEnabled', 'yes')
|
2018-10-17 14:09:11 +03:00
|
|
|
->willReturn('yes');
|
|
|
|
$this->config->expects($this->at(0))
|
|
|
|
->method('getSystemValue')
|
|
|
|
->with('gs.enabled', false)
|
|
|
|
->willReturn(false);
|
|
|
|
|
|
|
|
$this->config->expects($this->at(2))
|
2021-04-16 10:41:54 +03:00
|
|
|
->method('getSystemValueBool')
|
2018-10-17 14:09:11 +03:00
|
|
|
->with('has_internet_connection', true)
|
|
|
|
->willReturn(true);
|
|
|
|
$this->config->expects($this->at(3))
|
|
|
|
->method('getSystemValue')
|
|
|
|
->with('lookup_server', 'https://lookup.nextcloud.com')
|
|
|
|
->willReturn('');
|
|
|
|
|
|
|
|
$this->clientService->expects($this->never())
|
|
|
|
->method('newClient');
|
|
|
|
|
2020-08-11 22:32:18 +03:00
|
|
|
/** @var ISearchResult|\PHPUnit\Framework\MockObject\MockObject $searchResult */
|
2018-10-17 14:09:11 +03:00
|
|
|
$searchResult = $this->createMock(ISearchResult::class);
|
|
|
|
|
|
|
|
$this->plugin->search('foobar', 10, 0, $searchResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSearchNoInternet() {
|
|
|
|
$this->config->expects($this->once())
|
|
|
|
->method('getAppValue')
|
2019-02-21 23:36:14 +03:00
|
|
|
->with('files_sharing', 'lookupServerEnabled', 'yes')
|
2018-10-17 14:09:11 +03:00
|
|
|
->willReturn('yes');
|
|
|
|
$this->config->expects($this->at(0))
|
|
|
|
->method('getSystemValue')
|
|
|
|
->with('gs.enabled', false)
|
|
|
|
->willReturn(false);
|
|
|
|
|
|
|
|
$this->config->expects($this->at(2))
|
2021-04-16 10:41:54 +03:00
|
|
|
->method('getSystemValueBool')
|
2018-10-17 14:09:11 +03:00
|
|
|
->with('has_internet_connection', true)
|
|
|
|
->willReturn(false);
|
|
|
|
|
|
|
|
$this->clientService->expects($this->never())
|
|
|
|
->method('newClient');
|
|
|
|
|
2020-08-11 22:32:18 +03:00
|
|
|
/** @var ISearchResult|\PHPUnit\Framework\MockObject\MockObject $searchResult */
|
2018-10-17 14:09:11 +03:00
|
|
|
$searchResult = $this->createMock(ISearchResult::class);
|
|
|
|
|
|
|
|
$this->plugin->search('foobar', 10, 0, $searchResult);
|
|
|
|
}
|
|
|
|
|
2017-09-15 00:41:04 +03:00
|
|
|
/**
|
|
|
|
* @dataProvider searchDataProvider
|
|
|
|
* @param array $searchParams
|
|
|
|
*/
|
|
|
|
public function testSearch(array $searchParams) {
|
|
|
|
$type = new SearchResultType('lookup');
|
|
|
|
|
2020-08-11 22:32:18 +03:00
|
|
|
/** @var ISearchResult|\PHPUnit\Framework\MockObject\MockObject $searchResult */
|
2017-09-15 00:41:04 +03:00
|
|
|
$searchResult = $this->createMock(ISearchResult::class);
|
|
|
|
$searchResult->expects($this->once())
|
|
|
|
->method('addResultSet')
|
|
|
|
->with($type, $searchParams['expectedResult'], []);
|
|
|
|
|
|
|
|
$this->config->expects($this->once())
|
|
|
|
->method('getAppValue')
|
2019-02-21 23:36:14 +03:00
|
|
|
->with('files_sharing', 'lookupServerEnabled', 'yes')
|
2017-09-15 00:41:04 +03:00
|
|
|
->willReturn('yes');
|
2018-10-09 19:31:33 +03:00
|
|
|
$this->config->expects($this->at(0))
|
|
|
|
->method('getSystemValue')
|
|
|
|
->with('gs.enabled', false)
|
|
|
|
->willReturn(false);
|
2018-10-17 14:09:11 +03:00
|
|
|
|
2018-10-09 19:31:33 +03:00
|
|
|
$this->config->expects($this->at(2))
|
2021-04-16 10:41:54 +03:00
|
|
|
->method('getSystemValueBool')
|
2018-10-17 14:09:11 +03:00
|
|
|
->with('has_internet_connection', true)
|
|
|
|
->willReturn(true);
|
|
|
|
$this->config->expects($this->at(3))
|
2017-09-15 00:41:04 +03:00
|
|
|
->method('getSystemValue')
|
|
|
|
->with('lookup_server', 'https://lookup.nextcloud.com')
|
|
|
|
->willReturn($searchParams['server']);
|
|
|
|
|
|
|
|
$response = $this->createMock(IResponse::class);
|
|
|
|
$response->expects($this->once())
|
|
|
|
->method('getBody')
|
|
|
|
->willReturn(json_encode($searchParams['resultBody']));
|
|
|
|
|
|
|
|
$client = $this->createMock(IClient::class);
|
|
|
|
$client->expects($this->once())
|
|
|
|
->method('get')
|
2018-10-17 14:09:11 +03:00
|
|
|
->willReturnCallback(function ($url) use ($searchParams, $response) {
|
2017-09-15 00:41:04 +03:00
|
|
|
$this->assertSame(strpos($url, $searchParams['server'] . '/users?search='), 0);
|
|
|
|
$this->assertNotFalse(strpos($url, urlencode($searchParams['search'])));
|
|
|
|
return $response;
|
|
|
|
});
|
|
|
|
|
|
|
|
$this->clientService->expects($this->once())
|
|
|
|
->method('newClient')
|
|
|
|
->willReturn($client);
|
|
|
|
|
|
|
|
$moreResults = $this->plugin->search(
|
|
|
|
$searchParams['search'],
|
|
|
|
$searchParams['limit'],
|
|
|
|
$searchParams['offset'],
|
|
|
|
$searchResult
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertFalse($moreResults);
|
|
|
|
}
|
|
|
|
|
2018-10-12 17:11:48 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider dataSearchEnableDisableLookupServer
|
|
|
|
* @param array $searchParams
|
|
|
|
* @param bool $GSEnabled
|
|
|
|
* @param bool $LookupEnabled
|
|
|
|
*/
|
|
|
|
public function testSearchEnableDisableLookupServer(array $searchParams, $GSEnabled, $LookupEnabled) {
|
|
|
|
$type = new SearchResultType('lookup');
|
|
|
|
|
2020-08-11 22:32:18 +03:00
|
|
|
/** @var ISearchResult|\PHPUnit\Framework\MockObject\MockObject $searchResult */
|
2018-10-12 17:11:48 +03:00
|
|
|
$searchResult = $this->createMock(ISearchResult::class);
|
|
|
|
|
|
|
|
$this->config->expects($this->once())
|
|
|
|
->method('getAppValue')
|
2019-02-21 23:36:14 +03:00
|
|
|
->with('files_sharing', 'lookupServerEnabled', 'yes')
|
2018-10-12 17:11:48 +03:00
|
|
|
->willReturn($LookupEnabled ? 'yes' : 'no');
|
|
|
|
$this->config->expects($this->at(0))
|
|
|
|
->method('getSystemValue')
|
|
|
|
->with('gs.enabled', false)
|
|
|
|
->willReturn($GSEnabled);
|
|
|
|
if ($GSEnabled || $LookupEnabled) {
|
|
|
|
$searchResult->expects($this->once())
|
|
|
|
->method('addResultSet')
|
|
|
|
->with($type, $searchParams['expectedResult'], []);
|
|
|
|
|
|
|
|
$this->config->expects($this->at(2))
|
2021-04-16 10:41:54 +03:00
|
|
|
->method('getSystemValueBool')
|
2018-10-17 14:09:11 +03:00
|
|
|
->with('has_internet_connection', true)
|
|
|
|
->willReturn(true);
|
|
|
|
$this->config->expects($this->at(3))
|
2018-10-12 17:11:48 +03:00
|
|
|
->method('getSystemValue')
|
|
|
|
->with('lookup_server', 'https://lookup.nextcloud.com')
|
|
|
|
->willReturn($searchParams['server']);
|
|
|
|
|
|
|
|
$response = $this->createMock(IResponse::class);
|
|
|
|
$response->expects($this->once())
|
|
|
|
->method('getBody')
|
|
|
|
->willReturn(json_encode($searchParams['resultBody']));
|
|
|
|
|
|
|
|
$client = $this->createMock(IClient::class);
|
|
|
|
$client->expects($this->once())
|
|
|
|
->method('get')
|
|
|
|
->willReturnCallback(function ($url) use ($searchParams, $response) {
|
|
|
|
$this->assertSame(strpos($url, $searchParams['server'] . '/users?search='), 0);
|
|
|
|
$this->assertNotFalse(strpos($url, urlencode($searchParams['search'])));
|
|
|
|
return $response;
|
|
|
|
});
|
|
|
|
|
|
|
|
$this->clientService->expects($this->once())
|
|
|
|
->method('newClient')
|
|
|
|
->willReturn($client);
|
|
|
|
} else {
|
|
|
|
$searchResult->expects($this->never())->method('addResultSet');
|
|
|
|
}
|
|
|
|
$moreResults = $this->plugin->search(
|
|
|
|
$searchParams['search'],
|
|
|
|
$searchParams['limit'],
|
|
|
|
$searchParams['offset'],
|
|
|
|
$searchResult
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertFalse($moreResults);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-15 00:41:04 +03:00
|
|
|
public function testSearchLookupServerDisabled() {
|
|
|
|
$this->config->expects($this->once())
|
|
|
|
->method('getAppValue')
|
2019-02-21 23:36:14 +03:00
|
|
|
->with('files_sharing', 'lookupServerEnabled', 'yes')
|
2017-09-15 00:41:04 +03:00
|
|
|
->willReturn('no');
|
|
|
|
|
2020-08-11 22:32:18 +03:00
|
|
|
/** @var ISearchResult|\PHPUnit\Framework\MockObject\MockObject $searchResult */
|
2017-09-15 00:41:04 +03:00
|
|
|
$searchResult = $this->createMock(ISearchResult::class);
|
|
|
|
$searchResult->expects($this->never())
|
|
|
|
->method('addResultSet');
|
|
|
|
$searchResult->expects($this->never())
|
|
|
|
->method('markExactIdMatch');
|
|
|
|
|
|
|
|
$this->assertFalse($this->plugin->search('irr', 10, 0, $searchResult));
|
|
|
|
}
|
|
|
|
|
2018-10-12 17:11:48 +03:00
|
|
|
public function dataSearchEnableDisableLookupServer() {
|
|
|
|
$fedIDs = [
|
|
|
|
'foo@enceladus.moon',
|
|
|
|
'foobar@enceladus.moon',
|
|
|
|
'foongus@enceladus.moon',
|
|
|
|
];
|
|
|
|
|
|
|
|
return [
|
|
|
|
[[
|
|
|
|
'search' => 'foo',
|
|
|
|
'limit' => 10,
|
|
|
|
'offset' => 0,
|
|
|
|
'server' => 'https://lookup.example.io',
|
|
|
|
'resultBody' => [
|
2018-10-17 14:09:11 +03:00
|
|
|
['federationId' => $fedIDs[0]],
|
|
|
|
['federationId' => $fedIDs[1]],
|
|
|
|
['federationId' => $fedIDs[2]],
|
2018-10-12 17:11:48 +03:00
|
|
|
],
|
|
|
|
'expectedResult' => [
|
|
|
|
[
|
|
|
|
'label' => $fedIDs[0],
|
|
|
|
'value' => [
|
2020-06-24 17:49:16 +03:00
|
|
|
'shareType' => IShare::TYPE_REMOTE,
|
2018-10-12 17:11:48 +03:00
|
|
|
'shareWith' => $fedIDs[0]
|
|
|
|
],
|
|
|
|
'extra' => ['federationId' => $fedIDs[0]],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'label' => $fedIDs[1],
|
|
|
|
'value' => [
|
2020-06-24 17:49:16 +03:00
|
|
|
'shareType' => IShare::TYPE_REMOTE,
|
2018-10-12 17:11:48 +03:00
|
|
|
'shareWith' => $fedIDs[1]
|
|
|
|
],
|
|
|
|
'extra' => ['federationId' => $fedIDs[1]],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'label' => $fedIDs[2],
|
|
|
|
'value' => [
|
2020-06-24 17:49:16 +03:00
|
|
|
'shareType' => IShare::TYPE_REMOTE,
|
2018-10-12 17:11:48 +03:00
|
|
|
'shareWith' => $fedIDs[2]
|
|
|
|
],
|
|
|
|
'extra' => ['federationId' => $fedIDs[2]],
|
|
|
|
],
|
|
|
|
]
|
|
|
|
],// GS , Lookup
|
|
|
|
true, true
|
|
|
|
],
|
|
|
|
[[
|
|
|
|
'search' => 'foo',
|
|
|
|
'limit' => 10,
|
|
|
|
'offset' => 0,
|
|
|
|
'server' => 'https://lookup.example.io',
|
|
|
|
'resultBody' => [
|
2018-10-17 14:09:11 +03:00
|
|
|
['federationId' => $fedIDs[0]],
|
|
|
|
['federationId' => $fedIDs[1]],
|
|
|
|
['federationId' => $fedIDs[2]],
|
2018-10-12 17:11:48 +03:00
|
|
|
],
|
|
|
|
'expectedResult' => [
|
|
|
|
[
|
|
|
|
'label' => $fedIDs[0],
|
|
|
|
'value' => [
|
2020-06-24 17:49:16 +03:00
|
|
|
'shareType' => IShare::TYPE_REMOTE,
|
2018-10-12 17:11:48 +03:00
|
|
|
'shareWith' => $fedIDs[0]
|
|
|
|
],
|
|
|
|
'extra' => ['federationId' => $fedIDs[0]],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'label' => $fedIDs[1],
|
|
|
|
'value' => [
|
2020-06-24 17:49:16 +03:00
|
|
|
'shareType' => IShare::TYPE_REMOTE,
|
2018-10-12 17:11:48 +03:00
|
|
|
'shareWith' => $fedIDs[1]
|
|
|
|
],
|
|
|
|
'extra' => ['federationId' => $fedIDs[1]],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'label' => $fedIDs[2],
|
|
|
|
'value' => [
|
2020-06-24 17:49:16 +03:00
|
|
|
'shareType' => IShare::TYPE_REMOTE,
|
2018-10-12 17:11:48 +03:00
|
|
|
'shareWith' => $fedIDs[2]
|
|
|
|
],
|
|
|
|
'extra' => ['federationId' => $fedIDs[2]],
|
|
|
|
],
|
|
|
|
]
|
|
|
|
],// GS , Lookup
|
|
|
|
true, false
|
|
|
|
],
|
|
|
|
[[
|
|
|
|
'search' => 'foo',
|
|
|
|
'limit' => 10,
|
|
|
|
'offset' => 0,
|
|
|
|
'server' => 'https://lookup.example.io',
|
|
|
|
'resultBody' => [
|
2018-10-17 14:09:11 +03:00
|
|
|
['federationId' => $fedIDs[0]],
|
|
|
|
['federationId' => $fedIDs[1]],
|
|
|
|
['federationId' => $fedIDs[2]],
|
2018-10-12 17:11:48 +03:00
|
|
|
],
|
|
|
|
'expectedResult' => [
|
|
|
|
[
|
|
|
|
'label' => $fedIDs[0],
|
|
|
|
'value' => [
|
2020-06-24 17:49:16 +03:00
|
|
|
'shareType' => IShare::TYPE_REMOTE,
|
2018-10-12 17:11:48 +03:00
|
|
|
'shareWith' => $fedIDs[0]
|
|
|
|
],
|
|
|
|
'extra' => ['federationId' => $fedIDs[0]],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'label' => $fedIDs[1],
|
|
|
|
'value' => [
|
2020-06-24 17:49:16 +03:00
|
|
|
'shareType' => IShare::TYPE_REMOTE,
|
2018-10-12 17:11:48 +03:00
|
|
|
'shareWith' => $fedIDs[1]
|
|
|
|
],
|
|
|
|
'extra' => ['federationId' => $fedIDs[1]],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'label' => $fedIDs[2],
|
|
|
|
'value' => [
|
2020-06-24 17:49:16 +03:00
|
|
|
'shareType' => IShare::TYPE_REMOTE,
|
2018-10-12 17:11:48 +03:00
|
|
|
'shareWith' => $fedIDs[2]
|
|
|
|
],
|
|
|
|
'extra' => ['federationId' => $fedIDs[2]],
|
|
|
|
],
|
|
|
|
]
|
|
|
|
],// GS , Lookup
|
|
|
|
false, true
|
|
|
|
],
|
|
|
|
[[
|
|
|
|
'search' => 'foo',
|
|
|
|
'limit' => 10,
|
|
|
|
'offset' => 0,
|
|
|
|
'server' => 'https://lookup.example.io',
|
|
|
|
'resultBody' => [
|
2018-10-17 14:09:11 +03:00
|
|
|
['federationId' => $fedIDs[0]],
|
|
|
|
['federationId' => $fedIDs[1]],
|
|
|
|
['federationId' => $fedIDs[2]],
|
2018-10-12 17:11:48 +03:00
|
|
|
],
|
|
|
|
'expectedResult' => [
|
|
|
|
[
|
|
|
|
'label' => $fedIDs[0],
|
|
|
|
'value' => [
|
2020-06-24 17:49:16 +03:00
|
|
|
'shareType' => IShare::TYPE_REMOTE,
|
2018-10-12 17:11:48 +03:00
|
|
|
'shareWith' => $fedIDs[0]
|
|
|
|
],
|
|
|
|
'extra' => ['federationId' => $fedIDs[0]],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'label' => $fedIDs[1],
|
|
|
|
'value' => [
|
2020-06-24 17:49:16 +03:00
|
|
|
'shareType' => IShare::TYPE_REMOTE,
|
2018-10-12 17:11:48 +03:00
|
|
|
'shareWith' => $fedIDs[1]
|
|
|
|
],
|
|
|
|
'extra' => ['federationId' => $fedIDs[1]],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'label' => $fedIDs[2],
|
|
|
|
'value' => [
|
2020-06-24 17:49:16 +03:00
|
|
|
'shareType' => IShare::TYPE_REMOTE,
|
2018-10-12 17:11:48 +03:00
|
|
|
'shareWith' => $fedIDs[2]
|
|
|
|
],
|
|
|
|
'extra' => ['federationId' => $fedIDs[2]],
|
|
|
|
],
|
|
|
|
]
|
|
|
|
],// GS , Lookup
|
|
|
|
false, false
|
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2017-09-15 00:41:04 +03:00
|
|
|
public function searchDataProvider() {
|
|
|
|
$fedIDs = [
|
|
|
|
'foo@enceladus.moon',
|
|
|
|
'foobar@enceladus.moon',
|
|
|
|
'foongus@enceladus.moon',
|
|
|
|
];
|
|
|
|
|
|
|
|
return [
|
|
|
|
// #0, standard search with results
|
|
|
|
[[
|
|
|
|
'search' => 'foo',
|
|
|
|
'limit' => 10,
|
|
|
|
'offset' => 0,
|
|
|
|
'server' => 'https://lookup.example.io',
|
|
|
|
'resultBody' => [
|
2018-10-17 14:09:11 +03:00
|
|
|
['federationId' => $fedIDs[0]],
|
|
|
|
['federationId' => $fedIDs[1]],
|
|
|
|
['federationId' => $fedIDs[2]],
|
2017-09-15 00:41:04 +03:00
|
|
|
],
|
|
|
|
'expectedResult' => [
|
|
|
|
[
|
|
|
|
'label' => $fedIDs[0],
|
|
|
|
'value' => [
|
2020-06-24 17:49:16 +03:00
|
|
|
'shareType' => IShare::TYPE_REMOTE,
|
2017-09-15 00:41:04 +03:00
|
|
|
'shareWith' => $fedIDs[0]
|
|
|
|
],
|
|
|
|
'extra' => ['federationId' => $fedIDs[0]],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'label' => $fedIDs[1],
|
|
|
|
'value' => [
|
2020-06-24 17:49:16 +03:00
|
|
|
'shareType' => IShare::TYPE_REMOTE,
|
2017-09-15 00:41:04 +03:00
|
|
|
'shareWith' => $fedIDs[1]
|
|
|
|
],
|
|
|
|
'extra' => ['federationId' => $fedIDs[1]],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'label' => $fedIDs[2],
|
|
|
|
'value' => [
|
2020-06-24 17:49:16 +03:00
|
|
|
'shareType' => IShare::TYPE_REMOTE,
|
2017-09-15 00:41:04 +03:00
|
|
|
'shareWith' => $fedIDs[2]
|
|
|
|
],
|
|
|
|
'extra' => ['federationId' => $fedIDs[2]],
|
|
|
|
],
|
|
|
|
]
|
|
|
|
]],
|
|
|
|
// #1, search without results
|
|
|
|
[[
|
|
|
|
'search' => 'foo',
|
|
|
|
'limit' => 10,
|
|
|
|
'offset' => 0,
|
|
|
|
'server' => 'https://lookup.example.io',
|
|
|
|
'resultBody' => [],
|
|
|
|
'expectedResult' => [],
|
|
|
|
]],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|