Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions lib/private/App/AppStore/Fetcher/AppFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public function __construct(Factory $appDataFactory,
);

$this->fileName = 'apps.json';
$this->setEndpoint();
$this->compareVersion = $compareVersion;
$this->ignoreMaxVersion = true;
}
Expand Down Expand Up @@ -141,10 +140,6 @@ protected function fetch($ETag, $content) {
return $response;
}

private function setEndpoint() {
$this->endpointUrl = 'https://apps.nextcloud.com/api/v1/apps.json';
}

/**
* @param string $version
* @param string $fileName
Expand Down
1 change: 0 additions & 1 deletion lib/private/App/AppStore/Fetcher/CategoryFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,5 @@ public function __construct(Factory $appDataFactory,
$logger
);
$this->fileName = 'categories.json';
$this->endpointUrl = 'https://apps.nextcloud.com/api/v1/categories.json';
}
}
8 changes: 5 additions & 3 deletions lib/private/App/AppStore/Fetcher/Fetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ abstract class Fetcher {
/** @var string */
protected $fileName;
/** @var string */
protected $endpointUrl;
/** @var string */
protected $version;
/** @var string */
protected $channel;
Expand Down Expand Up @@ -105,7 +103,7 @@ protected function fetch($ETag, $content) {
}

$client = $this->clientService->newClient();
$response = $client->get($this->endpointUrl, $options);
$response = $client->get($this->getEndpoint(), $options);

$responseJson = [];
if ($response->getStatusCode() === Http::STATUS_NOT_MODIFIED) {
Expand Down Expand Up @@ -218,4 +216,8 @@ protected function getChannel() {
public function setChannel(string $channel) {
$this->channel = $channel;
}

protected function getEndpoint(): string {
return $this->config->getSystemValue('appstoreurl', 'https://apps.nextcloud.com/api/v1') . '/' . $this->fileName;
}
}
4 changes: 3 additions & 1 deletion tests/lib/App/AppStore/Fetcher/AppFetcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ public function testGetWithFilter() {
return true;
} else if ($key === 'version') {
return '11.0.0.2';
} else if ($key === 'appstoreurl' && $default === 'https://apps.nextcloud.com/api/v1') {
return 'https://custom.appsstore.endpoint/api/v1';
} else {
return $default;
}
Expand Down Expand Up @@ -122,7 +124,7 @@ public function testGetWithFilter() {
$response = $this->createMock(IResponse::class);
$client
->method('get')
->with('https://apps.nextcloud.com/api/v1/apps.json')
->with('https://custom.appsstore.endpoint/api/v1/apps.json')
->willReturn($response);
$response
->expects($this->once())
Expand Down
15 changes: 15 additions & 0 deletions tests/lib/App/AppStore/Fetcher/FetcherBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ public function testGetWithNotExistingFileAndUpToDateTimestampAndVersion() {
$this->config
->expects($this->at(3))
->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(
$this->equalTo('version'),
$this->anything()
Expand Down Expand Up @@ -298,6 +303,11 @@ public function testGetWithAlreadyExistingFileAndNoVersion() {
$this->config
->expects($this->at(3))
->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(
$this->equalTo('version'),
$this->anything()
Expand Down Expand Up @@ -382,6 +392,11 @@ public function testGetWithAlreadyExistingFileAndOutdatedVersion() {
$this->config
->expects($this->at(3))
->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(
$this->equalTo('version'),
$this->anything()
Expand Down