|
|
|
@ -234,15 +234,12 @@ class CheckSetupControllerTest extends TestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testIsInternetConnectionWorkingCorrectly() { |
|
|
|
|
$this->config->expects($this->at(0)) |
|
|
|
|
$this->config->expects($this->exactly(2)) |
|
|
|
|
->method('getSystemValue') |
|
|
|
|
->with('has_internet_connection', true) |
|
|
|
|
->willReturn(true); |
|
|
|
|
|
|
|
|
|
$this->config->expects($this->at(1)) |
|
|
|
|
->method('getSystemValue') |
|
|
|
|
->with('connectivity_check_domains', ['www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org']) |
|
|
|
|
->willReturn(['www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org']); |
|
|
|
|
->withConsecutive( |
|
|
|
|
['has_internet_connection', true], |
|
|
|
|
['connectivity_check_domains', ['www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org']], |
|
|
|
|
)->willReturnArgument(1); |
|
|
|
|
|
|
|
|
|
$client = $this->getMockBuilder('\OCP\Http\Client\IClient') |
|
|
|
|
->disableOriginalConstructor()->getMock(); |
|
|
|
@ -263,15 +260,12 @@ class CheckSetupControllerTest extends TestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testIsInternetConnectionFail() { |
|
|
|
|
$this->config->expects($this->at(0)) |
|
|
|
|
->method('getSystemValue') |
|
|
|
|
->with('has_internet_connection', true) |
|
|
|
|
->willReturn(true); |
|
|
|
|
|
|
|
|
|
$this->config->expects($this->at(1)) |
|
|
|
|
$this->config->expects($this->exactly(2)) |
|
|
|
|
->method('getSystemValue') |
|
|
|
|
->with('connectivity_check_domains', ['www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org']) |
|
|
|
|
->willReturn(['www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org']); |
|
|
|
|
->withConsecutive( |
|
|
|
|
['has_internet_connection', true], |
|
|
|
|
['connectivity_check_domains', ['www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org']], |
|
|
|
|
)->willReturnArgument(1); |
|
|
|
|
|
|
|
|
|
$client = $this->getMockBuilder('\OCP\Http\Client\IClient') |
|
|
|
|
->disableOriginalConstructor()->getMock(); |
|
|
|
@ -432,30 +426,20 @@ class CheckSetupControllerTest extends TestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testCheck() { |
|
|
|
|
$this->config->expects($this->at(0)) |
|
|
|
|
->method('getAppValue') |
|
|
|
|
->with('files_external', 'user_certificate_scan', false) |
|
|
|
|
->willReturn('["a", "b"]'); |
|
|
|
|
$this->config->expects($this->at(1)) |
|
|
|
|
$this->config->expects($this->any()) |
|
|
|
|
->method('getAppValue') |
|
|
|
|
->with('core', 'cronErrors') |
|
|
|
|
->willReturn(''); |
|
|
|
|
$this->config->expects($this->at(3)) |
|
|
|
|
->method('getSystemValue') |
|
|
|
|
->with('connectivity_check_domains', ['www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org']) |
|
|
|
|
->willReturn(['www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org']); |
|
|
|
|
$this->config->expects($this->at(4)) |
|
|
|
|
->method('getSystemValue') |
|
|
|
|
->with('memcache.local', null) |
|
|
|
|
->willReturn('SomeProvider'); |
|
|
|
|
$this->config->expects($this->at(5)) |
|
|
|
|
->method('getSystemValue') |
|
|
|
|
->with('has_internet_connection', true) |
|
|
|
|
->willReturn(true); |
|
|
|
|
$this->config->expects($this->at(6)) |
|
|
|
|
->willReturnMap([ |
|
|
|
|
['files_external', 'user_certificate_scan', '', '["a", "b"]'], |
|
|
|
|
['core', 'cronErrors', ''], |
|
|
|
|
]); |
|
|
|
|
$this->config->expects($this->any()) |
|
|
|
|
->method('getSystemValue') |
|
|
|
|
->with('appstoreenabled', true) |
|
|
|
|
->willReturn(false); |
|
|
|
|
->willReturnMap([ |
|
|
|
|
['connectivity_check_domains', ['www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org'], ['www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org']], |
|
|
|
|
['memcache.local', null, 'SomeProvider'], |
|
|
|
|
['has_internet_connection', true, true], |
|
|
|
|
['appstoreenabled', true, false], |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
$this->request->expects($this->atLeastOnce()) |
|
|
|
|
->method('getHeader') |
|
|
|
@ -466,22 +450,14 @@ class CheckSetupControllerTest extends TestCase { |
|
|
|
|
|
|
|
|
|
$client = $this->getMockBuilder('\OCP\Http\Client\IClient') |
|
|
|
|
->disableOriginalConstructor()->getMock(); |
|
|
|
|
$client->expects($this->at(0)) |
|
|
|
|
$client->expects($this->exactly(4)) |
|
|
|
|
->method('get') |
|
|
|
|
->with('http://www.nextcloud.com/', []) |
|
|
|
|
->will($this->throwException(new \Exception())); |
|
|
|
|
$client->expects($this->at(1)) |
|
|
|
|
->method('get') |
|
|
|
|
->with('http://www.startpage.com/', []) |
|
|
|
|
->will($this->throwException(new \Exception())); |
|
|
|
|
$client->expects($this->at(2)) |
|
|
|
|
->method('get') |
|
|
|
|
->with('http://www.eff.org/', []) |
|
|
|
|
->will($this->throwException(new \Exception())); |
|
|
|
|
$client->expects($this->at(3)) |
|
|
|
|
->method('get') |
|
|
|
|
->with('http://www.edri.org/', []) |
|
|
|
|
->will($this->throwException(new \Exception())); |
|
|
|
|
->withConsecutive( |
|
|
|
|
['http://www.nextcloud.com/', []], |
|
|
|
|
['http://www.startpage.com/', []], |
|
|
|
|
['http://www.eff.org/', []], |
|
|
|
|
['http://www.edri.org/', []] |
|
|
|
|
)->will($this->throwException(new \Exception())); |
|
|
|
|
$this->clientService->expects($this->exactly(4)) |
|
|
|
|
->method('newClient') |
|
|
|
|
->willReturn($client); |
|
|
|
@ -740,10 +716,12 @@ class CheckSetupControllerTest extends TestCase { |
|
|
|
|
|
|
|
|
|
public function testIsUsedTlsLibOutdatedWithOlderOpenSslAndWithoutAppstore() { |
|
|
|
|
$this->config |
|
|
|
|
->expects($this->at(0)) |
|
|
|
|
->expects($this->any()) |
|
|
|
|
->method('getSystemValue') |
|
|
|
|
->with('has_internet_connection', true) |
|
|
|
|
->willReturn(true); |
|
|
|
|
->willReturnMap([ |
|
|
|
|
['has_internet_connection', true, true], |
|
|
|
|
['appstoreenabled', true, false], |
|
|
|
|
]); |
|
|
|
|
$this->checkSetupController |
|
|
|
|
->expects($this->once()) |
|
|
|
|
->method('getCurlVersion') |
|
|
|
@ -855,7 +833,7 @@ class CheckSetupControllerTest extends TestCase { |
|
|
|
|
->method('getResponse') |
|
|
|
|
->willReturn($response); |
|
|
|
|
|
|
|
|
|
$client->expects($this->at(0)) |
|
|
|
|
$client->expects($this->once()) |
|
|
|
|
->method('get') |
|
|
|
|
->with('https://nextcloud.com/', []) |
|
|
|
|
->will($this->throwException($exception)); |
|
|
|
@ -889,7 +867,7 @@ class CheckSetupControllerTest extends TestCase { |
|
|
|
|
->method('getResponse') |
|
|
|
|
->willReturn($response); |
|
|
|
|
|
|
|
|
|
$client->expects($this->at(0)) |
|
|
|
|
$client->expects($this->once()) |
|
|
|
|
->method('get') |
|
|
|
|
->with('https://nextcloud.com/', []) |
|
|
|
|
->will($this->throwException($exception)); |
|
|
|
@ -903,7 +881,7 @@ class CheckSetupControllerTest extends TestCase { |
|
|
|
|
|
|
|
|
|
public function testIsUsedTlsLibOutdatedWithInternetDisabled() { |
|
|
|
|
$this->config |
|
|
|
|
->expects($this->at(0)) |
|
|
|
|
->expects($this->once()) |
|
|
|
|
->method('getSystemValue') |
|
|
|
|
->with('has_internet_connection', true) |
|
|
|
|
->willReturn(false); |
|
|
|
@ -912,25 +890,19 @@ class CheckSetupControllerTest extends TestCase { |
|
|
|
|
|
|
|
|
|
public function testIsUsedTlsLibOutdatedWithAppstoreDisabledAndServerToServerSharingEnabled() { |
|
|
|
|
$this->config |
|
|
|
|
->expects($this->at(0)) |
|
|
|
|
->method('getSystemValue') |
|
|
|
|
->with('has_internet_connection', true) |
|
|
|
|
->willReturn(true); |
|
|
|
|
$this->config |
|
|
|
|
->expects($this->at(1)) |
|
|
|
|
->expects($this->exactly(2)) |
|
|
|
|
->method('getSystemValue') |
|
|
|
|
->with('appstoreenabled', true) |
|
|
|
|
->willReturn(false); |
|
|
|
|
$this->config |
|
|
|
|
->expects($this->at(2)) |
|
|
|
|
->method('getAppValue') |
|
|
|
|
->with('files_sharing', 'outgoing_server2server_share_enabled', 'yes') |
|
|
|
|
->willReturn('no'); |
|
|
|
|
->willReturnMap([ |
|
|
|
|
['has_internet_connection', true, true], |
|
|
|
|
['appstoreenabled', true, false], |
|
|
|
|
]); |
|
|
|
|
$this->config |
|
|
|
|
->expects($this->at(3)) |
|
|
|
|
->expects($this->exactly(2)) |
|
|
|
|
->method('getAppValue') |
|
|
|
|
->with('files_sharing', 'incoming_server2server_share_enabled', 'yes') |
|
|
|
|
->willReturn('yes'); |
|
|
|
|
->willReturnMap([ |
|
|
|
|
['files_sharing', 'outgoing_server2server_share_enabled', 'yes', 'no'], |
|
|
|
|
['files_sharing', 'incoming_server2server_share_enabled', 'yes', 'yes'], |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
$this->checkSetupController |
|
|
|
|
->expects($this->once()) |
|
|
|
@ -941,25 +913,19 @@ class CheckSetupControllerTest extends TestCase { |
|
|
|
|
|
|
|
|
|
public function testIsUsedTlsLibOutdatedWithAppstoreDisabledAndServerToServerSharingDisabled() { |
|
|
|
|
$this->config |
|
|
|
|
->expects($this->at(0)) |
|
|
|
|
->method('getSystemValue') |
|
|
|
|
->with('has_internet_connection', true) |
|
|
|
|
->willReturn(true); |
|
|
|
|
$this->config |
|
|
|
|
->expects($this->at(1)) |
|
|
|
|
->expects($this->exactly(2)) |
|
|
|
|
->method('getSystemValue') |
|
|
|
|
->with('appstoreenabled', true) |
|
|
|
|
->willReturn(false); |
|
|
|
|
$this->config |
|
|
|
|
->expects($this->at(2)) |
|
|
|
|
->method('getAppValue') |
|
|
|
|
->with('files_sharing', 'outgoing_server2server_share_enabled', 'yes') |
|
|
|
|
->willReturn('no'); |
|
|
|
|
->willReturnMap([ |
|
|
|
|
['has_internet_connection', true, true], |
|
|
|
|
['appstoreenabled', true, false], |
|
|
|
|
]); |
|
|
|
|
$this->config |
|
|
|
|
->expects($this->at(3)) |
|
|
|
|
->expects($this->exactly(2)) |
|
|
|
|
->method('getAppValue') |
|
|
|
|
->with('files_sharing', 'incoming_server2server_share_enabled', 'yes') |
|
|
|
|
->willReturn('no'); |
|
|
|
|
->willReturnMap([ |
|
|
|
|
['files_sharing', 'outgoing_server2server_share_enabled', 'yes', 'no'], |
|
|
|
|
['files_sharing', 'incoming_server2server_share_enabled', 'yes', 'no'], |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
$this->checkSetupController |
|
|
|
|
->expects($this->never()) |
|
|
|
|