summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-04-10 17:06:22 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-04-10 17:06:27 +0200
commitdb545b430a513e7fda3fba5859972b6c550958b5 (patch)
tree581622a85ab84b214c7c75c4996d2321e2d92571
parent47954580d994611883167bfb6cb4bb18837bbb1c (diff)
add proxy settings to config
-rw-r--r--tests/unit/utility/ConfigTest.php16
-rw-r--r--utility/config.php35
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);