Skip to content

Commit fbbab33

Browse files
committed
fixup! fix(env-mode): accept multiple comma-separated groups
1 parent 4d05f70 commit fbbab33

File tree

4 files changed

+26
-299
lines changed

4 files changed

+26
-299
lines changed

lib/Controller/SAMLController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private function autoprovisionIfPossible(): void {
9494
$autoProvisioningAllowed = $this->userBackend->autoprovisionAllowed();
9595
if ($userExists) {
9696
if ($autoProvisioningAllowed) {
97-
$this->userBackend->updateAttributes($uid, $auth);
97+
$this->userBackend->updateAttributes($uid);
9898
}
9999
return;
100100
}
@@ -104,7 +104,7 @@ private function autoprovisionIfPossible(): void {
104104
throw new NoUserFoundException('Auto provisioning not allowed and user ' . $uid . ' does not exist');
105105
} elseif (!$userExists && $autoProvisioningAllowed) {
106106
$this->userBackend->createUserIfNotExists($uid, $auth);
107-
$this->userBackend->updateAttributes($uid, $auth);
107+
$this->userBackend->updateAttributes($uid);
108108
return;
109109
}
110110
}

lib/UserBackend.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,8 @@ private function getAttributeValue($name, array $attributes) {
474474
return $value;
475475
}
476476

477-
public function updateAttributes(string $uid, array $attributes): void {
477+
public function updateAttributes(string $uid): void {
478+
$attributes = $this->userData->getAttributes();
478479
$user = $this->userManager->get($uid);
479480
try {
480481
$newEmail = $this->getAttributeValue('saml-attribute-mapping-email_mapping', $attributes);

tests/unit/UserBackendTest.php

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,13 @@ public function testUpdateAttributes() {
155155
/** @var IUser|MockObject $user */
156156
$user = $this->createMock(IUser::class);
157157

158+
$attributes = [
159+
'email' => '[email protected]',
160+
'displayname' => 'New Displayname',
161+
'quota' => '50MB',
162+
'groups' => ['groupB', 'groupC'],
163+
];
164+
158165
// Replace at() matcher with willReturnCallback to avoid deprecation warning
159166
$this->config
160167
->method('getAppValue')
@@ -204,19 +211,20 @@ public function testUpdateAttributes() {
204211
->expects($this->once())
205212
->method('handleIncomingGroups')
206213
->with($user, ['groupB', 'groupC']);
207-
$this->userBackend->updateAttributes('ExistingUser', [
208-
'email' => '[email protected]',
209-
'displayname' => 'New Displayname',
210-
'quota' => '50MB',
211-
'groups' => ['groupB', 'groupC'],
212-
]);
214+
$this->userData->expects($this->any())
215+
->method('getAttributes')
216+
->willReturn($attributes);
217+
$this->userData->expects($this->any())
218+
->method('getGroups')
219+
->willReturn($attributes['groups']);
220+
$this->userBackend->updateAttributes('ExistingUser');
213221
}
214222

215223
public function testUpdateAttributesQuotaDefaultFallback() {
216224
$this->getMockedBuilder(['getDisplayName', 'setDisplayName']);
217225
/** @var IUser|MockObject $user */
218226
$user = $this->createMock(IUser::class);
219-
227+
$attributes = ['email' => '[email protected]', 'displayname' => 'New Displayname', 'quota' => ''];
220228

221229
$this->config->method('getAppValue')
222230
->willReturnCallback(fn (string $appId, string $key, string $default) =>
@@ -261,6 +269,12 @@ public function testUpdateAttributesQuotaDefaultFallback() {
261269
->expects($this->once())
262270
->method('handleIncomingGroups')
263271
->with($user, []);
264-
$this->userBackend->updateAttributes('ExistingUser', ['email' => '[email protected]', 'displayname' => 'New Displayname', 'quota' => '']);
272+
$this->userData->expects($this->any())
273+
->method('getAttributes')
274+
->willReturn($attributes);
275+
$this->userData->expects($this->any())
276+
->method('getGroups')
277+
->willReturn([]);
278+
$this->userBackend->updateAttributes('ExistingUser');
265279
}
266280
}

tests/unit/UserBackendTest.php.orig

Lines changed: 0 additions & 288 deletions
This file was deleted.

0 commit comments

Comments
 (0)