From db545b430a513e7fda3fba5859972b6c550958b5 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Thu, 10 Apr 2014 17:06:22 +0200 Subject: add proxy settings to config --- tests/unit/utility/ConfigTest.php | 16 ++++++++++++++-- utility/config.php | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/tests/unit/utility/ConfigTest.php b/tests/unit/utility/ConfigTest.php index 8ef688844..d3f91b975 100644 --- a/tests/unit/utility/ConfigTest.php +++ b/tests/unit/utility/ConfigTest.php @@ -55,6 +55,9 @@ class ConfigFetcherTest extends \OCA\News\Utility\TestUtility { $this->assertEquals(30*60, $this->config->getSimplePieCacheDuration()); $this->assertEquals(60, $this->config->getFeedFetcherTimeout()); $this->assertEquals(true, $this->config->getUseCronUpdates()); + $this->assertEquals(8080, $this->config->getProxyPort()); + $this->assertEquals('', $this->config->getProxyHost()); + $this->assertEquals('', $this->config->getProxyPassword()); } @@ -118,8 +121,14 @@ class ConfigFetcherTest extends \OCA\News\Utility\TestUtility { "autoPurgeCount = 3\n" . "simplePieCacheDuration = 1800\n" . "feedFetcherTimeout = 60\n" . - "useCronUpdates = true"; + "useCronUpdates = true\n" . + "proxyHost = yo man\n" . + "proxyPort = 12\n" . + "proxyPassword = this is a test"; $this->config->setAutoPurgeCount(3); + $this->config->setProxyHost("yo man"); + $this->config->setProxyPort(12); + $this->config->setProxyPassword("this is a test"); $this->fileSystem->expects($this->once()) ->method('file_put_contents') @@ -142,7 +151,10 @@ class ConfigFetcherTest extends \OCA\News\Utility\TestUtility { "autoPurgeCount = 200\n" . "simplePieCacheDuration = 1800\n" . "feedFetcherTimeout = 60\n" . - "useCronUpdates = false"; + "useCronUpdates = false\n" . + "proxyHost = \n" . + "proxyPort = 8080\n" . + "proxyPassword = "; $this->fileSystem->expects($this->once()) ->method('file_put_contents') diff --git a/utility/config.php b/utility/config.php index 193411592..92d0b9daf 100644 --- a/utility/config.php +++ b/utility/config.php @@ -39,6 +39,9 @@ class Config { private $simplePieCacheDuration; // seconds private $feedFetcherTimeout; // seconds private $useCronUpdates; // turn off updates run by owncloud cronjob + private $proxyHost; + private $proxyPort; + private $proxyPassword; private $api; @@ -50,8 +53,22 @@ class Config { $this->feedFetcherTimeout = 60; $this->useCronUpdates = true; $this->api = $api; + $this->proxyHost = ''; + $this->proxyPort = 8080; + $this->proxyPassword = ''; } + public function getProxyPort() { + return $this->proxyPort; + } + + public function getProxyHost() { + return $this->proxyHost; + } + + public function getProxyPassword() { + return $this->proxyPassword; + } public function getAutoPurgeMinimumInterval() { return $this->autoPurgeMinimumInterval; @@ -103,6 +120,19 @@ class Config { } + public function setProxyPort($value) { + $this->proxyPort = $value; + } + + public function setProxyHost($value) { + $this->proxyHost = $value; + } + + public function setProxyPassword($value) { + $this->proxyPassword = $value; + } + + public function read($configPath, $createIfNotExists=false) { if($createIfNotExists && !$this->fileSystem->file_exists($configPath)) { @@ -139,7 +169,10 @@ class Config { "autoPurgeCount = " . $this->autoPurgeCount . "\n" . "simplePieCacheDuration = " . $this->simplePieCacheDuration . "\n" . "feedFetcherTimeout = " . $this->feedFetcherTimeout . "\n" . - "useCronUpdates = " . var_export($this->useCronUpdates, true) + "useCronUpdates = " . var_export($this->useCronUpdates, true) . "\n" . + "proxyHost = " . $this->proxyHost . "\n" . + "proxyPort = " . $this->proxyPort . "\n" . + "proxyPassword = " . $this->proxyPassword; ; $this->fileSystem->file_put_contents($configPath, $ini); -- cgit v1.2.3