Skip to content

Commit

Permalink
fixup! Allow SSO users to send and recieve mail via master password
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <[email protected]>
  • Loading branch information
ChristophWurst committed Oct 27, 2023
1 parent abf92a6 commit 87a893f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/Db/ProvisioningMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function validate(array $data): Provisioning {
$provisioning->setSmtpPort((int)$data['smtpPort']);
$provisioning->setSmtpSslMode($data['smtpSslMode']);

$provisioning->setMasterPasswordEnabled((bool)$data['masterPasswordEnabled']);
$provisioning->setMasterPasswordEnabled((bool)($data['masterPasswordEnabled'] ?? false));
$provisioning->setMasterPassword($data['masterPassword'] ?? '');

$provisioning->setSieveEnabled((bool)$data['sieveEnabled']);
Expand Down
36 changes: 32 additions & 4 deletions tests/Unit/Service/Provisioning/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public function testDeprovision() {
$this->manager->deprovision($config);
}

public function testUpdatePasswordNotProvisioned() {
public function testUpdatePasswordNotProvisioned(): void {
/** @var IUser|MockObject $user */
$user = $this->createMock(IUser::class);
$this->mock->getParameter('mailAccountMapper')
Expand All @@ -213,23 +213,51 @@ public function testUpdatePasswordNotProvisioned() {
->with($user)
->willThrowException($this->createMock(DoesNotExistException::class));

$this->manager->updatePassword($user, '123456');
$this->manager->updatePassword($user, '123456', []);
}

public function testUpdatePassword() {
public function testUpdateLoginPassword(): void {
/** @var IUser|MockObject $user */
$user = $this->createMock(IUser::class);
$account = $this->createMock(MailAccount::class);
$this->mock->getParameter('mailAccountMapper')
->expects($this->once())
->method('findProvisionedAccount')
->willReturn($account);
$config = new Provisioning();
$config->setProvisioningDomain(Provisioning::WILDCARD);
$config->setMasterPasswordEnabled(false);
$this->mock->getParameter('mailAccountMapper')
->expects($this->once())
->method('update')
->with($account);

$this->manager->updatePassword($user, '123456', [$config]);
}

public function testUpdateMasterPassword(): void {
/** @var IUser|MockObject $user */
$user = $this->createMock(IUser::class);
$account = $this->createMock(MailAccount::class);
$this->mock->getParameter('mailAccountMapper')
->expects($this->once())
->method('findProvisionedAccount')
->willReturn($account);
$config = new Provisioning();
$config->setProvisioningDomain(Provisioning::WILDCARD);
$config->setMasterPasswordEnabled(true);
$config->setMasterPassword('topsecret');
$this->mock->getParameter('crypto')
->expects(self::atLeast(1))
->method('encrypt')
->with('topsecret')
->willReturn('tercespot');
$this->mock->getParameter('mailAccountMapper')
->expects($this->once())
->method('update')
->with($account);

$this->manager->updatePassword($user, '123456');
$this->manager->updatePassword($user, '123456', [$config]);
}

public function testNewProvisioning(): void {
Expand Down

0 comments on commit 87a893f

Please sign in to comment.