Skip to content

Commit

Permalink
Merge branch 'release' into 'master'
Browse files Browse the repository at this point in the history
v4.4.2

See merge request passbolt/passbolt-ce-api!212
  • Loading branch information
gmougenel committed Nov 29, 2023
2 parents 9ee0842 + 60cc51d commit bc93285
Show file tree
Hide file tree
Showing 23 changed files with 313 additions and 139 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [4.4.2] - 2023-11-29
### Improved
- PB-27616 As a user I should see improved performances when retrieving resources on the GET resources.json entry point

### Fixed
- PB-28991 As a user emails should be resent if the first attempt failed

## [4.4.2-test.1] - 2023-11-27
### Improved
- PB-27616 As a user I should see improved performances when retrieving resources on the GET resources.json entry point

## [4.4.1] - 2023-11-20
### Improved
- PB-28521 Alter the gpgkeys.uid column length to 769 to enable the synchronisation of user with very long names
Expand Down
20 changes: 9 additions & 11 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
Release song: https://youtu.be/RbmS3tQJ7Os?si=lp8QM5B-R65C8Jek
Release song: https://youtu.be/6JNwqRF32ZI

Passbolt v4.4.1 is a maintenance release aimed at addressing issues reported by the community, which were introduced in the previous release.
Passbolt version 4.4.2 has been released, primarily as a maintenance update to address specific issues reported by users. This version includes two main fixes.

The update addresses an issue concerning user roles in email notifications. Previously, administrators received notifications when another administrator was deleted. However, the deletion of any user, regardless of their administrator status, was incorrectly reported as an administrator deletion. This issue has been resolved.
The first fix concerns the Time-based One-Time Password (TOTP) feature. In the previous version, there was an issue where users could accidentally delete the TOTP secret for a resource while editing its description from the sidebar. This has been corrected in the latest update.

We extend our gratitude to the community members who reported these issues. Your support and patience are greatly appreciated.
The second fix improves the performance of the application, specifically when users are retrieving their resources. This update is part of an ongoing effort to enhance the overall performance of the application, with further improvements planned for future releases.

## [4.4.1] - 2023-11-20
We extend our gratitude to the community member who reported this issue.

## [4.4.2] - 2023-11-28
### Improved
- PB-28521 Alter the gpgkeys.uid column length to 769 to enable the synchronisation of user with very long names
- PB-27616 As a user I should see improved performances when retrieving resources on the GET resources.json entry point

### Fixed
- PB-27957 As an administrator I should be notified that an administrator was deleted only when an administrator has been deleted, and not a regular user

### Maintenance
- PB-27927 Remove unused user_agents table
- PB-28616 Refactor the email digest plugin code for easier usage and maintainability
- PB-28991 As a user emails should be resent if the first attempt failed
4 changes: 2 additions & 2 deletions config/version.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
return [
'passbolt' => [
'version' => '4.4.1',
'name' => 'Gimme Shelter',
'version' => '4.4.2',
'name' => 'Is It Because I\'m Black?',
],
'php' => [
'minVersion' => '7.4',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public function buildSingleEmailDigest(Entity $emailQueueEntity): EmailDigest
return (new EmailDigest())
->addEmailData($emailQueueEntity)
->setSubject($emailQueueEntity->get('subject'))
->setEmailIds([$emailQueueEntity->id])
->setEmailRecipient($emailQueueEntity->get('email'));
}

Expand All @@ -111,6 +112,8 @@ public function buildMultipleEmailDigest(Digest $digest): EmailDigest
->setEmailRecipient($emailQueueEntity->get('email'));
}

$emailDigest->setEmailIds($digest->getEmailQueueIds());

return $emailDigest;
}

Expand Down
18 changes: 15 additions & 3 deletions plugins/PassboltCe/EmailDigest/tests/Factory/EmailQueueFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,12 @@ public function setFullBaseUrl(string $fullBaseUrl)
}

