summaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2018-08-10 15:01:14 +0200
committerGitHub <noreply@github.com>2018-08-10 15:01:14 +0200
commit7aad5b7721bbecf673b1adb4f40a9b561bf6949e (patch)
tree4f1e48e73efc56bca65529b002cc1a86eeb5eab2 /apps/dav
parent674d5f292426007caca622e8a3279b4b099087aa (diff)
parentc80049516992cdd06c5d6cf7265af1abe4156f98 (diff)
downloadnextcloud-server-7aad5b7721bbecf673b1adb4f40a9b561bf6949e.tar.gz
nextcloud-server-7aad5b7721bbecf673b1adb4f40a9b561bf6949e.zip
Merge pull request #10543 from nextcloud/ignore-deactivated-users
Do not show deactivated users in sharees and contacts
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/CardDAV/SyncService.php24
-rw-r--r--apps/dav/tests/unit/CardDAV/SyncServiceTest.php25
2 files changed, 35 insertions, 14 deletions
diff --git a/apps/dav/lib/CardDAV/SyncService.php b/apps/dav/lib/CardDAV/SyncService.php
index ee68a4a26ec..5bd92015ad7 100644
--- a/apps/dav/lib/CardDAV/SyncService.php
+++ b/apps/dav/lib/CardDAV/SyncService.php
@@ -270,18 +270,22 @@ class SyncService {
$cardId = "$name:$userId.vcf";
$card = $this->backend->getCard($addressBookId, $cardId);
- if ($card === false) {
- $vCard = $converter->createCardFromUser($user);
- if ($vCard !== null) {
- $this->backend->createCard($addressBookId, $cardId, $vCard->serialize());
- }
- } else {
- $vCard = $converter->createCardFromUser($user);
- if (is_null($vCard)) {
- $this->backend->deleteCard($addressBookId, $cardId);
+ if ($user->isEnabled()) {
+ if ($card === false) {
+ $vCard = $converter->createCardFromUser($user);
+ if ($vCard !== null) {
+ $this->backend->createCard($addressBookId, $cardId, $vCard->serialize());
+ }
} else {
- $this->backend->updateCard($addressBookId, $cardId, $vCard->serialize());
+ $vCard = $converter->createCardFromUser($user);
+ if (is_null($vCard)) {
+ $this->backend->deleteCard($addressBookId, $cardId);
+ } else {
+ $this->backend->updateCard($addressBookId, $cardId, $vCard->serialize());
+ }
}
+ } else {
+ $this->backend->deleteCard($addressBookId, $cardId);
}
}
diff --git a/apps/dav/tests/unit/CardDAV/SyncServiceTest.php b/apps/dav/tests/unit/CardDAV/SyncServiceTest.php
index 1ca27d61ce4..7d444571fac 100644
--- a/apps/dav/tests/unit/CardDAV/SyncServiceTest.php
+++ b/apps/dav/tests/unit/CardDAV/SyncServiceTest.php
@@ -84,14 +84,30 @@ class SyncServiceTest extends TestCase {
$ss->ensureSystemAddressBookExists('principals/users/adam', 'contacts', []);
}
- public function testUpdateAndDeleteUser() {
+ public function dataActivatedUsers() {
+ return [
+ [true, 1, 1, 1],
+ [false, 0, 0, 3],
+ ];
+ }
+
+ /**
+ * @dataProvider dataActivatedUsers
+ *
+ * @param boolean $activated
+ * @param integer $createCalls
+ * @param integer $updateCalls
+ * @param integer $deleteCalls
+ * @return void
+ */
+ public function testUpdateAndDeleteUser($activated, $createCalls, $updateCalls, $deleteCalls) {
/** @var CardDavBackend | \PHPUnit_Framework_MockObject_MockObject $backend */
$backend = $this->getMockBuilder(CardDavBackend::class)->disableOriginalConstructor()->getMock();
$logger = $this->getMockBuilder(ILogger::class)->disableOriginalConstructor()->getMock();
- $backend->expects($this->once())->method('createCard');
- $backend->expects($this->once())->method('updateCard');
- $backend->expects($this->once())->method('deleteCard');
+ $backend->expects($this->exactly($createCalls))->method('createCard');
+ $backend->expects($this->exactly($updateCalls))->method('updateCard');
+ $backend->expects($this->exactly($deleteCalls))->method('deleteCard');
$backend->method('getCard')->willReturnOnConsecutiveCalls(false, [
'carddata' => "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 3.4.8//EN\r\nUID:test-user\r\nFN:test-user\r\nN:test-user;;;;\r\nEND:VCARD\r\n\r\n"
@@ -106,6 +122,7 @@ class SyncServiceTest extends TestCase {
$user->method('getUID')->willReturn('test-user');
$user->method('getCloudId')->willReturn('cloudId');
$user->method('getDisplayName')->willReturn('test-user');
+ $user->method('isEnabled')->willReturn($activated);
$accountManager = $this->getMockBuilder(AccountManager::class)->disableOriginalConstructor()->getMock();
$accountManager->expects($this->any())->method('getUser')
->willReturn([