summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristoph Wurst <ChristophWurst@users.noreply.github.com>2017-01-17 11:01:42 +0100
committerGitHub <noreply@github.com>2017-01-17 11:01:42 +0100
commit012708e1badebe5dab6260c2e9edb521d5dbfee0 (patch)
treecc0e6a1abe9a38b03d1d922a832c78b50b3d87a2 /tests
parentb1a82969e66fb25d59cfef63d2a8744e374b2500 (diff)
parent5dc6899d1a3e11841b62971a52f0aa8e577c3065 (diff)
downloadnextcloud-server-012708e1badebe5dab6260c2e9edb521d5dbfee0.tar.gz
nextcloud-server-012708e1badebe5dab6260c2e9edb521d5dbfee0.zip
Merge pull request #3023 from nextcloud/issue-2915-filter-out-sensitive-appconfigs
Filter out sensitive appconfig values
Diffstat (limited to 'tests')
-rw-r--r--tests/Core/Command/Config/ListConfigsTest.php6
-rw-r--r--tests/lib/AppConfigTest.php23
2 files changed, 29 insertions, 0 deletions
diff --git a/tests/Core/Command/Config/ListConfigsTest.php b/tests/Core/Command/Config/ListConfigsTest.php
index 0f170cee840..861c1f59d5e 100644
--- a/tests/Core/Command/Config/ListConfigsTest.php
+++ b/tests/Core/Command/Config/ListConfigsTest.php
@@ -285,10 +285,16 @@ class ListConfigsTest extends TestCase {
$this->systemConfig->expects($this->any())
->method('getValue')
->willReturnMap($systemConfigMap);
+ $this->appConfig->expects($this->any())
+ ->method('getValues')
+ ->willReturnMap($appConfig);
} else {
$this->systemConfig->expects($this->any())
->method('getFilteredValue')
->willReturnMap($systemConfigMap);
+ $this->appConfig->expects($this->any())
+ ->method('getFilteredValues')
+ ->willReturnMap($appConfig);
}
$this->appConfig->expects($this->any())
diff --git a/tests/lib/AppConfigTest.php b/tests/lib/AppConfigTest.php
index c4da7507752..fed929352d3 100644
--- a/tests/lib/AppConfigTest.php
+++ b/tests/lib/AppConfigTest.php
@@ -8,6 +8,7 @@
*/
namespace Test;
+use OCP\IConfig;
/**
* Class AppConfigTest
@@ -305,6 +306,28 @@ class AppConfigTest extends TestCase {
$this->assertEquals($expected, $values);
}
+ public function testGetFilteredValues() {
+ /** @var \OC\AppConfig|\PHPUnit_Framework_MockObject_MockObject $config */
+ $config = $this->getMockBuilder(\OC\AppConfig::class)
+ ->setConstructorArgs([\OC::$server->getDatabaseConnection()])
+ ->setMethods(['getValues'])
+ ->getMock();
+
+ $config->expects($this->once())
+ ->method('getValues')
+ ->with('user_ldap', false)
+ ->willReturn([
+ 'ldap_agent_password' => 'secret',
+ 'ldap_dn' => 'dn',
+ ]);
+
+ $values = $config->getFilteredValues('user_ldap');
+ $this->assertEquals([
+ 'ldap_agent_password' => IConfig::SENSITIVE_VALUE,
+ 'ldap_dn' => 'dn',
+ ], $values);
+ }
+
public function testSettingConfigParallel() {
$appConfig1 = new \OC\AppConfig(\OC::$server->getDatabaseConnection());
$appConfig2 = new \OC\AppConfig(\OC::$server->getDatabaseConnection());