/**
* @param string $subject locale of the email
* @return EmailQueueFactory
* @param ?string $subject locale of the email
* @return $this
*/
public function setSubject(string $subject)
public function setSubject(?string $subject = null)
{
$subject = $subject ?? $this->getFaker()->sentence(3);
$this->setField('template_vars.body.subject', $subject);

return $this->setField('subject', $subject);
Expand All @@ -164,4 +165,15 @@ public function setLocale(string $locale)
{
return $this->setField('template_vars.locale', $locale);
}

/**
* Sets the id of the email. Useful in unit testing, when an ID should be defined, but no persistence needed
*
* @param int|null $id email Id
* @return $this
*/
public function setId(?int $id = null)
{
return $this->setField('id', $id ?? $this->getFaker()->randomNumber(4));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ class GroupUserDeleteEmailQueueFactory extends EmailQueueFactory
protected function setDefaultTemplate(): void
{
parent::setDefaultTemplate();
$this->setTemplate(GroupUserDeleteEmailRedactor::TEMPLATE);
$this->setGroup();
$this->setOperator();
$this
->setSubject()
->setTemplate(GroupUserDeleteEmailRedactor::TEMPLATE)
->setGroup()
->setOperator();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ protected function setDefaultTemplate(): void
{
parent::setDefaultTemplate();
$this
->setSubject()
->setTemplate(ResourceDeleteEmailRedactor::TEMPLATE)
->setResource()
->setOperator()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
use App\Test\Factory\UserFactory;
use App\Test\Lib\AppIntegrationTestCase;
use App\Test\Lib\Utility\EmailTestTrait;
use App\Utility\UuidFactory;
use Cake\Chronos\Chronos;
use Cake\Console\TestSuite\ConsoleIntegrationTestTrait;
use Cake\I18n\I18n;
use Cake\Mailer\Mailer;
use Cake\Network\Exception\SocketException;
use Passbolt\EmailDigest\Test\Factory\EmailQueueFactory;
use Passbolt\EmailDigest\Test\Lib\EmailDigestMockTestTrait;
use Passbolt\EmailDigest\Utility\Digest\DigestTemplateRegistry;
Expand Down Expand Up @@ -124,17 +126,86 @@ public function testSenderCommandLocale()
$this->assertMailBodyStringCount(1, '</head>');
}

public function testSenderCommand_NoRowsAreLockedWhenThresholdIsExceeded()
public function noRowsLockedProvider(): array
{
$nResourcesAdded = 15;
$operator = UserFactory::make()->withAvatar()->persist();
return [
['single_email' => 1],
['multiple_emails_in_digest' => 2],
['threshold_exceeded' => 11],
];
}

/**
* @dataProvider noRowsLockedProvider
*/
public function testSenderCommand_EmailQueueRowsAreUnlockedAfterSuccessfulSend(int $nResourcesAdded)
{
$operator = UserFactory::make()->withAvatar()->getEntity();
$recipient = '[email protected]';
EmailQueueFactory::make($nResourcesAdded)
->setRecipient($recipient)
->setTemplate(ResourceCreateEmailRedactor::TEMPLATE)
->setField('template_vars.body.user', $operator)
->setField('template_vars.body.resource', [
// Dummy data to render email without any warnings
'id' => UuidFactory::uuid(),
'created' => 'now',
'name' => 'My pass',
'secrets' => [['data' => 'foo bar baz']],
])
->setField('template_vars.body.showUsername', false)
->setField('template_vars.body.showUri', false)
->setField('template_vars.body.showDescription', false)
->setField('template_vars.body.showSecret', false)
->persist();

$this->exec('passbolt email_digest send');

$this->assertExitSuccess();
$this->assertMailCount(1);
$this->assertMailSentToAt(0, [$recipient => $recipient]);
// Make sure email queue entries are not locked
$count = EmailQueueFactory::find()->where(['locked' => true])->count();
$this->assertEquals(0, $count);
// Make sure email queue entries are sent
$count = EmailQueueFactory::find()->where(['sent' => true, 'locked' => false])->count();
$this->assertEquals($nResourcesAdded, $count);
}

/**
* @dataProvider noRowsLockedProvider
*/
public function testSenderCommand_EmailQueueRowsAreUnlockedAfterFailedSend(int $nResourcesAdded)
{
$operator = UserFactory::make()->withAvatar()->getEntity();
$recipient = '[email protected]';
EmailQueueFactory::make($nResourcesAdded)
->setRecipient($recipient)
->setTemplate(ResourceCreateEmailRedactor::TEMPLATE)
->setField('template_vars.body.user', $operator)
->setField('template_vars.body.resource', [
// Dummy data to render email without any warnings
'id' => UuidFactory::uuid(),
'created' => 'now',
'name' => 'My pass',
'secrets' => [['data' => 'foo bar baz']],
])
->setField('template_vars.body.showUsername', false)
->setField('template_vars.body.showUri', false)
->setField('template_vars.body.showDescription', false)
->setField('template_vars.body.showSecret', false)
->persist();

$mockedEmailQueue = $this->getMockForModel(
'EmailQueue.EmailQueue',
['success',],
['table' => 'email_queue',]
);
$mockedEmailQueue
->expects($this->once())
->method('success')
->willThrowException(new SocketException());

$this->exec('passbolt email_digest send');

$this->assertExitSuccess();
Expand All @@ -143,6 +214,9 @@ public function testSenderCommand_NoRowsAreLockedWhenThresholdIsExceeded()
// Make sure email queue entries are not locked
$count = EmailQueueFactory::find()->where(['locked' => true])->count();
$this->assertEquals(0, $count);
// Make sure email queue entries are not sent
$count = EmailQueueFactory::find()->where(['sent' => false, 'locked' => false])->count();
$this->assertEquals($nResourcesAdded, $count);
}

public function testSenderCommandMultipleDigests()
Expand Down Expand Up @@ -174,6 +248,9 @@ public function testSenderCommandMultipleDigests()
$this->exec('passbolt email_digest send');
$this->assertExitSuccess();

$sentCount = EmailQueueFactory::find()->where(['sent' => true])->count();
$this->assertSame($nEmailsSent * 2, $sentCount);

$this->assertMailCount(2);
$subject = $user->profile->full_name . ' has made changes on several resources';
$this->assertMailSubjectContainsAt(0, $subject);
Expand Down
Loading

0 comments on commit bc93285

Please sign in to comment.