aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Config/UserConfigTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/Config/UserConfigTest.php')
-rw-r--r--tests/lib/Config/UserConfigTest.php60
1 files changed, 37 insertions, 23 deletions
diff --git a/tests/lib/Config/UserConfigTest.php b/tests/lib/Config/UserConfigTest.php
index 7bd1e06e297..09d19964249 100644
--- a/tests/lib/Config/UserConfigTest.php
+++ b/tests/lib/Config/UserConfigTest.php
@@ -15,6 +15,7 @@ use OC\Config\UserConfig;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Security\ICrypto;
+use OCP\Server;
use Psr\Log\LoggerInterface;
use Test\TestCase;
@@ -35,10 +36,10 @@ class UserConfigTest extends TestCase {
/**
* @var array<string, array<string, array<array<string, string, int, bool, bool>>> [userId => [appId => prefKey, prefValue, valueType, lazy, sensitive]]]
*/
- private array $basePreferences =
- [
- 'user1' =>
- [
+ private array $basePreferences
+ = [
+ 'user1'
+ => [
'app1' => [
'key1' => ['key1', 'value1'],
'key22' => ['key22', '31'],
@@ -97,8 +98,8 @@ class UserConfigTest extends TestCase {
'key5' => ['key5', true, ValueType::BOOL, true],
]
],
- 'user2' =>
- [
+ 'user2'
+ => [
'app1' => [
'1' => ['1', 'value1'],
'2' => ['2', 'value2', ValueType::STRING, true, UserConfig::FLAG_SENSITIVE],
@@ -120,8 +121,8 @@ class UserConfigTest extends TestCase {
'key1' => ['key1', 'value1', ValueType::STRING, true, 0, true]
]
],
- 'user3' =>
- [
+ 'user3'
+ => [
'app2' => [
'key2' => ['key2', 'value2c', ValueType::MIXED, false, 0, true],
'key3' => ['key3', 'value3', ValueType::STRING, true, ],
@@ -137,8 +138,8 @@ class UserConfigTest extends TestCase {
'key3' => ['key3', 'value3', ValueType::STRING, true]
]
],
- 'user4' =>
- [
+ 'user4'
+ => [
'app2' => [
'key1' => ['key1', 'value1'],
'key2' => ['key2', 'value2A', ValueType::MIXED, false, 0, true],
@@ -152,8 +153,8 @@ class UserConfigTest extends TestCase {
'key1' => ['key1', 123, ValueType::INT, true, 0, true]
]
],
- 'user5' =>
- [
+ 'user5'
+ => [
'app1' => [
'key1' => ['key1', 'value1']
],
@@ -170,10 +171,10 @@ class UserConfigTest extends TestCase {
protected function setUp(): void {
parent::setUp();
- $this->connection = \OCP\Server::get(IDBConnection::class);
- $this->config = \OCP\Server::get(IConfig::class);
- $this->logger = \OCP\Server::get(LoggerInterface::class);
- $this->crypto = \OCP\Server::get(ICrypto::class);
+ $this->connection = Server::get(IDBConnection::class);
+ $this->config = Server::get(IConfig::class);
+ $this->logger = Server::get(LoggerInterface::class);
+ $this->crypto = Server::get(ICrypto::class);
// storing current preferences and emptying the data table
$sql = $this->connection->getQueryBuilder();
@@ -278,7 +279,7 @@ class UserConfigTest extends TestCase {
* @return IUserConfig
*/
private function generateUserConfig(array $preLoading = []): IUserConfig {
- $userConfig = new \OC\Config\UserConfig(
+ $userConfig = new UserConfig(
$this->connection,
$this->config,
$this->logger,
@@ -1240,6 +1241,19 @@ class UserConfigTest extends TestCase {
}
}
+ /**
+ * This test needs to stay! Emails are expected to be lowercase due to performance reasons.
+ * This way we can skip the expensive casing change on the database.
+ */
+ public function testSetValueMixedWithSettingsEmail(): void {
+ $userConfig = $this->generateUserConfig();
+
+ $edited = $userConfig->setValueMixed('user1', 'settings', 'email', 'mixed.CASE@Nextcloud.com');
+ $this->assertTrue($edited);
+
+ $actual = $userConfig->getValueMixed('user1', 'settings', 'email');
+ $this->assertEquals('mixed.case@nextcloud.com', $actual);
+ }
public static function providerSetValueString(): array {
return [
@@ -1549,8 +1563,8 @@ class UserConfigTest extends TestCase {
$this->assertEquals($sensitive, $userConfig->isSensitive($userId, $app, $key));
if ($sensitive) {
$this->assertEquals(true, str_starts_with(
- $userConfig->statusCache()['fastCache'][$userId][$app][$key] ??
- $userConfig->statusCache()['lazyCache'][$userId][$app][$key],
+ $userConfig->statusCache()['fastCache'][$userId][$app][$key]
+ ?? $userConfig->statusCache()['lazyCache'][$userId][$app][$key],
'$UserConfigEncryption$')
);
}
@@ -1580,8 +1594,8 @@ class UserConfigTest extends TestCase {
$userConfig->getValueString($userId, $app, $key); // cache loading for userId
$this->assertEquals(
!$sensitive, str_starts_with(
- $userConfig->statusCache()['fastCache'][$userId][$app][$key] ??
- $userConfig->statusCache()['lazyCache'][$userId][$app][$key],
+ $userConfig->statusCache()['fastCache'][$userId][$app][$key]
+ ?? $userConfig->statusCache()['lazyCache'][$userId][$app][$key],
'$UserConfigEncryption$'
)
);
@@ -1594,8 +1608,8 @@ class UserConfigTest extends TestCase {
$this->assertEquals($sensitive, $userConfig->isSensitive($userId, $app, $key));
// should only work if updateGlobalSensitive drop cache
$this->assertEquals($sensitive, str_starts_with(
- $userConfig->statusCache()['fastCache'][$userId][$app][$key] ??
- $userConfig->statusCache()['lazyCache'][$userId][$app][$key],
+ $userConfig->statusCache()['fastCache'][$userId][$app][$key]
+ ?? $userConfig->statusCache()['lazyCache'][$userId][$app][$key],
'$UserConfigEncryption$')
);
}