Merge pull request #18442 from nextcloud/bugfix/noid/broken_appstoreurl_config

Restore old behavior allowing to set custom appstore
This commit is contained in:
Roeland Jago Douma 2019-12-22 20:18:21 +01:00 committed by GitHub
commit e5d77822c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 10 deletions

View File

@ -68,7 +68,6 @@ class AppFetcher extends Fetcher {
); );
$this->fileName = 'apps.json'; $this->fileName = 'apps.json';
$this->setEndpoint();
$this->compareVersion = $compareVersion; $this->compareVersion = $compareVersion;
$this->ignoreMaxVersion = true; $this->ignoreMaxVersion = true;
} }
@ -143,10 +142,6 @@ class AppFetcher extends Fetcher {
return $response; return $response;
} }
private function setEndpoint() {
$this->endpointUrl = 'https://apps.nextcloud.com/api/v1/apps.json';
}
/** /**
* @param string $version * @param string $version
* @param string $fileName * @param string $fileName

View File

@ -53,6 +53,5 @@ class CategoryFetcher extends Fetcher {
$logger $logger
); );
$this->fileName = 'categories.json'; $this->fileName = 'categories.json';
$this->endpointUrl = 'https://apps.nextcloud.com/api/v1/categories.json';
} }
} }

View File

@ -55,8 +55,6 @@ abstract class Fetcher {
/** @var string */ /** @var string */
protected $fileName; protected $fileName;
/** @var string */ /** @var string */
protected $endpointUrl;
/** @var string */
protected $version; protected $version;
/** @var string */ /** @var string */
protected $channel; protected $channel;
@ -106,7 +104,7 @@ abstract class Fetcher {
} }
$client = $this->clientService->newClient(); $client = $this->clientService->newClient();
$response = $client->get($this->endpointUrl, $options); $response = $client->get($this->getEndpoint(), $options);
$responseJson = []; $responseJson = [];
if ($response->getStatusCode() === Http::STATUS_NOT_MODIFIED) { if ($response->getStatusCode() === Http::STATUS_NOT_MODIFIED) {
@ -219,4 +217,8 @@ abstract class Fetcher {
public function setChannel(string $channel) { public function setChannel(string $channel) {
$this->channel = $channel; $this->channel = $channel;
} }
protected function getEndpoint(): string {
return $this->config->getSystemValue('appstoreurl', 'https://apps.nextcloud.com/api/v1') . '/' . $this->fileName;
}
} }

View File

@ -92,6 +92,8 @@ EOD;
return true; return true;
} else if ($key === 'version') { } else if ($key === 'version') {
return '11.0.0.2'; return '11.0.0.2';
} else if ($key === 'appstoreurl' && $default === 'https://apps.nextcloud.com/api/v1') {
return 'https://custom.appsstore.endpoint/api/v1';
} else { } else {
return $default; return $default;
} }
@ -122,7 +124,7 @@ EOD;
$response = $this->createMock(IResponse::class); $response = $this->createMock(IResponse::class);
$client $client
->method('get') ->method('get')
->with('https://apps.nextcloud.com/api/v1/apps.json') ->with('https://custom.appsstore.endpoint/api/v1/apps.json')
->willReturn($response); ->willReturn($response);
$response $response
->expects($this->once()) ->expects($this->once())

View File

@ -137,6 +137,11 @@ abstract class FetcherBase extends TestCase {
$this->config $this->config
->expects($this->at(3)) ->expects($this->at(3))
->method('getSystemValue') ->method('getSystemValue')
->with('appstoreurl', 'https://apps.nextcloud.com/api/v1')
->willReturn('https://apps.nextcloud.com/api/v1');
$this->config
->expects($this->at(4))
->method('getSystemValue')
->with( ->with(
$this->equalTo('version'), $this->equalTo('version'),
$this->anything() $this->anything()
@ -298,6 +303,11 @@ abstract class FetcherBase extends TestCase {
$this->config $this->config
->expects($this->at(3)) ->expects($this->at(3))
->method('getSystemValue') ->method('getSystemValue')
->with('appstoreurl', 'https://apps.nextcloud.com/api/v1')
->willReturn('https://apps.nextcloud.com/api/v1');
$this->config
->expects($this->at(4))
->method('getSystemValue')
->with( ->with(
$this->equalTo('version'), $this->equalTo('version'),
$this->anything() $this->anything()
@ -382,6 +392,11 @@ abstract class FetcherBase extends TestCase {
$this->config $this->config
->expects($this->at(3)) ->expects($this->at(3))
->method('getSystemValue') ->method('getSystemValue')
->with('appstoreurl', 'https://apps.nextcloud.com/api/v1')
->willReturn('https://apps.nextcloud.com/api/v1');
$this->config
->expects($this->at(4))
->method('getSystemValue')
->with( ->with(
$this->equalTo('version'), $this->equalTo('version'),
$this->anything() $this->anything()