Merge pull request #19025 from nextcloud/backport/19017/stable18

[stable18] Increase the timeout for app downloads
This commit is contained in:
Roeland Jago Douma 2020-01-21 11:55:38 +01:00 committed by GitHub
commit 986ad0a497
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 13 deletions

View file

@ -271,7 +271,7 @@ class Installer {
// Download the release // Download the release
$tempFile = $this->tempManager->getTemporaryFile('.tar.gz'); $tempFile = $this->tempManager->getTemporaryFile('.tar.gz');
$client = $this->clientService->newClient(); $client = $this->clientService->newClient();
$client->get($app['releases'][0]['download'], ['save_to' => $tempFile]); $client->get($app['releases'][0]['download'], ['save_to' => $tempFile, 'timeout' => 120]);
// Check if the signature actually matches the downloaded content // Check if the signature actually matches the downloaded content
$certificate = openssl_get_publickey($app['certificate']); $certificate = openssl_get_publickey($app['certificate']);

View file

@ -159,7 +159,7 @@ class InstallerTest extends TestCase {
$this->assertSame($updateAvailable, $installer->isUpdateAvailable('files'), 'Cached result should be returned and fetcher should be only called once'); $this->assertSame($updateAvailable, $installer->isUpdateAvailable('files'), 'Cached result should be returned and fetcher should be only called once');
} }
public function testDownloadAppWithRevokedCertificate() { public function testDownloadAppWithRevokedCertificate() {
$this->expectException(\Exception::class); $this->expectException(\Exception::class);
$this->expectExceptionMessage('Certificate "4112" has been revoked'); $this->expectExceptionMessage('Certificate "4112" has been revoked');
@ -203,7 +203,7 @@ gLgK8d8sKL60JMmKHN3boHrsThKBVA==
$installer->downloadApp('news'); $installer->downloadApp('news');
} }
public function testDownloadAppWithNotNextcloudCertificate() { public function testDownloadAppWithNotNextcloudCertificate() {
$this->expectException(\Exception::class); $this->expectException(\Exception::class);
$this->expectExceptionMessage('App with id news has a certificate not issued by a trusted Code Signing Authority'); $this->expectExceptionMessage('App with id news has a certificate not issued by a trusted Code Signing Authority');
@ -246,7 +246,7 @@ YSu356M=
$installer->downloadApp('news'); $installer->downloadApp('news');
} }
public function testDownloadAppWithDifferentCN() { public function testDownloadAppWithDifferentCN() {
$this->expectException(\Exception::class); $this->expectException(\Exception::class);
$this->expectExceptionMessage('App with id news has a cert issued to passman'); $this->expectExceptionMessage('App with id news has a cert issued to passman');
@ -289,7 +289,7 @@ u/spPSSVhaun5BA1FlphB2TkgnzlCmxJa63nFY045e/Jq+IKMcqqZl/092gbI2EQ
$installer->downloadApp('news'); $installer->downloadApp('news');
} }
public function testDownloadAppWithInvalidSignature() { public function testDownloadAppWithInvalidSignature() {
$this->expectException(\Exception::class); $this->expectException(\Exception::class);
$this->expectExceptionMessage('App with id passman has invalid signature'); $this->expectExceptionMessage('App with id passman has invalid signature');
@ -347,7 +347,7 @@ u/spPSSVhaun5BA1FlphB2TkgnzlCmxJa63nFY045e/Jq+IKMcqqZl/092gbI2EQ
$client $client
->expects($this->once()) ->expects($this->once())
->method('get') ->method('get')
->with('https://example.com', ['save_to' => $realTmpFile]); ->with('https://example.com', ['save_to' => $realTmpFile, 'timeout' => 120]);
$this->clientService $this->clientService
->expects($this->once()) ->expects($this->once())
->method('newClient') ->method('newClient')
@ -357,7 +357,7 @@ u/spPSSVhaun5BA1FlphB2TkgnzlCmxJa63nFY045e/Jq+IKMcqqZl/092gbI2EQ
$installer->downloadApp('passman'); $installer->downloadApp('passman');
} }
public function testDownloadAppWithMoreThanOneFolderDownloaded() { public function testDownloadAppWithMoreThanOneFolderDownloaded() {
$this->expectException(\Exception::class); $this->expectException(\Exception::class);
$this->expectExceptionMessage('Extracted app testapp has more than 1 folder'); $this->expectExceptionMessage('Extracted app testapp has more than 1 folder');
@ -431,7 +431,7 @@ YwDVP+QmNRzx72jtqAN/Kc3CvQ9nkgYhU65B95aX0xA=',
$client $client
->expects($this->once()) ->expects($this->once())
->method('get') ->method('get')
->with('https://example.com', ['save_to' => $realTmpFile]); ->with('https://example.com', ['save_to' => $realTmpFile, 'timeout' => 120]);
$this->clientService $this->clientService
->expects($this->once()) ->expects($this->once())
->method('newClient') ->method('newClient')
@ -441,7 +441,7 @@ YwDVP+QmNRzx72jtqAN/Kc3CvQ9nkgYhU65B95aX0xA=',
$installer->downloadApp('testapp'); $installer->downloadApp('testapp');
} }
public function testDownloadAppWithMismatchingIdentifier() { public function testDownloadAppWithMismatchingIdentifier() {
$this->expectException(\Exception::class); $this->expectException(\Exception::class);
$this->expectExceptionMessage('App for id testapp has a wrong app ID in info.xml: testapp1'); $this->expectExceptionMessage('App for id testapp has a wrong app ID in info.xml: testapp1');
@ -514,7 +514,7 @@ YwDVP+QmNRzx72jtqAN/Kc3CvQ9nkgYhU65B95aX0xA=',
$client $client
->expects($this->once()) ->expects($this->once())
->method('get') ->method('get')
->with('https://example.com', ['save_to' => $realTmpFile]); ->with('https://example.com', ['save_to' => $realTmpFile, 'timeout' => 120]);
$this->clientService $this->clientService
->expects($this->once()) ->expects($this->once())
->method('newClient') ->method('newClient')
@ -593,7 +593,7 @@ MPLX6f5V9tCJtlH6ztmEcDROfvuVc0U3rEhqx2hphoyo+MZrPFpdcJL8KkIdMKbY
$client $client
->expects($this->once()) ->expects($this->once())
->method('get') ->method('get')
->with('https://example.com', ['save_to' => $realTmpFile]); ->with('https://example.com', ['save_to' => $realTmpFile, 'timeout' => 120]);
$this->clientService $this->clientService
->expects($this->at(0)) ->expects($this->at(0))
->method('newClient') ->method('newClient')
@ -606,7 +606,7 @@ MPLX6f5V9tCJtlH6ztmEcDROfvuVc0U3rEhqx2hphoyo+MZrPFpdcJL8KkIdMKbY
$this->assertEquals('0.9', \OC_App::getAppVersionByPath(__DIR__ . '/../../apps/testapp/')); $this->assertEquals('0.9', \OC_App::getAppVersionByPath(__DIR__ . '/../../apps/testapp/'));
} }
public function testDownloadAppWithDowngrade() { public function testDownloadAppWithDowngrade() {
$this->expectException(\Exception::class); $this->expectException(\Exception::class);
$this->expectExceptionMessage('App for id testapp has version 0.9 and tried to update to lower version 0.8'); $this->expectExceptionMessage('App for id testapp has version 0.9 and tried to update to lower version 0.8');
@ -679,7 +679,7 @@ JXhrdaWDZ8fzpUjugrtC3qslsqL0dzgU37anS3HwrT8=',
$client $client
->expects($this->once()) ->expects($this->once())
->method('get') ->method('get')
->with('https://example.com', ['save_to' => $realTmpFile]); ->with('https://example.com', ['save_to' => $realTmpFile, 'timeout' => 120]);
$this->clientService $this->clientService
->expects($this->at(1)) ->expects($this->at(1))
->method('newClient') ->method('newClient')