diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-04-10 19:38:52 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-04-10 19:38:52 +0200 |
commit | 836dfebf723afc264868da69021c89221d02aa18 (patch) | |
tree | ae5274151345a13f65488bb6562fe1db0da41244 /tests | |
parent | 5befce51ef9f38609b713cfbc6095a3b60b1d574 (diff) |
build http basic auth rather than requiring it from the user to write the correct auth string into the config
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/utility/ConfigTest.php | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/tests/unit/utility/ConfigTest.php b/tests/unit/utility/ConfigTest.php index 9cea0acf0..a2b871c76 100644 --- a/tests/unit/utility/ConfigTest.php +++ b/tests/unit/utility/ConfigTest.php @@ -57,7 +57,9 @@ class ConfigFetcherTest extends \OCA\News\Utility\TestUtility { $this->assertEquals(true, $this->config->getUseCronUpdates()); $this->assertEquals(8080, $this->config->getProxyPort()); $this->assertEquals('', $this->config->getProxyHost()); - $this->assertEquals('', $this->config->getProxyAuth()); + $this->assertEquals(null, $this->config->getProxyAuth()); + $this->assertEquals('', $this->config->getProxyUser()); + $this->assertEquals('', $this->config->getProxyPassword()); } @@ -124,11 +126,13 @@ class ConfigFetcherTest extends \OCA\News\Utility\TestUtility { "useCronUpdates = true\n" . "proxyHost = yo man\n" . "proxyPort = 12\n" . - "proxyAuth = this is a test"; + "proxyUser = this is a test\n". + "proxyPassword = se"; $this->config->setAutoPurgeCount(3); $this->config->setProxyHost("yo man"); $this->config->setProxyPort(12); - $this->config->setProxyAuth("this is a test"); + $this->config->setProxyUser("this is a test"); + $this->config->setProxyPassword("se"); $this->fileSystem->expects($this->once()) ->method('file_put_contents') @@ -139,6 +143,11 @@ class ConfigFetcherTest extends \OCA\News\Utility\TestUtility { } + public function testNoProxyAuthReturnsNull() { + $this->assertNull($this->config->getProxyAuth()); + } + + public function testReadingNonExistentConfigWillWriteDefaults() { $this->fileSystem->expects($this->once()) ->method('file_exists') @@ -154,7 +163,8 @@ class ConfigFetcherTest extends \OCA\News\Utility\TestUtility { "useCronUpdates = false\n" . "proxyHost = \n" . "proxyPort = 8080\n" . - "proxyAuth = "; + "proxyUser = \n" . + "proxyPassword = "; $this->fileSystem->expects($this->once()) ->method('file_put_contents') @@ -164,4 +174,11 @@ class ConfigFetcherTest extends \OCA\News\Utility\TestUtility { $this->config->read($this->configPath, true); } + + public function testEncodesUserAndPasswordInHTTPBasicAuth() { + $this->config->setProxyUser("this is a test"); + $this->config->setProxyPassword("se"); + + $this->assertEquals('this is a test:se', $this->config->getProxyAuth()); + } }
\ No newline at end of file |