示例#1
0
    public function testGetApplicationDownloadUrlSuccessful()
    {
        $this->config->expects($this->at(0))->method('getSystemValue')->with('appstoreenabled', true)->will($this->returnValue(true));
        $this->config->expects($this->at(1))->method('getSystemValue')->with('appstoreurl', 'https://api.owncloud.com/v1')->will($this->returnValue('https://api.owncloud.com/v1'));
        $response = $this->getMock('\\OCP\\Http\\Client\\IResponse');
        $response->expects($this->once())->method('getBody')->will($this->returnValue('<?xml version="1.0"?>
				<ocs>
				 <meta>
				  <status>ok</status>
				  <statuscode>100</statuscode>
				  <message></message>
				 </meta>
				 <data>
				  <content details="download">
				   <downloadlink>https://apps.owncloud.com/CONTENT/content-files/166052-files_trashbin.zip</downloadlink>
				   <mimetype>application/zip</mimetype>
				   <gpgfingerprint></gpgfingerprint>
				   <gpgsignature></gpgsignature>
				   <packagename></packagename>
				   <repository></repository>
				  </content>
				 </data>
				</ocs>
				'));
        $client = $this->getMock('\\OCP\\Http\\Client\\IClient');
        $client->expects($this->once())->method('get')->with('https://api.owncloud.com/v1/content/download/MyId/1', ['timeout' => 5, 'query' => ['version' => '8x1x0x7']])->will($this->returnValue($response));
        $this->clientService->expects($this->once())->method('newClient')->will($this->returnValue($client));
        $expected = ['downloadlink' => 'https://apps.owncloud.com/CONTENT/content-files/166052-files_trashbin.zip'];
        $this->assertSame($expected, $this->ocsClient->getApplicationDownload('MyId', [8, 1, 0, 7]));
    }
示例#2
0
 /**
  * update an app by it's id
  *
  * @param integer $ocsId
  * @return bool
  * @throws Exception
  */
 public static function updateAppByOCSId($ocsId)
 {
     $ocsClient = new OCSClient(\OC::$server->getHTTPClientService(), \OC::$server->getConfig(), \OC::$server->getLogger());
     $appData = $ocsClient->getApplication($ocsId, \OCP\Util::getVersion());
     $download = $ocsClient->getApplicationDownload($ocsId, \OCP\Util::getVersion());
     if (isset($download['downloadlink']) && trim($download['downloadlink']) !== '') {
         $download['downloadlink'] = str_replace(' ', '%20', $download['downloadlink']);
         $info = array('source' => 'http', 'href' => $download['downloadlink'], 'appdata' => $appData);
     } else {
         throw new \Exception('Could not fetch app info!');
     }
     return self::updateApp($info);
 }
示例#3
0
文件: app.php 项目: pierreozoux/core
 /**
  * @param string $app
  * @return int
  */
 private static function downloadApp($app)
 {
     $ocsClient = new OCSClient(\OC::$server->getHTTPClientService(), \OC::$server->getConfig(), \OC::$server->getLogger());
     $appData = $ocsClient->getApplication($app, \OCP\Util::getVersion());
     $download = $ocsClient->getApplicationDownload($app, \OCP\Util::getVersion());
     if (isset($download['downloadlink']) and $download['downloadlink'] != '') {
         // Replace spaces in download link without encoding entire URL
         $download['downloadlink'] = str_replace(' ', '%20', $download['downloadlink']);
         $info = array('source' => 'http', 'href' => $download['downloadlink'], 'appdata' => $appData);
         $app = OC_Installer::installApp($info);
     }
     return $app;
 }