From 836dfebf723afc264868da69021c89221d02aa18 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Thu, 10 Apr 2014 19:38:52 +0200 Subject: build http basic auth rather than requiring it from the user to write the correct auth string into the config --- tests/unit/utility/ConfigTest.php | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'tests/unit/utility/ConfigTest.php') 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 -- cgit v1.2.3